Commit Graph

743 Commits

Author SHA1 Message Date
Vlad Shcherbina 4eb22a3c20 Travis: move doc build step to `script` #115
To ensure that doc build failures aren't silently ignored.
2018-02-14 20:45:08 +03:00
Vlad Shcherbina c4939ab9d7 Fix documentation build (hopefully) #115 2018-02-14 19:23:09 +03:00
Vlad Shcherbina f8d914cac8 Fix broken links
https://pyo3.github.io/PyO3 -> https://pyo3.github.io/pyo3
in the documentation.
2018-02-14 17:21:17 +03:00
Brian Anderson 473b1f8b30 Use version 0.2 in guide overview 2018-02-13 00:14:51 +03:00
Vlad Shcherbina a59e1dc8ad Fix unused_parens warnings
I left the parentheses in place to keep the resemblance
to the original C macros.
2018-02-12 14:36:05 +03:00
Nikolay Kim 30baa990f8
Update CHANGES.txt 2018-02-11 09:38:50 -08:00
Nikolay Kim 0874c243ef
Merge pull request #112 from Vlad-Shcherbina/patch-3
Disallow str/float to int conversions #108
2018-02-11 09:37:28 -08:00
Vlad Shcherbina a5d3ed0939 Add tests that string/float to int conversions raise TypeError #108 2018-02-11 19:09:15 +03:00
Vlad Shcherbina 9fe78b5cb3 Disallow implicit weakly-typed conversions to integers #108
In `int_fits_c_long!`,
use `PyLong_AsLong(PyNumber_Index(x))`
instead of `PyNumber_Index(x)`.

In `int_convert_u64_or_i64!`,
use `PyLong_As*LongLong(PyNumber_Index(x))`
instead of `PyLong_As*LongLong(if PyLong_Check(x) {x} else {PyNumber_Long(x)})`.

Along the way, fix memory leak caused by missing `Py_DECREF(num)`.


`PyNumber_Index(x)` is the best way to get an integer losslessly:
https://docs.python.org/3/reference/datamodel.html#object.__index__
https://docs.python.org/3.5/c-api/number.html#c.PyNumber_Index

`PyLong_AsLong(x)` has the problem that it attempts to call `x.__int__()`.
Strings don't implement this method, but floats do, so it silently converts
floats to integers.
https://docs.python.org/3.5/c-api/long.html#c.PyLong_AsLong

`PyNumber_Long(x)` is equivalent to `int(x)` call,
so not only does it truncate floats, but also attempts to parse strings.
https://docs.python.org/3.5/c-api/number.html#c.PyNumber_Long

`PyLong_Check(x)` is redundant because it happens inside `PyNumber_Index(x)`
anyway:
988fb28431/Objects/abstract.c (L1259)
2018-02-11 19:04:12 +03:00
Vlad Shcherbina f8e503f3b7 Drop tests for implicit float to int conversions #108
Neither Python nor Rust has implicit float to integer conversions
(they mask programming errors), so it would make sense for the
bindings library to disallow them as well.

Later there will be tests that such conversions result in TypeError.
2018-02-11 18:19:21 +03:00
Nikolay Kim b4f7273474
Update CHANGES.txt 2018-02-10 11:27:45 -08:00
Nikolay Kim ffb5880fa2
Merge pull request #111 from Vlad-Shcherbina/patch-2
Remove PyEval_ThreadsInitialized() assertion #110
2018-02-10 11:26:31 -08:00
Vlad Shcherbina 81fd4bd24e Remove PyEval_ThreadsInitialized() assertion #110
First, this function should not be called before `Py_Initialize()`.
It accesses the field `_PyRuntime.ceval.gil.locked` of the global
variable, which is zero initially, but uses -1 to indicate that
the GIL is not created or destroyed.
(8ff5356473/Python/ceval_gil.h (L98))

Second, this assertion can't be moved after `Py_InitializeEx(0)` call,
because in Python 3.7 they started calling `PyEval_InitThreads()`
from `Py_Initialize()`.
(2914bb32e2 (diff-baf5eab51059d96fb8837152dab0d1a4R689))
2018-02-10 21:36:59 +03:00
Nikolay Kim 8b7a57891b
Merge pull request #109 from Vlad-Shcherbina/patch-1
Remove too strict version requirement for Windows
2018-02-10 07:48:33 -08:00
Vlad-Shcherbina 4f3e5ba357
Remove too strict version requirement for Windows
The special rustc version requirement for Windows was introduced in
f6ed2bbae9 (diff-04c6e90faac2675aa89e2176d2eec7d8R23)

Required versions converged in
0c7293125c (diff-04c6e90faac2675aa89e2176d2eec7d8R19)

And since then it seems they were updated mechanically in sync.
2018-02-10 15:37:34 +03:00
Nikolay Kim 63a2066a39 can not use workspace for examples 2018-01-19 10:27:37 -08:00
Nikolay Kim 96ad2efddf do not use workspaces 2018-01-19 10:18:57 -08:00
Nikolay Kim c39a1d7e94 Add examples to workspace 2018-01-19 10:10:32 -08:00
Nikolay Kim 3681cf51e8 python2 compatibility 2018-01-19 10:08:13 -08:00
Nikolay Kim b738c1a04b clippy warnings 2018-01-19 10:02:36 -08:00
Nikolay Kim 324a6b2697 drop RefFromPyObject; allow mut refs #106 2018-01-19 09:04:42 -08:00
Nikolay Kim 35e91a5cd1 Merge branch 'master' of github.com:PyO3/pyo3 2018-01-17 08:10:01 -08:00
Nikolay Kim d6035bce15 Fix impl FromPyObject for Py<T> 2018-01-17 08:09:44 -08:00
Nikolay Kim 8f2a705cd6
Merge pull request #97 from guanqun/fix-description
display the required version and current version in error message
2017-12-27 08:25:06 -08:00
Nikolay Kim 8ee8562a7f
Merge pull request #101 from guanqun/typo-fix
typo fix
2017-12-27 08:24:43 -08:00
Guanqun Lu 81f31153aa doc fixes 2017-12-27 23:10:19 +08:00
Guanqun Lu cd17b41b88 add a rust-toolchain file in the repo to indicate the toolchain used 2017-12-27 22:36:13 +08:00
Guanqun Lu 4bc079f619 typo fix 2017-12-27 22:11:18 +08:00
Guanqun Lu 4b26edfa09 display the required version and current version in error message 2017-12-27 18:35:49 +08:00
Nikolay Kim 9a141fb921 changelog 2017-12-26 13:42:32 -08:00
Nikolay Kim 050397b723 mark method that work with raw pointer unsafe 2017-12-26 13:41:27 -08:00
Nikolay Kim 017c404d69 fix travis build 2017-12-18 19:47:23 -08:00
Nikolay Kim 1f6c73e91a add link to crate 2017-11-27 11:51:42 -08:00
Nikolay Kim 3cb57f5579 prepare release 2017-11-27 11:40:03 -08:00
Nikolay Kim 70b07f8112 update version 2017-11-27 11:27:09 -08:00
Nikolay Kim 653f081d65 enable coverage for master only 2017-11-27 11:19:22 -08:00
Nikolay Kim 6a31a4cbb7 kcov only for py3.6 2017-11-27 11:07:50 -08:00
Nikolay Kim a57ebc7928 fix travis 2017-11-27 11:06:53 -08:00
Nikolay Kim 258e84c4e2 enable coverage 2017-11-27 11:05:51 -08:00
Nikolay Kim 99d5994d95 enable coverage 2017-11-27 11:04:49 -08:00
Nikolay Kim d3832359a2 proper c_char usage #93 2017-11-27 10:59:45 -08:00
messense e7a7b3d5a0
Remove use of now unneeded 'AsciiExt' trait 2017-11-23 12:08:05 +08:00
Nikolay Kim e5bf656cbc revert pycls changes; fix word-cound-cls example 2017-11-18 07:20:03 -10:00
Nikolay Kim d02a950eb6 test word-count-cls 2017-11-18 07:09:39 -10:00
Nikolay Kim 9d56fd279a enable const_align_of future 2017-11-18 07:07:45 -10:00
Nikolay Kim b5ffefc50c use as_ref for PyRawObject in __new__ wrapper 2017-11-18 07:07:19 -10:00
dkao1978 eb9050ab90 Add documentation for compiling on MacOS (#89)
* Update README.md

* Update overview.md

* Update lib.rs

* Update README.md

* Add links
2017-10-22 11:17:35 +08:00
serpilliere 68937db201 Update README version (#83) 2017-10-06 09:54:51 -05:00
Nikolay Kim ff2780cb80 Rename LICENSE-APACHE to LICENSE 2017-10-04 08:56:57 -07:00
Nikolay Kim 086a28e230 Delete LICENSE-MIT 2017-10-04 08:56:25 -07:00