Commit Graph

341 Commits

Author SHA1 Message Date
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