Commit graph

1193 commits

Author SHA1 Message Date
kngwyu ac2c51c774 Fix typo and revert unintended changes 2020-06-13 15:25:04 +09:00
kngwyu 05effe26f1 Avoid function definition in setters for readability 2020-06-13 15:25:04 +09:00
kngwyu d678093509 Remove specialization from async/sequence methods 2020-06-13 15:25:04 +09:00
kngwyu 0d082961aa Remove specialization from gc/mapping/number protocols 2020-06-13 15:25:03 +09:00
kngwyu 7967874177 Remove specialization from basic/buffer/descr/iter protocols 2020-06-13 15:24:56 +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
Yuji Kanagawa 7a7271319c
Merge pull request #966 from davidhewitt/pyclass-send
Require Send for #[pyclass] (no compilefail test)
2020-06-09 19:25:54 +09:00
David Hewitt bd7869002f
Tidy up docs for from_borrowed_ptr methods
The release pool doesn't exist for borrowed objects any more, so just tidied these docs up.
2020-06-09 08:45:58 +01:00
David 33617bfffc Require Send for #[pyclass] 2020-06-08 02:06:15 +01:00
Alexander Niederbühl 75d44ca296 Remove getting started chapter from user guide
Since it's exactly the same content as in the README.
2020-06-07 00:26:17 +02:00
Yuji Kanagawa d674b5ff34
Merge pull request #952 from kngwyu/typed-pybuffer
Typed PyBuffer
2020-06-05 23:08:07 +09:00
Alexander Niederbühl bcf48c0bd2 Fix clippy lints 2020-06-05 13:53:01 +02:00
kngwyu 688021315e Typed PyBuffer 2020-06-04 22:03:53 +09:00
kngwyu 69efb0980f Rename PyMethodsImpl -> PyMethods 2020-06-03 13:01:37 +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
Yuji Kanagawa 89fe62eb80
Merge pull request #942 from davidhewitt/iterator-comment
Improve comment in iterator.rs
2020-05-21 16:21:01 +09:00
David Hewitt 01a74b2546 Improve comment in iterator.rs 2020-05-20 20:08:23 +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
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
kngwyu 837261c860 Bump version to 0.10.1 2020-05-14 20:57:51 +09:00
kngwyu 2954342f6c A tiny optimization in ReferencePool::update_counts 2020-05-14 20:03:14 +09:00
David Hewitt 509db11777 Use parking_lot::Mutex instead of spinlock 2020-05-14 09:14:30 +01: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 9f8b7cd9bf Revert #889 2020-05-12 00:10:49 +09:00
kngwyu 69dba08b01 Use PyMethodsImpl instead of *ProtocolImpl::methods 2020-05-11 20:08:21 +09:00
Yuji Kanagawa da22eecb5f
Merge pull request #897 from fusion-engineering-forks/macros-feature
Move macros into separate feature.
2020-05-11 11:01:46 +09:00
David Hewitt 86af474a95 Add Clone for PyObject / Py<T> 2020-05-10 12:01:18 +01:00
David Hewitt 8ffe8c58b3 Close soundness hole with acquire_gil 2020-05-09 10:41:41 +01:00
Mara Bos dab8c2e4e7 Move macros into separate feature.
It's enabled by default to avoid breakage, but this allows compiling
pyo3 with a lot less dependencies in case the macros are not needed.
2020-05-09 11:27:30 +02:00
Yuji Kanagawa d5eb8f0544
Merge pull request #911 from davidhewitt/remove-objectprotocol
Remove ObjectProtocol
2020-05-08 18:56:52 +09:00
David Hewitt a5ebef4b2e Remove ObjectProtocol; Add methods to PyAny and use Deref 2020-05-08 10:05:19 +01:00
Yuji Kanagawa 027c90c223
Merge pull request #913 from davidhewitt/gil_state_list
Fix issue with PyObject drop and allow_threads
2020-05-08 12:59:36 +09:00
Yuji Kanagawa 8aeae6c8ac
Merge pull request #905 from scalexm/master
Add `#[classattr]` methods to define Python class attributes
2020-05-08 11:24:42 +09:00
scalexm 7b5a076680 Add #[classattr] methods to define Python class attributes 2020-05-07 21:23:47 +02:00
David Hewitt bb571930f1 Temporarily set GIL_COUNT to 0 during allow_threads 2020-05-07 16:34:38 +01:00
David Hewitt b083e0babf Make allow_threads safe with panics 2020-05-07 15:29:47 +01:00
kngwyu 11c1c5e6a1 Use -Cpanic=abort for correct coverage 2020-05-06 21:20:00 +09:00
Yuji Kanagawa 626268d28a
Merge pull request #899 from fusion-engineering-forks/mutex
Simplify ReleasePool, remove parking_lot dependency.
2020-05-05 18:09:20 +09:00
David Hewitt 9380bfde6f Add catch_unwind! macro to prevent panics crossing ffi boundaries 2020-05-05 08:17:06 +01:00
Mara Bos 0407288758 Simplify ReleasePool, remove parking_lot dependency.
Replaces the parking_lot Mutex by a simple AtomicBool spinlock,
and simplifies the ReleasePool to contain one Vec instead of pointers to
two Vecs.
2020-05-05 08:08:07 +02:00
Yuji Kanagawa c4f36535d8
Merge pull request #895 from fusion-engineering-forks/tryfrom
Replace num-traits dependency by std's TryFrom.
2020-05-05 12:26:35 +09:00
David Hewitt 9a2d908342 Simplify callback code using callback_body! macro 2020-05-05 00:27:50 +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 d32c3c0b37 Add test for dir(). 2020-05-04 09:57:46 +02:00
Yuji Kanagawa 879b0b58ac
Merge pull request #890 from davidhewitt/no-borrowed-objects
Remove unsound return of borrowed objects
2020-05-04 12:18:52 +09:00
David Hewitt 6f74fe6b38 Allow borrowed object for PyTuple::get_item.
As per feedback on #890
2020-05-03 18:48:01 +01:00
Mara Bos 49d31a0134 Add dir() to ObjectProtocol. 2020-05-03 14:32:43 +02:00
Yuji Kanagawa e9bec070e1
Merge pull request #887 from kngwyu/new-nativetypes
New Native Types and Lighter GILPool
2020-05-03 12:10:43 +09:00
David Hewitt b7ecec7812 Remove unsound return of borrowed objects 2020-05-02 23:35:26 +01:00
kngwyu 75c807f31d Less borrow in GILPool::drop 2020-05-02 23:39:52 +09:00
David Hewitt dfbe22bb56 Thread-safe release pools 2020-05-02 13:16:22 +01:00
kngwyu b6befcfb93 CHANGELOG and better docs for PyMethodsImpl 2020-05-02 18:46:48 +09:00
kngwyu 816c50a649 Unify PyMethodsInventoryDispatch and PyMethodsProtocol 2020-05-02 17:48:25 +09:00
kngwyu 39bfb5f0d5 Clean up gil tests 2020-05-02 15:33:10 +09:00
kngwyu 8c6cbb605a Better docs for new unchecked_downcast and borrowed objects 2020-05-02 14:58:12 +09:00
kngwyu 823b8e7f8a New Native Types and lighter GILPool 2020-05-02 14:54:13 +09:00
David Hewitt 3008528fa6 Allow use of #[pyo3(get, set)] with Py<T> 2020-04-22 22:21:27 +01:00
Mara Bos dcab478d66
Fix lifetime safety bug of AsPyRef::as_ref(). (#876)
* Fix lifetime safety bug of AsPyRef::as_ref().

Fixes #875.

* Add test for AsPyRef's lifetimes.
2020-04-20 18:44:31 +01:00
Martin Larralde 378a6a484c Move TryFromPyCell trait to derive_utils module 2020-04-19 12:57:31 +02:00
Martin Larralde b3c937c73a Reformat code with rustfmt 2020-04-18 03:59:42 +02:00
Martin Larralde 187d889565 Make PyIterProtocol methods accept both PyRef and PyRefMut 2020-04-18 03:57:17 +02:00
Martin Larralde 42e84ea6ff Add compatibility trait TryFromPyCell to pyo3::pycell 2020-04-18 03:38:27 +02: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
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
David Hewitt d8effb24e8 Refactor CallbackConverter code
Now shorter and allows use of the ? operator inside callback code
2020-04-08 21:55:11 +01:00
Martin Larralde b73bb06ff4 Fix panics caused by GC borrowing when class is already mutably borrowed 2020-04-08 16:25:32 +02:00
Yuji Kanagawa a9357ef8a1
Merge pull request #852 from davidhewitt/20200407-fix-clippy-warnings
Fix clippy complaint of empty return type
2020-04-08 21:00:12 +09:00
David Hewitt 8f41d56b9e Fix clippy complaint of empty return type 2020-04-08 08:04:29 +01:00
ijl 97f4987958 _PyDict_NewPresized() 2020-04-06 14:55:12 +00:00
kngwyu 810d3b62ab Add tests for FromPyObject implementation for HashSet/BTreeSet 2020-03-30 14:37:37 +09:00
Yuji Kanagawa 85de698a0d
Merge pull request #839 from kngwyu/radd-fix
Make __r*__ methods work with operators
2020-03-30 12:40:17 +09:00
Árni Dagur 97aca504a3 Implement FromPyObject for HashSet and BTreeSet 2020-03-29 20:58:36 -04:00
kngwyu ac418ce020 Inhibit __ipow__ to take Modulo 2020-03-30 03:01:44 +09:00
kngwyu 25eda36353 Speficy METH_COEXIST for some number methods except 2020-03-30 02:02:57 +09:00
kngwyu 970e393bb9 Make __r*__ methods work by slot fallback 2020-03-28 18:17:40 +09:00
kngwyu 5280a281c9 Remove GILPool::new_no_pointer 2020-03-26 19:45:32 +09: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 e9b15b83ff Change PyBorrowError and PyBorrowMutError to inherit RuntimeError 2020-03-19 13:47:37 +09:00
Yuji Kanagawa 25b594cd47
Merge pull request #820 from ijl/more-ffi
More bytes, dict FFI
2020-03-19 13:44:40 +09:00
kngwyu 9f4ea2b234 Fix the case where T::DESCRIPTION is not null-terminated 2020-03-19 12:17:06 +09:00
ijl e58249cf55 _PyDict_Next(), _PyDict_Contains(), _PyObject_GetDictPtr() 2020-03-18 22:46:51 +00:00
ijl 5e14b39c62 _PyBytes_Resize() 2020-03-18 22:41:20 +00:00
kngwyu 02ee7a5afc Expose PyAny to lib.rs and prelude 2020-03-18 13:38:18 +09:00
Georg Brandl e026013321
Apply suggestions from code review
Co-Authored-By: Alexander Niederbühl <a.niederbuehl@gmail.com>
2020-03-17 20:06:09 +01:00
Georg Brandl b7d5f9097b
Fix tests
Co-Authored-By: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-03-17 16:49:48 +01:00
Georg Brandl 77b1ae3137 lib: overhaul docstrings 2020-03-17 15:16:30 +01:00
Georg Brandl a7a2ccb5ff
Apply suggestions from code review 2020-03-17 10:54:51 +01:00
Georg Brandl 4da5dbcd01
Apply suggestions from code review
Co-Authored-By: Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>
2020-03-17 10:54:05 +01:00
Georg Brandl e649e58674 docstrings: fixes, also point to the new guide chapter 2020-03-17 10:04:29 +01:00
kngwyu 40077245ea Fix PyModule::dict 2020-03-16 15:45:54 +09:00
kngwyu 107c0cf1ba Unify AsPyRef for Py<T> to make rust-numpy work 2020-03-09 18:31:43 +09:00
kngwyu ded83027fa Write migration guide for 0.9 2020-03-09 14:11:14 +09:00
kngwyu 25069baef4 Fix the interpretation of '*' 2020-03-04 23:48:46 +09:00
kngwyu e63e0cbf5a Make it enable to take &PyClass as arguments as pyfunctions/methods 2020-03-04 13:37:26 +09:00
kngwyu 6307c25b81 Remove static mut from make_module 2020-03-03 18:46:20 +09:00
Yuji Kanagawa 3115667181
Merge pull request #783 from kngwyu/fix-pylayout
Fix PyLayout and restrict PyRef::as_ref for non-native types
2020-03-03 17:09:28 +09:00
Yuji Kanagawa 402c382f0e
Make rustfmt happy 2020-03-03 13:41:15 +09:00
Yuji Kanagawa dc8e0c4c18
Merge branch 'master' into array-impls 2020-03-03 13:07:03 +09:00
Caio 6b78f1b43c Implement *Py* traits for arrays (up to 32) 2020-03-02 18:25:07 -03:00
kngwyu 7deb3b1fb2 Make FFIs Python3.8 compatible 2020-03-02 20:12:12 +09:00
kngwyu a12667be25 Add a document about inherting native types 2020-03-02 20:07:23 +09:00
kngwyu 39c299959e Fix PyLayout and restrict PyRef::as_ref for non-native types 2020-03-02 18:42:04 +09:00
Yuji Kanagawa fee755adbe
Merge pull request #770 from kngwyu/pycell
Rename PyClassShell with `PyCell` and do mutability checking
2020-03-02 14:56:51 +09:00
kngwyu ee0c178fed Remove ObjectProtocol::get_base and fix class.md 2020-03-02 13:08:37 +09:00
kngwyu ca6227c739 Address review comments 2020-03-01 12:58:28 +09:00
Yuji Kanagawa 399e4bf9b1
Apply suggestions from code review
Co-Authored-By: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-03-01 12:43:04 +09:00
Jack O'Connor 6568d78e24 avoid calling ffi::PyBuffer_Release twice in PyBuffer::release
Fixes https://github.com/PyO3/pyo3/issues/776.
2020-02-28 16:59:44 -05:00
kngwyu 461b32a432 More docs 2020-02-28 16:49:25 +09:00
kngwyu dcac5ad200 Simplify PyLayout 2020-02-26 17:19:33 +09:00
kngwyu 6a64806d90 Address clippy warnings 2020-02-26 17:10:46 +09:00
kngwyu bab146a580 Refactor set_item 2020-02-25 20:16:49 +09:00
kngwyu 6c652dff8c Merge branch 'master' into pycell 2020-02-25 20:15:17 +09:00
kngwyu 9bc41923be More documents for AsPyRef and PyRef 2020-02-25 19:56:58 +09:00
kngwyu 68a3b15943 Use PyBorrowFlagLayout to ensure the baseclass has a borrow flag 2020-02-23 01:02:14 +09:00
kngwyu 0e3f7cbc30 More documents for PyCell 2020-02-23 00:56:34 +09:00
kngwyu d3d61c6ad3 Remove all usages of unguarded 2020-02-22 20:26:11 +09:00
kngwyu c2a40fbf70 Modify CallbackConverter so that it can deal with try_borrow well 2020-02-22 20:01:08 +09:00
kngwyu 043b13046a Write docs for PyCell, PyRef, PyRefMut 2020-02-22 16:21:09 +09:00
kngwyu 3d0ee2a28d Use AsRef/AsMut instead of as_super/as_super_mut 2020-02-21 20:37:35 +09:00
Andrew Whitehead aae57e704f
make clippy happy
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
2020-02-20 14:30:48 -08:00
Andrew Whitehead ca6cb99a4b
Implement buffer release for PyBufferProtocol; change callback signatures to pass PyClassShell
Signed-off-by: Andrew Whitehead <cywolf@gmail.com>
2020-02-20 12:48:22 -08:00
kngwyu 1f5cb83ef8 Add tests for mutability checking 2020-02-18 15:28:04 +09:00
kngwyu 4b746af11b Rename unchecked_refmut -> unchecked_mut 2020-02-18 12:55:06 +09:00
Yuji Kanagawa 98d810e662 Apply suggestions from davidhewitt's review
Co-Authored-By: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-02-18 12:51:02 +09:00
kngwyu daca04e5f3 Update class.md and Change super API 2020-02-18 00:19:55 +09:00
kngwyu 2fd2185052 Merge branch 'master' into pycell 2020-02-17 00:07:15 +09:00
kngwyu 8f8b42591a Fix PySelf and AsPyRef 2020-02-16 23:54:55 +09:00
kngwyu da4ed398bb Fix PyCell to share BorrowFlag with parents 2020-02-15 18:13:39 +09:00
kngwyu 4a5f219cc4 New AsPyRef 2020-02-11 18:50:50 +09:00
kngwyu c43fb9fcdf Prototype Implementation of RefCell-like PyCell 2020-02-10 16:13:15 +09:00
Yuji Kanagawa 0eb4eb4e58 Merge branch 'master' into property-fixes 2020-02-10 15:13:19 +09:00
David Hewitt de9698e7a5 Changes from PR#760 2020-02-09 11:06:44 +00:00
kngwyu 5d4e7374e9 Introduce PyDownCastImpl and Change PyTryFrom and FromPyPointer 2020-02-09 16:35:52 +09:00
David Hewitt 20c6c2d463 Fix clippy warnings 2020-02-08 19:25:52 +00:00
kngwyu a2408cacbb Rename PyClassShell with PyCell 2020-02-08 15:05:13 +09:00
kngwyu ba20b0ef21 Remove unnecessary parentheses from FFI 2020-02-08 14:27:59 +09:00
kngwyu 50de21abb7 Use AtomicBool for lazy types 2020-02-08 14:03:57 +09:00
David Hewitt f8c8b8effd Fix for PyObject with #[pyo3(get)] 2020-02-07 19:31:13 +00:00