Commit Graph

591 Commits

Author SHA1 Message Date
David Hewitt fe75b2da59
Merge pull request #1482 from PyO3/dependabot/cargo/num-complex-0.4
build(deps): update num-complex requirement from 0.3 to 0.4
2021-03-08 22:06:51 +00:00
David Hewitt 5e44c2b0d6
Merge pull request #1473 from davidhewitt/initconfig-limited-api
ffi: move initconfig.rs to cpython/initconfig.rs
2021-03-08 21:59:58 +00:00
David Hewitt 993d461287 changelog: add entry for num-complex update 2021-03-08 21:35:50 +00:00
David Hewitt 818039ff93 changelog: add entry for num-bigint update 2021-03-08 08:03:05 +00:00
David Hewitt 23b5fe9e69 ffi: add _Py_InitializeMain 2021-03-06 22:45:19 +00:00
Georg Brandl e065f9b517 PyModule: rename call* to call_function*
For consistency with PyObject/PyAny, where call() means to call the
object itself.
2021-03-04 09:29:28 +01:00
David Hewitt 29a525b327 pyfunction: refactor argument extraction 2021-03-01 17:49:46 +00:00
David Hewitt ffd5874c3a pyfunction: fix args conflicting with keyword only arg 2021-03-01 17:49:46 +00:00
David Hewitt 9acf242ccc tuples: support conversions up to length 12 2021-03-01 08:32:13 +00:00
David Hewitt 593be05b83
Merge pull request #1436 from nw0/ffi-8
ffi cleanup: abstract.h
2021-02-28 07:55:35 +00:00
Nicholas Sim d278aaff54 Remove PyIter_Check, PyIndex_Check under abi3 for Python < 3.8
While these are defined as macros in the Python C API, they rely on
access to the PyTypeObject structure, which is not part of the limited
API for those versions.
2021-02-28 13:25:22 +08:00
David Hewitt 1aa1e91ce6 pycfunction: take &'static str arguments to new
Co-authored-by: messense <messense@icloud.com>
2021-02-27 09:33:15 +00:00
Nicholas Sim 13bfbd38b4 CHANGELOG: update 2021-02-22 23:04:17 +00:00
Nicholas Sim 24f091b8ff remove cfg for PyTryFrom impl for PyIterator 2021-02-22 23:03:13 +00:00
Nicholas Sim f7edd35a9e ffi cleanup: abstract.h 2021-02-22 23:00:51 +00:00
David Hewitt 9e4e0dbbe0 auto-initialize: remove from default features 2021-02-22 22:34:34 +00:00
Daniil Konovalenko 554cffd60d
add #[pyo3(from_py_with="...")] attribute (#1411)
* allow from_py_with inside #[derive(FromPyObject)]
* split up FnSpec::parse
2021-02-21 00:15:20 +09:00
David Hewitt 0c3517a6e0 ffi: further removals 2021-02-20 07:22:08 +00:00
Nicholas Sim 04c9388a3d
Merge branch 'master' into ffi-6 2021-02-16 19:46:49 +08:00
Nicholas Sim d8198f8beb ffi cleanup: remove PyTypeObject_INIT
This should only be used internally. See discussion:
https://github.com/PyO3/pyo3/pull/1429#discussion_r575837123
2021-02-16 19:36:15 +08:00
David Hewitt 7fa3b36eb4
Merge pull request #1428 from PyO3/macos-arm64-cross
Don't require PYO3_CROSS_LIB_DIR when compiling for x86_64 from macOS arm64 and reverse
2021-02-14 14:06:12 +00:00
David Hewitt 07c7624506
Merge pull request #1379 from kangalioo/master
OsStr and Path conversions
2021-02-14 13:13:53 +00:00
Nicholas Sim 031840652c
Merge branch 'master' into ffi-6 2021-02-14 21:00:28 +08:00
Nicholas Sim a3b1f35767 CHANGELOG: update with PR number 2021-02-14 20:55:58 +08:00
Nicholas Sim 67e1755f9c ffi cleanup: deprecate some nonexistent functions 2021-02-14 20:44:55 +08:00
David Hewitt 442a04efdd
Merge pull request #1397 from kangalioo/get_fold_bool
Make PyTimeAccess::get_fold() return bool instead of u8
2021-02-14 12:17:38 +00:00
messense ebc52c4aea Don't require PYO3_CROSS_LIB_DIR when compiling for x86_64 from macOS arm64 and reverse 2021-02-14 16:43:50 +08:00
kangalioo 87ee51fb86 Make PyTimeAccess::get_fold return bool 2021-02-13 20:28:28 +00:00
kangalioo fe9b4625d1 Implement conversions for Path/PathBuf 2021-02-13 20:22:16 +00:00
David Hewitt 1196cbd396 0.14: deprecations 2021-02-13 20:03:39 +00:00
Nicholas Sim aaddb20a22 CHANGELOG: update as requested 2021-02-13 17:07:03 +08:00
Nicholas Sim d34856ba59 CHANGELOG: add PR number 2021-02-13 15:43:12 +08:00
Nicholas Sim d84d0de604 ffi cleanup: methodobject to moduleobject 2021-02-13 15:36:59 +08:00
David Hewitt 190eb72803 release: 0.13.2 2021-02-12 21:34:29 +00:00
Christoph Reiter e067b32521 Support building with Mingw Python
The DLL of the mingw Python in MSYS2 is named libpython3.8.dll:

$ python3 -m sysconfig | grep LIBPYTHON
        LIBPYTHON = "-lpython3.8"

Add another special case to in get_rustc_link_lib() to handle that case.
Afaik the mingw build doesn't support the limited ABI, so skipt that as well.

This makes all tests pass in an MSYS2 environment and lets us build
python-cryptography.
2021-02-12 12:31:20 +00:00
David Hewitt 59dac57689 build: fix support for non-utf8 systems 2021-01-26 23:16:47 +00:00
David Hewitt 3a627587f6
Merge pull request #1404 from nw0/mark-safe
Remove `unsafe` for some safe functions
2021-01-26 21:57:49 +00:00
Nicholas Sim 7dddb8b0c0 Remove `unsafe` for some safe functions 2021-01-26 17:52:26 +08:00
Matthew Neeley d92f22a7fc Add CHANGELOG entry 2021-01-25 11:49:20 -08:00
kangalioo f135bb046e Add changelog entry 2021-01-21 09:55:32 +01:00
David Hewitt 3de51d59df
Merge pull request #1384 from ijl/pycfunctionfastwithkeyboards
Define _PyCFunctionFastWithKeywords() on CPython 3.7+
2021-01-15 14:50:35 +00:00
David Hewitt 2ada44b7e0
Apply suggestions from review
Co-authored-by: Nicholas Sim <nsim+github@posteo.net>
2021-01-15 12:58:06 +00:00
Nicholas Sim d023338ed5 speculatively add PR number 2021-01-15 18:26:26 +08:00
Nicholas Sim a460f7d287 ffi module cleanup: listobject.h to memoryobject.h 2021-01-15 18:24:45 +08:00
ijl d0145bb4ee Define _PyCFunctionFastWithKeywords() on CPython 3.7+ 2021-01-13 15:44:36 +00:00
David Hewitt 9807ef8ed4 macros-backend: fix raw idents in pymethods 2021-01-12 22:01:11 +00:00
David Hewitt dc7bcdaf9b gil: move finalization from prepare_freethreaded_python to
with_embedded_python_interpreter
2021-01-12 07:44:37 +00:00
David Hewitt 7c61c9b7f9 gil: tidy ups to finalization 2021-01-12 07:42:47 +00:00
Daniil Konovalenko abb5829e9c implement Serialize, Deserialize for Py<T> 2021-01-11 22:19:10 +00:00
David Hewitt d2e87d95f3 release: 0.13.1 2021-01-10 12:20:10 +00:00
konstin 02f3d5cc90 Deprecate functions from PEP 623 2021-01-10 10:18:08 +00:00
David Hewitt 0257acfd08 changelog: add Deprecated sections 2021-01-09 08:45:02 +00:00
David Hewitt b92441cd7c pyclass: fix reference count issue in subclass new 2021-01-08 00:13:49 +00:00
David Hewitt e0c35d17dd auto-initialize: add CHANGELOG and docs 2021-01-04 21:08:08 +00:00
David Hewitt a350dd2c20 build: make include dir optional when targeting Windows 2020-12-31 22:02:29 +00:00
David Hewitt b1012ebb68 build: update for Rust 1.49 2020-12-31 18:16:02 +00:00
Nicholas Sim 05812d5f55 ffi module cleanup: update CHANGELOG 2020-12-29 18:21:11 +08:00
Nicholas Sim 717050af4b
Merge branch 'master' into ffi-1 2020-12-28 21:22:42 +08:00
Nicholas Sim aadb58621c fix errors in PR 2020-12-28 21:18:27 +08:00
David Hewitt 1e5e93d458
Merge pull request #1342 from davidhewitt/abi3-dict-weakref
abi3: add support for dict and weakref from Python 3.9
2020-12-28 13:00:59 +00:00
Nicholas Sim 1fd86132e0 CHANGELOG: update as requested 2020-12-28 20:54:56 +08:00
Nicholas Sim 55a602462d
Apply suggestions from code review
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-12-28 20:51:08 +08:00
Nicholas Sim f2ddea9dba
Merge branch 'master' into ffi-1 2020-12-28 19:44:09 +08:00
David Hewitt 7572962828 abi3: add support for dict and weakref from Python 3.9 2020-12-28 10:22:46 +00:00
Nicholas Sim 3518ac3c3f Update changelog, allow use of deprecated PyGetSetDef_DICT 2020-12-28 18:17:10 +08:00
David Hewitt 600466e12f pyclass: fix deprecation warning for no __module__ attribute 2020-12-27 19:42:47 +00:00
Nicholas Sim 83739e60f7 ffi module cleanup: context.h to frameobject.h 2020-12-27 14:00:50 +08:00
Nicholas Sim 3f093d9e59
ffi module cleanup (#1338)
* initial work to clean up ffi module

* ffi: mirror cpython Includes

* ffi: start to alphebetise, note skipped headers

* ffi: temporarily move _PyFrameEvalFunction back

* ffi cleanup: fix pypy compilation

* Update src/ffi/mod.rs

Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>

* add suggested changes

* ffi cleanup: remove unnecessary use stmt

* ffi cleanup: add deprecation warning

* ffi cleanup: transitively deprecate, update changelog

Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-12-27 11:53:18 +09:00
David Hewitt 51d1996218 ci: deny warnings using RUSTFLAGS 2020-12-26 08:27:08 +00:00
cecini c780aa931d Fix the pydebug with trace refs and count_allocs for python > 3.7 2020-12-23 16:20:19 +00:00
David Hewitt 26ca1f5bca Release 0.13 2020-12-22 15:42:04 +00:00
David Hewitt a689ab42c6 macros: rename crates for consistency 2020-12-20 06:39:28 +00:00
David Hewitt 2616d3de76 python: add version() to get running version 2020-12-19 19:13:59 +00:00
David Hewitt 3d9f660e21
CHANGELOG: remove unneeded entry 2020-12-18 23:48:11 +00:00
David Hewitt fa8c93cfd1 pyclass #[new]: allow using custom error type 2020-12-13 23:50:03 +00:00
Yuji Kanagawa 22359e9097
Merge pull request #1310 from PyO3/abi3-128bit-integer
Implement 128bit integer conversion for limited API
2020-12-12 22:30:15 +09:00
Yuji Kanagawa 560fb4883d
Merge pull request #1312 from birkenfeld/fix-1311
ffi: use recommended stable way to represent an opaque C struct
2020-12-12 22:29:45 +09:00
Yuji Kanagawa 2a3a730db5
Merge pull request #1303 from scalexm/lit
Do not include the double quotes in `#[pyclass(name = "literal")]`
2020-12-12 22:28:56 +09:00
David Hewitt 5133f81e6d deprecate pyclass name without quotes 2020-12-12 11:11:11 +00:00
Yuji Kanagawa 7a0542d44e
Update CHANGELOG.md
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-12-12 19:38:49 +09:00
kngwyu 8c4cba25b7 Implement 128bit integer conversion for limited API 2020-12-12 19:13:53 +09:00
Georg Brandl 7d5ff2d768 ffi: use recommended stable way to represent an opaque C struct
After `extern { type ... }` has stabilized for a while, this can
be replaced.  For now, I used a macro since it is much easier to
spot the locations to touch at that time.

fixes #1311
2020-12-12 10:59:36 +01:00
Yuji Kanagawa 9aa70f7c89
Merge pull request #1263 from PyO3/abi3-min-python
Add abi3-py* features
2020-12-08 12:52:00 +09:00
Yuji Kanagawa 6da6bc9461
Apply suggestions from @davidhewitt
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-12-06 16:06:10 +09:00
Patrick Chieppe d5767b8921 Fix typo 2020-11-30 11:46:26 +11:00
Patrick Chieppe cda46cbe40 Add CHANGELOG.md entry 2020-11-30 11:43:01 +11:00
David Hewitt afa5ed3ba2 Release notes for backported 0.12.4 2020-11-28 20:21:52 +00:00
scalexm 649b439463 Allow `#[pyclass(name = "string literal")]`
This is also more in line with the `#[name = "..."]` attribute on
methods.
2020-11-27 18:45:07 +01:00
David Hewitt 87bacf1be5 performance: use vectorcall for call0 and call_method0 2020-11-25 20:59:11 +00:00
David Hewitt fc6fa9ead6 ffi: correct vectorcall bindings 2020-11-25 20:54:12 +00:00
David Hewitt 7ca126cc5b python: deprecate some redundant methods 2020-11-22 20:04:45 +00:00
David Hewitt fc34e41163 pyany: add is_instance 2020-11-22 19:24:59 +00:00
David Hewitt 53ce423424 anaconda: fix for building in a virtualenv 2020-11-21 08:56:07 +00:00
kngwyu a2490e32ce Add a CHANGELOG entry for char support 2020-11-20 16:39:05 +09:00
roblabla d479b54b94 Fix #1285, text_signature and raw ident interaction 2020-11-19 17:21:02 +00:00
David Hewitt 1ce14d77e4 pytypeinfo: rename is_instance to is_type_of 2020-11-15 18:35:16 +00:00
David Hewitt 45599620b5 pyerr: improve debug & display impls 2020-11-15 16:22:45 +00:00
kngwyu 93282e9a70 Note abi3-py* features in the guide and Add CHANGELOG 2020-11-16 00:47:24 +09:00
David Hewitt 9617edfca9 msrv: bump to 1.45 2020-11-12 11:33:08 +00:00
David Hewitt fb02a582b8
Merge pull request #1267 from davidhewitt/build-for-musl
build: not cross-compiling when musl from gnu
2020-11-12 08:10:42 +00:00
David Hewitt cfa586c034 build: not cross-compiling when musl from gnu 2020-11-10 08:31:39 +00:00
David Hewitt cd75895cd0 ffi: add bindings for PEP 587 2020-11-10 07:44:59 +00:00
Yuji Kanagawa 3b3ba4e3ab
Merge pull request #1152 from PyO3/abi3
Complete abi3 support
2020-10-27 23:30:36 +09:00
Aviram Hassan c982639503 Added missing field to PyCodeObject. 2020-10-25 06:54:04 +02:00
Aviram Hassan 0fd500fb0f Add context.h functions (PyContext_New, PyContext*)
Formatting
2020-10-22 10:18:17 +03:00
Aviram Hassan 7baa89e8d9 Add PyEval_SetProfile, PyEval_SetTrace
add changelog
2020-10-21 10:46:46 +03:00
Alex Gaynor 90a825d0c2 Merge branch 'master' into abi3-merge-master 2020-10-19 14:32:49 -04:00
David Hewitt afd9b823d2 Drop support for Python 3.5 2020-10-18 19:02:27 +01:00
Alex Gaynor 265db337c2 Fixes for PyIterator 2020-10-18 11:31:42 -04:00
Alex Gaynor ba6f0ecdfa Merge branch 'master' into abi3-merge-master 2020-10-18 10:47:06 -04:00
Askaholic 1d7034478c
Add entries to changelog 2020-10-15 12:02:58 -08:00
David Hewitt 95cebd8fee
Merge pull request #1217 from PyO3/remove-python-3-10-removals
Remove symbols that are removed in python 3.10
2020-10-13 00:48:45 +01:00
Alex Gaynor 5060379185 Fix changelog 2020-10-12 18:11:38 -04:00
Alex Gaynor 9e34835b76 Merge branch 'master' into abi3-merge-master 2020-10-12 18:03:14 -04:00
konstin 2c3ee2c97a Update CHANGELOG.md
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-10-12 17:39:14 +01:00
konstin 5f109743a7 Remove symbols that are removed in python 3.10
Those functions and variable are listed in https://docs.python.org/3.10/whatsnew/3.10.html#id4
2020-10-12 17:38:16 +01:00
David Hewitt 482ee3a8b2 Add changelog entry and test 2020-10-12 17:37:53 +01:00
David Hewitt 1539db762b Remove unused `python3` feature 2020-10-12 16:53:49 +01:00
David Hewitt 38af32e33e Release 0.12.3 2020-10-12 16:18:25 +01:00
David Hewitt 7b3dd68bfb Fix support for MSRV
Co-authored-by: Alex Gaynor <alex.gaynor@gmail.com>
2020-10-12 15:46:40 +01:00
David Hewitt 1cecad884a Release 0.12.2 2020-10-12 12:56:46 +01:00
Alex Gaynor 877667a1c6 Improved documentation 2020-10-11 15:18:05 -04:00
Yuji Kanagawa cb90c5171d
Merge pull request #1169 from PyO3/doc-null-check
Add null-check for function's documents
2020-10-10 14:35:44 +09:00
kngwyu ff644316d7 Add a CHANGELOG entry 2020-10-08 23:31:17 +09:00
Georg Brandl 4d008218a0 Add wrapper for PyErr_CheckSignals() to Python.
This is a useful API in long-running Rust code, which lets users
cancel evaluation by pressing Ctrl-C, and run any other signal
handlers that have been set using the signal module.
2020-10-08 15:22:30 +02:00
David Hewitt 41bd448431 Add CHANGELOG entry for #1209. 2020-10-01 08:15:27 +01:00
David Hewitt c05815520c Release 0.12.1 2020-09-16 21:45:36 +01:00
Alex Gaynor 5fe1a44277
fixed markdown syntax 2020-09-16 08:47:58 -04:00
Matthew Treinish a0960f8918
Fix compilation on platforms that don't use i8 for c_char (#1182)
* Fix compilation on platforms that don't use i8 for c_char

This commit changes the cast of an c_char to be a c_char type instead of
i8. On x86 platforms i8 == c_char, but it can also be u8 on other
platforms. [1][2] This should fix compilation on those platforms by just
using the c_char type so that we're casting as the right type regardless
of which platform PyO3 is being built for.

Fixes #1181

[1] https://doc.rust-lang.org/std/os/raw/type.c_char.html
[2] https://github.com/rust-lang/rust/blob/master/library/std/src/os/raw/mod.rs#L55-L99

* Add changelog entry
2020-09-14 11:27:38 +01:00
Alex Gaynor 10f8c24931
Update CHANGELOG.md 2020-09-12 19:41:02 -04:00
Alex Gaynor 8c011620fe
Merge branch 'master' into patch-1 2020-09-12 19:39:54 -04:00
Alex Gaynor d530e462f9
Update CHANGELOG.md 2020-09-12 19:19:33 -04:00
David Hewitt 5ad89de170 Fix date in changelog 2020-09-12 14:45:20 +01:00
David Hewitt 32be8d9a3c Release 0.12 2020-09-12 14:13:45 +01:00
Rob Thatcher 118646dd4a update changelog 2020-09-11 17:31:41 +01:00
David Hewitt 151af7a0b7
Merge pull request #1115 from davidhewitt/std-py-err
Implement std::error::Error for PyErr
2020-09-10 21:17:11 +01:00
David Hewitt 73507dbf5e
Merge pull request #1163 from sebpuetz/pyfunction
Add native Function types.
2020-09-10 19:05:57 +01:00
David Hewitt b9e95dc7c9 Implement std::error::Error for PyErr 2020-09-10 19:04:24 +01:00
Sebastian Pütz 2e8010b5df Add native Function native types.
Add bindings for PyCFunction, PyFunction, PyClassMethod and
PyStaticMethod.
2020-09-08 09:51:31 +02:00
David Hewitt 16fe583b82
Merge pull request #1143 from sebpuetz/pyfunction-modules
PyModule in #[pyfunction]
2020-09-06 20:55:29 +01:00
Sebastian Pütz 64b06ea9ec Change `add_submodule()` to take `&PyModule`.
The C-exported wrapper generated through `#[pymodule]` is only
required for the top-level module.
2020-09-05 15:54:57 +02:00
David Hewitt 2b0b853912 Add CHANGELOG to the guide 2020-09-05 14:44:39 +01:00
Sebastian Pütz e65b849ab6 Doc fixes, changelog and rename. 2020-09-05 10:20:22 +02:00
Yuji Kanagawa 729f2f42e7
Merge pull request #1065 from sebpuetz/union
FromPyObject derivation for structs and enums
2020-08-31 21:28:49 +09:00
David Hewitt 82cb815afa Use IntoPy<PyObject> for PyModule::add 2020-08-30 16:24:20 +01:00
Sebastian Pütz 60fe4925f5 '#[derive(FromPyObject)]` changes suggested by @davidwhewitt. 2020-08-30 10:22:01 +02:00
Mario 608aea726c
Allow other Result types in `#[pyfunction]` (#1118)
* Added a couple basic tests

* Implemented suggested change

* Fixed type inference

* cargo fmt

* Finished tests and removed warnings

* Include in CHANGELOG.md

* Moved test into separate file

* &'static str and function rename

* Mention in the book
2020-08-29 08:25:20 +01:00
Matthew Treinish 659d24e1a9
Add CHANGELOG entry and update conversions guide 2020-08-26 06:37:02 -04:00
kngwyu 3e958bf607 Encapsule slot_setter's behavior to an iterator 2020-08-20 14:41:51 +09:00
Rene Leveille 6ddae70a2b fix changelog and added comment for finding sysconfigdata 2020-08-18 13:23:48 -04:00
Rene Leveille aef159d4ee appy suggestions from PR 2020-08-17 11:26:30 -04:00
Rene Leveille 3bc951a551 make clippy happy and add to changelog 2020-08-17 11:25:42 -04:00
David Hewitt 565e36d989
Merge pull request #1098 from davidhewitt/py-as-into-ref
Py::as_ref and Py::into_ref (remove AsPyRef)
2020-08-11 20:44:53 +01:00
Yuji Kanagawa c4d9ab227e
Merge branch 'master' into iterator-example 2020-08-10 17:11:00 +09:00
kngwyu 093dda375f Improve lifetime insertions for #[pyproto] 2020-08-10 15:18:16 +09:00
David Hewitt 7d0b3b386a Add Py::into_ref 2020-08-09 23:00:34 +01:00
David Hewitt f29e6bae7a Replace PyObject with type alias for Py<T> 2020-08-09 12:28:21 +01:00
David Hewitt e0376d24aa Experimental support for PyPy 3.6
Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-08-08 14:54:34 +01:00
David Hewitt 1f37dbc1a7 Various fixes to edge cases with GILGuard 2020-08-06 14:32:59 +01:00
David Hewitt dc5c2a9b8f Rename PYTHON_SYS_EXECUTABLE to PYO3_PYTHON 2020-08-06 13:27:20 +01:00
Manuel Vázquez Acosta f2ba3e6da7
#1064: Comparisons with __eq__ should not raise TypeError (#1072)
* Add (failing) tests for issue #1064

* Return NotImplemented when richcmp doesn't match the expected type.

* Fix tests that expect TypeError when richcmp returns NotImplemented.

- The python code 'class Other: pass; c2 {} Other()' was raising a NameError:
  c2 not found

- eq and ne never raise a TypeError, so I split the those cases.

* Return NotImplemented for number-like binary operations.

* Add dummy impl PyNumberProtocol for the test struct.

* Rework tests of NotImplemented.

* Make py_ternary_num_func return NotImplemented when type mismatches.

* Return NotImplement for type mismatches in binary inplace operators.

* Reduce boilerplate with `extract_or_return_not_implemented!`

* Extract common definition 'Other' into a function.

* Test explicitly for NotImplemented in the __ipow__ test.

* Add entry in CHANGELOG for PR #1072.

* Add the section 'Emulating numeric types' to the guide.

* Ensure we're returning NotImplemented in tests.

* Simplify the tests: only test we return NotImplemented.

Our previous test were rather indirect: were relying that Python
behaves correctly when we return NotImplemented.

Now we only test that calling a pyclass dunder method returns NotImplemented
when the argument doesn't match the type signature.  This is the expected
behavior.

* Remove reverse operators in tests of NotImplemented

The won't be used because of #844.

* Apply suggestions from code review

Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>

* Add a note about #844 below the list of reflected operations.

Co-authored-by: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-08-05 22:53:16 +09:00
Moritz Langenstein a877300f72
Added Rust initialisation of Python-allocated bytes (#1074)
* Added Rust initialisation of Python-allocated bytes

* Added unsafe PyBytes::new_with_unit constructor

* Added examples to PyBytes::new_with and PyBytes::new_with_uninit (now with MaybeUninit<u8>)

* Fixed doc test imports for PyBytes::new_with and PyBytes::new_with_uninit

* Fixed clippy error in PyBytes::new_with_uninit test

* Added PyByteArray::new_with and Removed PyBytes::new_with_uninit

* Small doc fixes + FnOnce init closure for PyBytes::new_with and PyByteArray::new_with

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>

* Fixed where clause formatting in PyBytes::new_with and PyByteArray::new_with

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-08-03 09:04:06 +01:00
Yuji Kanagawa aaeb5eab54
Merge pull request #1067 from davidhewitt/pyerr-send
Make `PyErr: Send + Sync`
2020-08-02 17:49:11 +09:00
kngwyu f5f2e84f4b Enable &Self in #[pymethods] again 2020-07-28 20:55:38 +09:00
David Hewitt 09aef5d299 Make `PyErr: Send + Sync` 2020-07-25 11:59:44 +01:00
Sebastian Puetz 43d1f43c72 Calculate offsets for weakreflist and dict in PyCell. 2020-07-21 10:38:20 +02:00
Sebastian Puetz e75f768ea8 Move the ThreadChecker field in front of dict and weakref.
Offsets for dict and weakref are calculated from the end of the
PyCell struct. When using the non-dummy ThreadChecker, the offsets
were invalid since the `ThreadCheckerImpl` is not zero-sized.
2020-07-20 19:37:38 +02:00
Sebastian Puetz 63d6d4c0e2 Add type info to conversion errors. 2020-07-19 12:08:14 +02:00
David Hewitt 602080d397 Change PyIterator::from_object` to return underlying TypeError 2020-07-18 09:39:49 +01:00
David Hewitt 4ed9748b45 Rename exceptions to PyException etc; reintroduce deprecated ones 2020-07-18 06:02:57 +01:00
David Hewitt 3341d10e7f Functions which cast reference to pointer are not unsafe. 2020-07-17 19:52:32 +01:00
David Hewitt 4020e4d0c8 Add `Python::with_gil` 2020-07-13 22:37:40 +01:00
David Hewitt b1a37afa8c Fix definition of _PyLong_AsByteArray 2020-07-09 16:38:01 +01:00
David Hewitt 5d07bbb50f Correct CHANGELOG entries 2020-07-09 09:32:58 +01:00
David Hewitt e5959f268e Add CHANGELOG entry 2020-07-09 08:43:56 +01:00
Yuji Kanagawa c00080e27f
Merge pull request #1020 from PyO3/to-str
Remove PyString::as_bytes since it cannot return raw bytes
2020-07-08 15:05:58 +09:00
kngwyu 581e6e0924 Remove register_gil 2020-07-08 13:36:00 +09:00
vthriller 0f2eeea4ed
CHANGELOG.md: trivial URL typo fix 2020-07-06 21:55:00 +03:00
kngwyu 7849b74dbf Remove PyString::as_bytes since it cannot return raw bytes 2020-07-06 21:38:31 +09:00
David Hewitt a5c1c9ade9 Update FFI definitions for pylifecycle.h 2020-07-04 15:03:42 +01:00
kngwyu 6cbe9ff30d Bump version to 0.11.1 2020-06-30 14:53:55 +09:00
Yuji Kanagawa 512335186a
Merge branch 'master' into pyclass-unsendable 2020-06-30 14:17:40 +09:00
kngwyu d76fe7835a Introduce #[pyclass(unsendable)] 2020-06-30 12:30:17 +09:00
David Hewitt a250de824d Update CHANGELOG 2020-06-29 22:26:21 +01:00
David Hewitt f89e9e0eb1 Write migration guide for 0.11 2020-06-27 23:59:44 +09:00
kngwyu fd94a0d55c Bump version to 0.11.0 2020-06-27 23:59:44 +09:00
David Hewitt e140b729fc Allow #[getter] and #[setter] functions to take PyRef 2020-06-27 14:55:22 +01:00
Yuji Kanagawa e35622b941
Merge pull request #997 from davidhewitt/pyproto-next-return
Add __next__ return
2020-06-24 23:16:35 +09:00
scalexm f5e1dff7eb Update docs now that recursive `#[classattr]` are allowed again 2020-06-23 22:41:23 +02:00
David Hewitt 9f9137c6e4 Add ability to return from `__next__` / `__anext__` 2020-06-23 15:26:28 +01:00
David Hewitt a9c7e12be0 Allow skipping the return type completely for `#[pyproto]` methods returning `()`. 2020-06-23 11:51:02 +01:00
David Hewitt c7a4b4770f Refactor `#[pyproto]` Result types 2020-06-23 11:08:36 +01:00
kngwyu f053bc3881 Fix dealloc implementation to collectly use subtype's tp_free 2020-06-22 10:58:00 +09:00
kngwyu b70ee9a5ad Use subclass correctly in tp_new 2020-06-22 01:38:13 +09:00
Yuji Kanagawa 7075827a03
Merge pull request #969 from PyO3/poc-stable-rust
Stable Rust
2020-06-21 16:54:59 +09:00
kngwyu a63e426f6f Some doc and test cleanups mainly around specialization 2020-06-20 12:59:56 +09:00
David Hewitt a1dbfa8c8c Add pyo3::once_cell::GILOnceCell 2020-06-18 18:53:32 +01:00
konstin 3180e5cc06 POC stable rust (2 tests failing) 2020-06-18 17:21:09 +09:00
kngwyu 8a0c9bfcf5 Add a CHANGELOG entry for 961 2020-06-18 16:39:22 +09:00
Yuji Kanagawa 6ea834526b
Merge pull request #976 from davidhewitt/prefer-py
Add PyClass borrow methods to Py
2020-06-18 15:48:36 +09:00
David Hewitt 925986c706 Add PyCell::borrow shortcuts to Py 2020-06-17 08:58:32 +01:00
David Hewitt e377afa5de Add CHANGELOG entries for num crate version bumps 2020-06-15 20:14:56 +01:00
David Hewitt a85d157111 Cleanups to ensure GIL-safety of Py<T> and PyObject methods 2020-06-14 16:37:34 +01:00
Yuji Kanagawa bbdca6b0bd
Merge pull request #967 from davidhewitt/bytearray-as-bytes
Add accessor methods to `PyByteArray`
2020-06-13 16:53:22 +09:00
David Hewitt 8a85feca97 Change return type of `PyTuple::slice` to `&[&PyAny]` 2020-06-12 05:21:27 +01:00
David Hewitt 21d365f7d4 Add accessor methods to `PyByteArray` 2020-06-12 05:01:09 +01:00
David 33617bfffc Require Send for #[pyclass] 2020-06-08 02:06:15 +01:00
Yuji Kanagawa 5939362e72
Fix docs and comments based on the review
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-06-05 17:48:43 +09:00
kngwyu 688021315e Typed PyBuffer 2020-06-04 22:03:53 +09:00
Mara Bos febccbf6e7 Call Py_Finalize at exit using libc::atexit.
This makes sure buffers are flushed, threads are joined, etc. when
exiting the process.
2020-05-24 14:56:54 +02:00
David Hewitt 29c93c87c7 Remove GetPropertyValue 2020-05-21 18:06:24 +01:00
Omer Katz 6f9048cd8f
Add FFI definition for PyObject_AsFileDescriptor (#938)
Add FFI definition for PyObject_AsFileDescriptor

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-05-19 22:14:53 +01:00
David Hewitt 5c5527dfec Fix passing explicit None to pyfunction with default 2020-05-17 19:19:33 +01:00
Yuji Kanagawa 8e6398029d
Merge pull request #930 from davidhewitt/remove-managed-py-ref
Remove ManagedPyRef
2020-05-16 13:31:46 +09:00
David Hewitt 91d0dbceab Remove ManagedPyRef 2020-05-15 21:38:40 +01:00
David Hewitt aa81e382be
Fix changelog typo 2020-05-15 09:01:23 +01:00
kngwyu 837261c860 Bump version to 0.10.1 2020-05-14 20:57:51 +09:00
David Hewitt 3b1f720eb0 Fix deadlock in update_counts 2020-05-13 18:36:40 +01:00
Yuji Kanagawa 7e4d1c41e3
Bump version to 0.10.0 (#919)
* Bump version to 0.10.0

* Apply suggestions from code review

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>

* Improve CHANGELOG completeness and messaging

* ObjectProtocol was in prelude

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-05-13 13:24:36 +09:00
kngwyu 69dba08b01 Use PyMethodsImpl instead of *ProtocolImpl::methods 2020-05-11 20:08:21 +09:00
David Hewitt 86af474a95 Add Clone for PyObject / Py<T> 2020-05-10 12:01:18 +01:00
Yuji Kanagawa 8e84721438
Merge pull request #893 from davidhewitt/safe_acquire_gil
Close soundness hole with acquire_gil
2020-05-09 19:03:15 +09:00
David Hewitt 8ffe8c58b3 Close soundness hole with acquire_gil 2020-05-09 10:41:41 +01:00
scalexm 76c7f9eaa8 Add a changelog item for `#[classattr]` 2020-05-08 22:37:33 +02:00
David Hewitt 69fb04f04b Clean up CHANGELOG 2020-05-08 15:41:53 +01:00
David Hewitt a5ebef4b2e Remove ObjectProtocol; Add methods to PyAny and use Deref 2020-05-08 10:05:19 +01:00
David Hewitt b083e0babf Make allow_threads safe with panics 2020-05-07 15:29:47 +01:00
David Hewitt 9380bfde6f Add catch_unwind! macro to prevent panics crossing ffi boundaries 2020-05-05 08:17:06 +01:00
Mara Bos 39b41b3dc7 Replace num-traits dependency by std's TryFrom. 2020-05-04 15:50:07 +02:00
Yuji Kanagawa 0f07cf8db9
Merge pull request #886 from fusion-engineering-forks/dir
Add dir() to ObjectProtocol.
2020-05-04 18:07:27 +09:00
Mara Bos 36ebd0566c Update CHANGELOG.md. 2020-05-03 14:32:43 +02:00
David Hewitt b7ecec7812 Remove unsound return of borrowed objects 2020-05-02 23:35:26 +01:00
kngwyu b6befcfb93 CHANGELOG and better docs for PyMethodsImpl 2020-05-02 18:46:48 +09:00
David Hewitt 3008528fa6 Allow use of `#[pyo3(get, set)]` with `Py<T>` 2020-04-22 22:21:27 +01:00
Yuji Kanagawa ae81865232 Apply suggestions from David
Co-Authored-By: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-04-13 11:05:48 +09:00
kngwyu 2cd466dc46 Bound 'py lifetime by GILPool when it's possible 2020-04-12 23:55:23 +09:00
David Hewitt 97fd658593
Add IntoPy<PyObject> for HashSet and BTreeSet (#865) 2020-04-12 14:44:01 +09:00
Yuji Kanagawa 7b1e8a6daf
Merge pull request #851 from davidhewitt/pointer-optimization
Improve performance on pointer drop
2020-04-10 12:30:35 +09:00
Yuji Kanagawa 5add8d1dee
Merge branch 'master' into merge-0.9.2 2020-04-09 17:17:52 +09:00
kngwyu a73ff502ba More changelog 2020-04-09 17:13:05 +09:00
David Hewitt fe57f64435 Improve performance on pointer drop
Co-Authored-By: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-04-09 08:51:43 +01:00
Yuji Kanagawa 53b63cddc2
Merge pull request #855 from althonos/patch-gc
Fix potential panics caused by Garbage Collector
2020-04-09 16:39:58 +09:00
kngwyu c83d88ba8d Bump version to 0.9.2 2020-04-09 13:00:13 +09:00
Martin Larralde 049202c011 Add changelog entry [ci skip] 2020-04-08 16:35:22 +02:00
David Hewitt b5b8264eb4 Tidy up changelog newlines 2020-04-08 08:02:54 +01:00
Árni Dagur 97aca504a3 Implement FromPyObject for HashSet and BTreeSet 2020-03-29 20:58:36 -04:00
kngwyu 4759358acb Bump version to 0.9.1 2020-03-23 18:55:24 +09:00
kngwyu 1e39071c04 Retrieve FromPyObject implementation for &PySequence 2020-03-22 20:00:21 +09:00
kngwyu 89e5a654ad Bump version to 0.9.0 2020-03-19 13:48:00 +09:00
kngwyu 02ee7a5afc Expose PyAny to lib.rs and prelude 2020-03-18 13:38:18 +09:00