Commit graph

1193 commits

Author SHA1 Message Date
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
kngwyu 58a0841ff7 Rewrite LazyTypeObjects without once_cell 2020-02-07 00:10:27 +09:00
kngwyu f8de335b00 Make PyTypeInfo::type_object return &'static instead of NonNull 2020-02-06 19:11:59 +09:00
Yuji Kanagawa 14980d742d
Merge pull request #755 from davidhewitt/property-doc
Fix docstrings generated by `[pyo3(get, set)]`
2020-02-03 18:14:54 +09:00
Yuji Kanagawa 8fea23a0b8
Merge pull request #751 from davidhewitt/remove-static-mut
Remove static mut from PyTypeInfo implementation
2020-02-03 17:39:25 +09:00
David Hewitt dfb7d7c58d Fix docstrings generated by [pyo3(get, set)] 2020-02-03 08:01:30 +00:00
David Hewitt 04f30c5971 Revisions from PR#751 2020-02-03 07:34:42 +00:00
kngwyu b88fe39ed6 Implement From<&PyNativeType> for Py 2020-02-02 15:28:44 +09:00
David Hewitt 7531b9fb07 Remove even more uses of static mut 2020-01-30 13:24:55 +00:00
David Hewitt 5cbdef6471 Remove static mut from PyTypeInfo implementation 2020-01-30 00:14:27 +00:00
kngwyu d1f28e9089 Separate FromPyObjectImpl from pyobject_native_type_convert! 2020-01-29 18:12:16 +09:00
David Hewitt d536974208 Remove unneeded brackets 2020-01-27 08:33:40 +00:00
Yuji Kanagawa 541816b7d2
Merge pull request #730 from davidhewitt/extract-clone
FromPyObject for #[pyclass] with T: Clone
2020-01-25 12:42:05 +09:00
David Hewitt fdf407e045 FromPyObject for #[pyclass] with T: Clone 2020-01-24 08:57:28 +00:00
David Hewitt 43df3299ab Remove PyNoArgsFunction 2020-01-22 16:27:36 +00:00
Yuji Kanagawa 4fe1841c5f
Merge branch 'master' into v0.9.0 2020-01-17 14:27:02 +09:00
Yuji Kanagawa db6c822fa2
Merge pull request #734 from ijl/rm-spin
Use parking_lot::Mutex instead of spin::Mutex
2020-01-17 14:24:54 +09:00
ijl 23d380ef07 _Py_HashBytes() 2020-01-16 14:04:25 +00:00
ijl a55a48b189 _PyDict_SetItem_KnownHash() 2020-01-16 14:04:17 +00:00
ijl 4b2f4b3a15 Use parking_lot::Mutex instead of spin::Mutex
spin is no longer maintained.

Fixes #718.
2020-01-16 13:53:54 +00:00
kngwyu 56f68a55cd Bump version to 0.9.0-alpha.1 2020-01-16 20:05:44 +09:00
David Hewitt f45eaa00b5 Remove dead code 2020-01-13 23:26:45 +00:00
Alexander Niederbühl a126f5d0ab Fix typo in panic message 2020-01-12 14:33:20 +01:00
kngwyu 302b3bb088 Merge branch 'master' into pyclass-new-layout 2020-01-11 15:03:25 +09:00
Alexander Niederbühl 1f675dcaa7 Clear error indicator when the exception is handled on the Rust side
Leaving Python's global exception state is misleading, e.g. subsequent
calls of `py.eval` will fail.
2020-01-11 00:44:11 +01:00
kngwyu ea9824a982 Fix document for PyList::iter 2020-01-08 23:44:16 +09:00
kngwyu 7b502821ce Use &PyAny instead of PyObject in PyDictIterator 2020-01-08 23:43:40 +09:00
kngwyu 026caeda68 Implement iter for PySet and PyFrozenSet 2020-01-08 23:15:53 +09:00
kngwyu c57177a169 Refine tests and documents around pyclass.rs 2020-01-08 22:44:50 +09:00
David Hewitt f7a4fbaa38 Use _PySet_NextEntry 2020-01-08 09:43:03 +00:00
kngwyu 451de182cb Merge branch 'master' into pyclass-new-layout 2020-01-08 17:16:33 +09:00
David Hewitt ec79285fe4 Implement IntoIterator for PySet and PyFrozenSet 2020-01-08 00:07:11 +00:00
David Hewitt 72e9abd4c7 Remove specialization from IntoPy implementation 2020-01-07 09:32:34 +00:00
David Hewitt bf507da154 Remove specialization from FromPyObject blanket impls 2020-01-07 09:01:35 +00:00
kngwyu ab0a731e5e Fix use order in prelude 2020-01-07 17:38:20 +09:00
kngwyu 67a98d6c4a Remove unnecessary Box 2020-01-07 17:37:29 +09:00
kngwyu f26e07cfd6 Replace IntoInitializer<T> with Into<PyClassInitializer<T>> 2020-01-07 13:08:41 +09:00
kngwyu b602b4bf6c Enhance documentation and tests around #[new] 2020-01-07 12:49:36 +09:00
David Hewitt 60edeb889e Simplify IntoInitializer 2020-01-06 13:19:58 +00:00
kngwyu d22b03edde Bump version to 0.8.5 2020-01-05 16:39:18 +09:00
kngwyu 18e565fab5 New PyClassInitializer 2020-01-05 16:01:05 +09:00
kngwyu 8f8785d7c2 Merge branch 'master' into pyclass-new-layout 2019-12-29 23:51:51 +09:00
kngwyu 766a520a10 Documentation enhancement 2019-12-29 00:02:48 +09:00
Alexander Niederbühl 3fae391a3c Ignore missing # Safety section in ffi module 2019-12-28 03:54:41 +01:00
Guillaume Desmottes 6f202efa59 dict: implement FromPyObject for BTreeMap 2019-12-24 18:53:19 +05:30
Guillaume Desmottes ea7a384999 dict: implement FromPyObject for HashMap
Based on code from Ben Avrahami on https://github.com/PyO3/pyo3/issues/516
2019-12-24 18:53:00 +05:30
kngwyu 58590393c5 Fix accidently changed file permission 2019-12-24 12:27:22 +09:00
kngwyu ea51756933 Resolve some clippy complains 2019-12-23 18:05:06 +09:00
kngwyu d5cff058ef Fix documents and a clippy warning 2019-12-23 02:09:36 +09:00
kngwyu acb1120c55 Fix examples with the new #[new] API 2019-12-22 23:59:28 +09:00
kngwyu e2dc843de5 Fix a corner case for PyClassInitializer 2019-12-22 23:54:41 +09:00
kngwyu efa16a6dc7 Fix documents accompanied by PyClassShell 2019-12-22 19:41:25 +09:00
kngwyu 6b84401126 Make it enable to safely inherit native types 2019-12-21 23:28:55 +09:00
kngwyu 8175d6f36a Merge branch 'master' into pyclass-new-layout 2019-12-19 16:12:45 +09:00
David Hewitt 0b45135ff6
Fix documentation typo 2019-12-17 09:42:00 +00:00
kngwyu b86de9376d Introduce PyClassInitializer 2019-12-15 21:04:36 +09:00
kngwyu a6639076b9 Introduce PyInternalCaster 2019-12-14 23:16:39 +09:00
kngwyu d8a4ecb476 Bump version to 0.8.4 2019-12-14 15:20:55 +09:00
kngwyu bdb66afe0a Make PyClassShell have dict&weakref 2019-12-08 17:18:25 +09:00
kngwyu 4b5fa7e977 Introduce PyClass trait and PyClassShell 2019-12-07 17:56:49 +09:00
Simonas Kazlauskas 2ba887a8cf Fix docs on how to obtain object from PyErr 2019-12-05 00:56:10 +02:00
kngwyu 935adaa5d5 Bump version to 0.8.3 2019-11-23 17:09:10 +09:00
kngwyu 6c6d54db3c Fix compile error in the latest nightly 2019-11-23 16:29:49 +09:00
kngwyu 8550e0f575 Remove #[init] attribute 2019-10-31 19:39:53 +09:00
kngwyu b5157b0431 Add doctests for allow_threads 2019-10-28 13:21:30 +09:00
kngwyu 6dff93b7e9 Make &Py~ types unsendable 2019-10-27 23:13:07 +09:00
kngwyu 7977fe68e2 Use Unsendable alias instead of Phantomdata<Rc<()>> 2019-10-27 23:12:59 +09:00
kngwyu 14d2196ba0 Bump version to 0.8.2 2019-10-26 22:47:19 +09:00
Yuji Kanagawa da1ab1b2b8
Merge pull request #644 from sebpuetz/fix-mapping-protocol
Remove contains and iter from PyMappingProtocol.
2019-10-26 22:36:08 +09:00
Alexander Niederbühl 04dece4804 Move PyBytes from string.rs into own file 2019-10-26 00:56:14 +02:00
Sebastian Puetz 3b707c8511 Remove contains and iter from PyMappingProtocol.
The methods are not expected by CPython and are only explicitly
callable. To get iteration support, PyIterProtocol should be
implemented and to get support for `x in mapping`,
PySequenceProtocol's __contains__ should be implemented.

https://github.com/PyO3/pyo3/issues/611
2019-10-25 17:20:44 +02:00
Alexander Niederbühl defa43015a Fix handling of invalid utf-8 sequences in PyString::to_string_lossy 2019-10-24 22:45:32 +02:00
ijl caf4713b3a FFI for PEP 590 Vectorcall
https://www.python.org/dev/peps/pep-0590/

This was tested on 3.7 using _PyCFunctionFast and 3.8
using PyObject_Vectorcall. Extending pyo3-derive-backend
to generate code using vectorcall is not done here.

This exposes PyObject_Vectorcall with a link_name to the
underscored name on 3.8 because it is expected to be stabilized
on 3.9.

This fixes the "fast" objects being new in 3.7, not 3.6.
2019-10-23 21:40:38 +00:00
Alexander Niederbühl 7a4909bdc7 Guard against PyUnicode_AsUTF8AndSize returning null 2019-10-23 00:39:47 +02:00
Alexander Niederbühl b0925e1109 Add conversion traits for PyBytes 2019-10-20 14:42:12 +02:00
Yuji Kanagawa f6f607ef68
Merge pull request #624 from kngwyu/seq-setitem
Fix PySequenceProtocol::set_item
2019-10-19 13:44:49 +09:00
Yuji Kanagawa 69975339be
Merge pull request #630 from programmerjake/fix-bigint-overflow
Fix off-by-one error in FromPyObject for BigInt
2019-10-19 13:44:32 +09:00
Jacob Lifshay f55037c377 switch to using macro for test & change test name 2019-10-18 16:20:16 -07:00
Jacob Lifshay 85492842ac Fix off-by-one error in FromPyObject for BigInt
Fixes #629
2019-10-14 22:31:22 -07:00
kngwyu d57f2423c8 Fix PySequenceProtocol::set_item 2019-10-12 21:03:21 +09:00
kngwyu ee69ffd0f0 Support TryFromSliceError/TryFromIntError -> PyErr conversion 2019-10-12 17:25:28 +09:00
kngwyu 13ccdbee84 Implement IntoPy<PyObject> for BigInts 2019-10-12 15:13:09 +09:00
kngwyu d019fe814c Bump version to 0.8.1 2019-10-08 01:52:06 +09:00
Yuji Kanagawa d602b65347
Merge pull request #615 from PyO3/fix-specialization
Fix broken specialized implementations with Rust 1.40
2019-10-08 01:39:07 +09:00
Martin Larralde 33bf37d3d8 Run cargo fmt on source code and update CHANGELOG.md 2019-10-07 17:12:32 +02:00
Martin Larralde 5397a62f48 Fix broken specialized implementations with Rust 1.40 2019-10-07 16:01:15 +02:00
kngwyu 9b2fbbbe15 [BigInt] Refactor and handle zero based on reviews 2019-10-04 21:04:26 +09:00
kngwyu a18c8ddf59 Fix typos in BigInt tests 2019-09-28 21:22:42 +09:00
kngwyu f8573e7e13 [BigInt] Fix tests for neg value 2019-09-28 18:12:23 +09:00
kngwyu a6d38c9929 Support conversion between num-bigint and Python Long 2019-09-28 17:43:26 +09:00
kngwyu c38bf5ea7c Use to/from_ne_bytes for 128bit int conversion 2019-09-28 16:19:31 +09:00
Yuji Kanagawa 75516d87eb
Merge pull request #603 from kngwyu/upd-doc
Update README and document
2019-09-28 16:18:53 +09:00
Yuji Kanagawa d860ee3f21
Merge pull request #597 from kngwyu/err-nosegv
Reguire GIL before constructing PyErr from Rust value
2019-09-28 15:11:23 +09:00
kngwyu a344999526 [DOC] Add Python from Rust section in the guide 2019-09-23 21:44:42 +09:00
kngwyu 35851b7ff9 Fix documents following the review comment 2019-09-15 22:17:36 +09:00
kngwyu 44f26f4bb9 Update README and document 2019-09-15 19:58:41 +09:00
kngwyu 05a1a097a9 Remove mem::forget from PyBuffer::release 2019-09-14 16:56:11 +09:00
kngwyu 46ba019829 Address clippy warning(to_args->from_err_args) 2019-09-07 16:07:24 +09:00
kngwyu a82726a240 Reguire GIL before constructing PyErr from Rust value 2019-09-07 15:38:59 +09:00
Yuji Kanagawa aaa28a3bd0
Merge pull request #594 from PyO3/pyo3-pack-to-maturin
Replace pyo3-pack with maturin
2019-09-07 11:49:09 +09:00
Alexander Niederbühl 68c3208d35 Move files from ffi3 into ffi
Since Python 2 is no longer supported, one folder should be enough.
2019-09-07 00:50:47 +02:00
konstin a3cde076f4 Replace pyo3-pack with maturin 2019-09-06 01:12:37 +02:00
konstin a3e41cc819 Release 0.8.0 2019-09-05 13:18:50 +02:00
konstin 3228b4cd6c
Merge pull request #585 from andersk/drain-gil
Require the GIL to be held in ReleasePool::drain
2019-09-05 12:46:35 +02:00
kngwyu df44e500a9 Remove py from parse_fn_args's args(to address clippy warning) 2019-09-02 23:05:42 +09:00
kngwyu c7e377a472 [derive_utils] Copy kwargs not to modify it 2019-09-01 23:59:24 +09:00
kngwyu 96b71bfb76 Merge branch 'master' into parse_args_msg 2019-08-31 17:03:15 +09:00
Anders Kaseorg e70e9ab5e6 Require the GIL to be held to drain the ReleasePool
This adds a `Python` marker to `GILPool`, to prevent the caller from
misusing it to drain the `ReleasePool` and release Python objects
without the GIL held.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-08-29 23:55:59 -07:00
konstin b04727c11f FromPy implies IntoPy 2019-08-25 23:52:56 +02:00
konstin 30e82a3018 Replace IntoPyObject with IntoPy<PyObject> 2019-08-24 19:23:28 +02:00
Samuele Maci f15fa210f4 Remove unnecessary trailing semicolon 2019-08-17 15:27:07 +02:00
Samuele Maci 6b4a221d61 Address clippy::float_cmp issues 2019-08-17 14:10:36 +02:00
Samuele Maci 0de22c665f Address clippy::identity_conversion issues 2019-08-17 14:10:36 +02:00
Samuele Maci 6ae27f9c44 Address clippy::unreadable_literal issues 2019-08-17 14:10:35 +02:00
Yuji Kanagawa be22d9e5bb
Merge pull request #573 from kngwyu/ref_into
Implement IntoPyObject to PyRef
2019-08-11 21:04:36 +09:00
kngwyu 5ab216dfe0 Implement IntoPyObject to PyRef 2019-08-11 18:43:50 +09:00
Yuji Kanagawa 1f85593d0a
Merge pull request #564 from kngwyu/paste
Replace mashup with paste
2019-08-11 18:42:21 +09:00
konstin 664209b3ed
Merge pull request #558 from danieldk/fix-iter-null-deref
Fix NULL pointer deref when creating iterator for non-iterable
2019-08-05 14:39:33 +02:00
konstin 38f25f6462
Merge pull request #550 from hengchu/fix/rhs-arithmetic
Attempting to fix #549
2019-08-05 11:40:24 +02:00
kngwyu 41f31e85fd Replace mashup with paste 2019-08-04 23:50:10 +09:00
Alexander Niederbühl 1e01f4f8cc Use to_string() instead of description() for exception messages
`description()` is soft-deprecated and can differ from `to_string()`.

For example for NotFound error:
* `description()`: "entity not found"
* `to_string()`: "No such file or directory (os error 2)"

Since io errors provide their error code through the Display trait there
is no need to get it through `raw_os_error()`.
2019-08-01 00:48:56 +02:00
Daniël de Kok ac28a3114b Fix NULL pointer deref when creating iterator for non-iterable
Fixes #494.
2019-07-27 19:58:18 +02:00
hengchu 3596cc65c0 adding a small testcase for rhs arithmetics 2019-07-21 23:05:03 -04:00
konstin a4ed4543d1 Remove an unsafe 2019-07-21 14:08:49 +02:00
hengchu 741b7e3daa make rhs-arith protocol impls public traits 2019-07-21 03:33:39 -04:00
konstin 58e17be1a6
Merge pull request #545 from PyO3/replace-PyByteArray-data
Replace unsound PyByteArray::data with PyByteArray::to_vec
2019-07-20 13:14:14 +02:00
konstin cd2eefb65a fixup 2019-07-20 12:22:10 +02:00
konstin 1736568d28 Rename also in the tests 2019-07-19 18:17:11 +02:00
Omer Katz 182b2fc615 Add empty() to PySet and PyFrozenSet. 2019-07-19 17:35:47 +03:00
konstin bd86b6750e Replace unsound PyByteArray::data with PyByteArray::to_vec 2019-07-18 22:57:33 +02:00
konstin d90ac76400 Implement Index for PyBytes 2019-07-17 12:29:14 +02:00
konstin 5ae014fe52
Merge pull request #532 from Alexander-N/gc-default
Remove default implementation for PyGCProtocol
2019-07-15 12:02:52 +02:00
konstin 7e4b7168a6
Merge pull request #534 from Alexander-N/clippy
Make CI fail on clippy warnings
2019-07-15 11:48:22 +02:00
kngwyu 370849e075 Use [Option<T>; N] in ArrayList 2019-07-15 13:32:18 +09:00
Alexander Niederbühl cc31c7dbf2 Ignore remaining clippy lints 2019-07-14 22:42:37 +02:00
Alexander Niederbühl faa21f48c7 Fix some clippy lints 2019-07-14 22:42:37 +02:00
Alexander Niederbühl ec71dc63a0 Remove #[allow(unused_variables)] 2019-07-14 18:09:12 +02:00
Alexander Niederbühl 7c687a8d38 Remove default implementation for PyGCProtocol
Implementations for these methods should always be provided. See #531
2019-07-14 17:26:04 +02:00
konstin 7a83cb6afa Use existing fields and methods before calling custom __getattr__
Previously, defining `__getattr__` would override all existing fields and methods. This changes it to behave like a `__getattr__` method defined in python, i.e. the custom method is only called if there isn't a field or method of that name
2019-07-13 22:54:43 +09:00
Yuji Kanagawa 5d85ea7fdc
Merge pull request #513 from kngwyu/pinbox
Refactoring around Box usages
2019-07-10 11:43:10 +09:00
ijl c27d9947a8 Fix deprecation warnings on sync and mem 2019-07-07 09:52:25 +00:00
kngwyu a4cf09f16a Refactor derive_utils 2019-06-16 22:13:50 +09:00
Georg Brandl cba1657460 Adjust the varargs/kwds objects to remove arguments consumed by parameters
Also fix some other validation issues and add more tests.

fixes #420
2019-06-16 22:13:50 +09:00
Georg Brandl 241a8956c9 Fix the argument parsing TypeError message
- parens are already added by the _LOCATION at call site
- fix plural-"s" logic
2019-06-16 22:13:50 +09:00
kngwyu 2fa017a508 Refactor type_object::initialize_type 2019-06-16 21:54:06 +09:00
kngwyu 02d93346c2 Use Pin<Box> for PyBuffer 2019-06-16 21:53:02 +09:00
Yuji Kanagawa 3e69389e68
Merge pull request #512 from kngwyu/expose-py-run
Expose py_run! macro
2019-06-15 23:50:14 +09:00
kngwyu 503ec1a061 Use unindent crate instead of _indoc_runtime 2019-06-15 01:10:18 +09:00
kngwyu f642dbccb2 Refactor py_run! 2019-06-14 18:58:00 +09:00
kngwyu 8dbb388372 Change add_wrapped to take &impl Fn 2019-06-14 12:42:32 +09:00
kngwyu 0f9a3b1194 Expose py_run macro 2019-06-13 18:18:06 +09:00
konstin dfd5a2abb8 Print error before on class init panic
Inspired by https://github.com/rust-numpy/rust-numpy/issues/97, also fixes some warnings from the latest nightly
2019-06-05 12:01:09 +02:00
Martin Larralde 99fdafbb88 Allow setting the module name for a pyclass (#499)
* Add `MODULE` const value to `PyTypeInfo` trait

* Allow setting module name in `pyclass` macro arguments

* Add `$module` argument to `pyobject_native_type` macro in `pyo3::types`

* Set the right module for builtin types in `pyo3::types`

* Add `module` argument to example `word_count.WordCounter` class

* Add `module` argument of `pyclass` macro to guide

* Reformat code using `rustfmt`

* Add tests and entry in CHANGELOG.md for `module` argument in `pyclass`

* Make `$module` parameter in `pyobject_native_type` optional

* Make `pyobject_native_type` declare module as `Some("builtins")` by default
2019-06-03 12:18:44 +09:00
konstin 0279b3d69f Release 0.7.0 2019-05-26 17:27:14 +09:00
kngwyu 4bf448ecaa Complete the PR 2019-05-25 23:19:07 +09:00
Georg Brandl 39d3ceb551 Make PyTuple constructors return &PyTuple 2019-05-25 22:40:32 +09:00
Alexander Niederbühl 6a7090c0b0 Fix some clippy lints 2019-05-16 00:16:23 +02:00
konstin eeeee236fd
Merge pull request #478 from kngwyu/run_returns_empty
Change Python::run to return PyResult<()>
2019-05-12 15:16:17 +02:00
Alexander Niederbühl 299d325375 Enable setting the module name of a class
This is relevant for pickling objects.
2019-05-08 23:39:22 +02:00
kngwyu 803f18e61d Change Python::run to return PyResult<()> 2019-05-08 15:49:24 +09:00
Georg Brandl cdabf9e1a5 Make more constructors return &PyX instead of Py<PyX>
fixes #405
2019-05-06 10:33:31 +02:00
Alexander Niederbühl c68333c5c2 Fix clippy::len_without_is_empty
Also remove obsolete Python 2 comment and add some punctuation for
consistency.
2019-05-04 15:36:10 +02:00
Alexander Niederbühl d174c6ed23 Fix clippy::type_complexity
Don't use PyResult since no error is returned.
2019-05-04 14:03:24 +02:00
konstin c6a5c054e1
Merge pull request #469 from PyO3/remove_doc_comment
Remove doc-comment
2019-04-28 18:26:51 +02:00
konstin cd15719765 Remove doc-comment 2019-04-28 10:36:32 +02:00
Maarten de Vries 651e28ccbb marshal: Remove unwrapped ffi functions. 2019-04-26 10:10:50 +02:00
Maarten de Vries caa5c7f88a marshal: Add example to documentation of dumps. 2019-04-26 10:10:50 +02:00
Maarten de Vries 739efb1b54 marshal: Use PyAny and PyBytes in safe interface. 2019-04-26 10:10:50 +02:00
Maarten de Vries 35168883b2 Add safe marshal module wrapping unsafe ffi::PyMarhshal_*. 2019-04-26 10:10:50 +02:00
Maarten de Vries 1ebdb9f364 Move marshal module from ffi3 to ffi. 2019-04-26 10:10:50 +02:00
Maarten de Vries 0a5edcb74e Add PyMarshal_* functions to ffi modules. 2019-04-26 10:10:50 +02:00
Alexander Niederbühl 1d92c24db8 Add pypy.md to doctests
At the moment there are no code snippets, but all files in the guide
should be included.
2019-04-24 22:44:47 +02:00
Alexander Niederbühl e912900926 Add mistakenly ignored test again 2019-04-24 22:41:59 +02:00
Yuji Kanagawa 60cd0d09c4
Merge pull request #419 from kngwyu/pyclass-regression
Allow slf: PyRef<Self>/PyRefMut<Self> in pymethods
2019-04-24 14:10:28 +09:00
Yuji Kanagawa 5cc6b55c71
Merge pull request #455 from Alexander-N/clippy
Fix some clippy lints
2019-04-24 12:39:21 +09:00
Alexander Niederbühl faa3feda3f Merge branch 'master' into doctest 2019-04-23 21:58:09 +02:00
Alexander Niederbühl 6d87934ce0 Fix some clippy lints 2019-04-23 21:44:40 +02:00
konstin 7149a1fecb
Bump to 0.7.0-alpha.1 (#457) 2019-04-23 18:55:35 +02:00
kngwyu 09bf9bbf4a Allow slf: PyRef<Self> by replacing Self 2019-04-23 23:16:09 +09:00
kngwyu 5a2b021fda Remove FromPyObject from PyRef
It's invalid
2019-04-23 23:16:09 +09:00
kngwyu b2e01066f0 Introduce FromPyPointer for slf: PyRef/PyRefMut 2019-04-23 23:16:09 +09:00
kngwyu 515c7beac0 Allow slf: Py<Self>/PyRef<Self>/PyRefMut<Self> in pymethods 2019-04-23 23:16:08 +09:00
Omer BenAmram f8bf258602 Support rust extensions for PyPy via cpyext (#393)
* wip

* removed stuff

* removed another change

* implemented minimum amouth of ifdefs to make pypy3 hello world to compile

* implemented minimum amount of ifdefs to make pypy3 hello world to compile

* hacking on build.rs

* compiler is happy!

* few todos remain

* extracted build logic to seperate module

* added pypy test

* finally fixed pypy structs

* removed some todos

* test should now be machine independent

* fixed all pypy3 symbols

* added pypy feature

* removed `is_pypy`

* added pypy2 declerations also

* fix for cpython2

* improved libpypy detection

* added all pypy2 macros

* fixed errneous type

* more fixes

* fix python2 string macros

* modsupport symbol

* fix

* fixed and added many symbols

* fixes

* remove dup

* remove mac-specific config

* fix all name mangling macros

* unite imports

* missing symbol

* fix pybool

* implemented another missing symbol

* it works

* fix merge conflict

* uncomment non default features

* cargo.toml

* Cargo fmt

* small merge fixes

* use newer build version

* whoops

* fix build script

* more build hacks

* some random hiccups

* small fixes

* it builds!

* it builds and runs

* revert everything in FFI2

* revert changes to ffi2

* check python3 for pypy

* tiny fix

* revert ffi2 for real

* revert weird formatting changes

* bring back missing feature

* tiny error

* fix py3.7 issue

* add pypy3.5 6.0 to travis

* remove dbg!

* another tiny fix

* removed some useless annotations, and fixed inlines annotations

* removed `pretty_assertions`

* removed pypy feature from cargo.toml

* fix for Py_CompileStringFlags

* tox runs word_count!

* __dict__ changes are not supported for PyPy

* fix 3.7 and copy comment

* fix test script 😳

* transfer ownership of strings to cpython when possible

* remove cstr! macro

* added missing nuls

* as_bytes() -> b’’ string

* symbol removed by mistake

* properly shim pypy date time API, some tests are passing!

* extension_module tests now not crashing! (some still skipped)

* maybe travis has new pypy version?

* small error on windows (build script)

* fix conditional compilation

* try to make tests run on travis..

* invert condition

* added pytest-faulthandler to facilitate debugging

* correctly name dir

* use full paths

* say —yes to conda

* fix

* syntax error

* change PATH

* fixed a terrible bug with PyTypeObjects in PyPy

* fix PyTypeObject defs

* re-enabled tests!

* all tests are passing!

* make the fix ad-hoc for now

* removed build module

* revert changes that cause an additional GC bug

* prevented buggy test from failing pypy

* removed unused comment

* don’t run coverage on pypy

* removed some erroneous symbols from function calls which are actually macros

* restore py37 pyunicode missing def

* use only `link_name` in PyPy specific declarations

* only setup PyPy when testing against PyPy

* annotation that was eaten during merge

* remove change to  comment by mistake + unnecessary changes to cargo.toml

* xfail dates test only on pypy

* changed comment to be a little more helpful

* cleaned up some warnings

* Update src/ffi3/ceval.rs

Co-Authored-By: omerbenamram <omerbenamram@gmail.com>

* @konstin PR notes

* rustfmt

* some documentation

* if configured via env var only, default to cpython

* remove extra unsafe

* refer users to guide for pypy

* Update guide/src/pypy.md

Co-Authored-By: omerbenamram <omerbenamram@gmail.com>

* Update guide/src/pypy.md

Co-Authored-By: omerbenamram <omerbenamram@gmail.com>

* @konstin applied patch

* check that pypy at least build

* search explicitly for libpypy

* added note about some known unsupported features

* use ld_version

* export PYTHON_SYS_EXECUTABLE to `cargo build` test

* inverted if

* always link pypy dynamically

* remove unused imports

* Apply @kngwyu’s suggestion

* fix tox configuration

* try conda virtualenv

* try to simply not install python at all inside pypy environment

* setup pypy before using “python"

* use system_site_packages

* revert change to .travis

* moved cpyext datetime documentation to module level, and revised it.

* Update src/ffi/datetime.rs

Co-Authored-By: omerbenamram <omerbenamram@gmail.com>

* rustfmt

* Update src/ffi/datetime.rs

Co-Authored-By: omerbenamram <omerbenamram@gmail.com>

* kept only notes that are relevant to users.

* invert if

* use bash and not sh
2019-04-23 13:18:42 +02:00
Alexander Niederbühl 5858823e83 Test readme and user guide with doc-comment
Also rename some files for consistency.
2019-04-19 22:38:11 +02:00
konstin f62f384ecd
Merge pull request #448 from PyO3/fix_442
Properly scope libc to fix #442
2019-04-18 18:46:47 +02:00
konstin 6d80ee0679 Properly scope libc to fix #442
Apparently we can't add a test for that because the test crates have libc
in scope
2019-04-17 19:08:55 +02:00
Georg Brandl 527da127f3 Make Py(Frozen)Set::new return PyResult<&Py(Frozen)Set>
fixes #437
2019-04-17 12:17:58 +02:00
ijl afb82ee875 PyFloat_AS_DOUBLE() 2019-04-16 12:53:03 +00:00
Martin Larralde 60efd5b9c2
Merge pull request #432 from althonos/master
Fix documentation-related bugs
2019-04-14 19:05:59 -07:00
Ivan Enderlin a78465f8b1
doc(types) Fix a typo in PySlice
Thanks for the awesome project!
2019-04-13 20:59:31 -07:00
Martin Larralde 3f4f068c7f Ensure #[getter] doc is exposed as the __doc__ of the descriptor 2019-04-14 00:23:59 +02:00
Martin Larralde 72003ec37a Add entry to CHANGELOG.md 2019-04-04 09:47:21 +02:00
Martin Larralde ad9e676512 Have PyModule generate a __all__ list from its members 2019-04-04 09:43:32 +02:00
Martin Larralde 08334fe582 Fix create_exception macro not using an unsafe impl 2019-03-31 05:40:06 +02:00
Martin Larralde 2c82a03170 Add entry to CHANGELOG.md and fix typo 2019-03-31 05:29:20 +02:00
Martin Larralde d482b715de Fix signatures of PySequenceProtocol methods 2019-03-31 05:28:52 +02:00
konstin 9a9b519bcb Mark PyTypeObject as unsafe 2019-03-30 20:25:47 +01:00
ijl 80179be2b0 Merge num3, num_common to num 2019-03-29 12:37:26 +00:00
ijl fdeef7d67e Merge string and stringutils 2019-03-29 12:37:26 +00:00
ijl 2bb0d05a30 Drop support for python2 2019-03-29 12:37:26 +00:00
konstin 20481e8324 Whitelist clippy error 2019-03-24 17:33:08 +01:00