Commit Graph

778 Commits

Author SHA1 Message Date
David Hewitt 16ac7d481d
Merge pull request #1844 from davidhewitt/mapping-type
types: add PyMapping
2021-09-26 14:55:59 +01:00
David Hewitt d929916071 types: add PyMapping 2021-09-26 13:57:33 +01:00
Mo Mirza 4a34cc63a6
Remove use of unwrap (#1888)
* Remove use of unwrap

* Update changelog

* Update CHANGELOG.md

Co-authored-by: Mo Mirza <mo.mirza@iwoca.co.uk>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-09-26 09:01:23 +01:00
Dean Li c72033751e
update changelog 2021-09-25 21:02:06 +08:00
Sergey Kvachonok 2f74ab0d23 build-config: Always pass `abi3` flag to `default_lib_name_windows()`
Hardcoding `false` here leads to an incorrect abi3 DLL name
when cross-compiling to Windows.
2021-09-22 07:30:21 +01:00
Alex Touchet 2a09583b28 Update various links and formatting 2021-09-18 11:48:45 -07:00
David Hewitt 70d829de66 gil: try to initialize threads on Python 3.6 if possible 2021-09-17 08:48:21 +01:00
David Hewitt 097d7e09cb pyo3-build-config: fix location for conda interpreter on windows 2021-09-16 23:38:46 +01:00
David Hewitt dca02a92ce changelog: updates for 0.14.5 backports 2021-09-05 15:19:36 +01:00
Georg Brandl 7cb4faf21c PyList/PyTuple: add as_sequence()
Fixes #1845
2021-09-03 08:09:19 +02:00
Gregory Szorc 1e951d5d8b pyo3-build-config: add a crate feature to control build script
I have a use case in PyOxidizer where I want to use the
pyo3-build-config crate as a library crate so I can access the
`InterpreterConfig` struct so I can read/write config files without
reinventing the wheel.

This is doable before this commit. But it requires that the
build environment have a Python interpreter. This is undesirable
for library usage.

This commit introduces a cargo feature flag to control whether the
build script does anything. The feature flag must be present for
the build script to resolve a config. The feature flag is enabled
by default for backwards compatibility. The pyo3 and pyo3-macros-backend
crates use this feature by default, for backwards compatibility and
because it is the reasonable default.

This is probably room to conditionalize some APIs and other behavior
based on this feature flag. But we stop short of doing that for
the time being.
2021-09-01 19:44:54 -07:00
David Hewitt 921c4410ce
Merge pull request #1849 from PyO3/pylist_apis
PyList: add more sequence APIs
2021-09-01 08:50:49 +01:00
David Hewitt 868f668201
Merge pull request #1819 from indygreg/links-python
cargo: add `links = "python"`
2021-08-30 22:22:56 +01:00
Gregory Szorc 82d9b44f5e cargo: add `links = "python"`
PyOxidizer has crates depending on `pyo3` that would like to access
the `pyo3` crate configuration. (This use case isn't unique to
PyOxidizer.)

Cargo has a facility for enabling the build scripts of dependent
crates to access _exported_ variables via `DEP_` environment
variables. However, this only works if the exporting crate defines a
`links` key in its Cargo manifest. See
https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key.

While `pyo3`'s build script doesn't yet export the variables that
PyOxidizer will need, a prerequisite to making this work is adding
the `links` key. Since this change could introduce unintended
side-effects, it warrants being made in its own commit, which is
why we're making this change outside of #1793.

I _think_ this change should be mostly safe: the `links` key is
effectively metadata advertising that a crate links against a named
library. The only side-effects setting it has is to enable the
aforementioned `DEP_` environment variables in build scripts and
enforcing a limitation that only a single crate may link against the
same native library. I believe the only potential for this change
to cause problems is if there are multiple crates with `links =
"python"` entries. I'm not aware of any other crates that advertise
`links = "python"`: even `python3-sys` / `cpython` use `links =
"python3"` so this change should not prevent dual use of `pyo3` and
`cpython` in the same build.
2021-08-30 09:47:54 -07:00
David Hewitt a20864a903 ci: test and fix s390x build 2021-08-30 13:50:44 +01:00
Georg Brandl af46bf3bc6 PyList/Tuple: add more sequence APIs
See #1845
2021-08-30 12:19:31 +02:00
David Hewitt 5119bad580 changelog: updates for 0.14.4 2021-08-29 08:07:44 +01:00
David Hewitt f76535fd07 pyo3-macros-backend: support macros inside doc attributes 2021-08-28 22:47:20 +01:00
David Hewitt cf0e8a6435
Merge pull request #1830 from deantvv/ffi-cleanup-0825
ffi cleanup: pystrtod to pythonrun
2021-08-28 07:23:47 +01:00
David Hewitt 9c03227a20
Merge pull request #1833 from davidhewitt/changelog-function-brackets
changelog: remove function parentheses
2021-08-27 22:57:41 +01:00
Dean Li 73220565c1
update changelog 2021-08-27 23:36:59 +08:00
David Hewitt 755dd221e7 pystring: disable `PyString::data` on big-endian targets 2021-08-26 19:29:58 +01:00
David Hewitt 4a50a26c87 changelog: remove function parentheses 2021-08-26 18:59:07 +01:00
David Hewitt 3a90ff77f4 list,tuple,sequence: add slice indexing 2021-08-26 07:57:12 +01:00
David Hewitt de87971bf6
Merge pull request #1827 from davidhewitt/changelog-tidy
changelog: fix PR links
2021-08-24 20:29:58 +01:00
Georg Brandl 3bed78230d
Merge pull request #1828 from PyO3/get_slice_rename 2021-08-24 10:38:32 +02:00
Georg Brandl 097216702f tuple: add back old slice() for deprecation cycle 2021-08-24 09:08:08 +02:00
David Hewitt 764b1e5b95 changelog: fix PR links 2021-08-24 07:44:50 +01:00
Georg Brandl c522a9c087 list/tuple: rename slice -> get_slice 2021-08-24 08:40:05 +02:00
Georg Brandl 611126d994 list/tuple/sequence: implement Index
See #1667.
2021-08-24 08:24:47 +02:00
Georg Brandl 8083c1c310 Update changelog for #1802 and #1803. 2021-08-23 15:47:09 +02:00
David Hewitt bc1a983371 changelog: update for 0.14.3 release 2021-08-22 01:25:29 +01:00
David Hewitt 591f44ea6d
Merge pull request #1794 from indygreg/pystringdata
string: implement API to access raw string data
2021-08-21 22:54:58 +01:00
Gregory Szorc 0cf7776a4d string: implement API to access raw string data
With the recent implementation of non-limited unicode APIs, we're
able to query Python's low-level state to access the raw bytes that
Python is using to store string objects.

This commit implements a safe Rust API for obtaining a view into
Python's internals and representing the raw bytes Python is using
to store strings.

Not only do we allow accessing what Python has stored internally,
but we also support coercing this data to a `Cow<str>`.

Closes #1776.
2021-08-19 18:24:17 -07:00
Christian Heimes d74c3f6cd0 Use 'crate::' to refer to pyo3
Fixes: #1811
Signed-off-by: Christian Heimes <christian@python.org>
2021-08-18 12:54:27 +02:00
Péter Leéh f72b2c8f09
Py_CompileString decref (#1810)
* update changelog

* fix memory leak in PyModule::from_code

* add PR link to changelog

* Add Py_DECREF also when PyImport_ExecCodeModuleEx fails

* Remove duplicated calls, simplify logic

Co-authored-by: messense <messense@icloud.com>

Co-authored-by: messense <messense@icloud.com>
2021-08-18 10:50:57 +00:00
Peter Schafhalter 37ea57de2b Update changelog 2021-08-17 22:56:27 -07:00
Peter Schafhalter e4466549e5 Edit changelog 2021-08-17 14:37:39 -07:00
Aviram Hassan c6255e6734 - `PyList`, `PyTuple` and `PySequence`'s `get_item` now accepts only `usize` indices instead of `isize`.
- `PyList` and `PyTuple`'s `get_item` now always uses the safe API. See `get_item_unchecked` for retrieving index without checks.
2021-08-17 15:01:22 +01:00
David Hewitt 7a92e2699b
Merge pull request #1804 from davidhewitt/deprecate_split_from
pytuple: deprecate split_from
2021-08-17 15:00:21 +01:00
David Hewitt 37d39aa83a
Merge pull request #1751 from davidhewitt/pyany-py
pyany: add PyAny::py()
2021-08-17 14:10:16 +01:00
David Hewitt 7fd70d103e pytuple: deprecate split_from 2021-08-17 13:57:27 +01:00
Matthew Treinish 60db3a45b3
Expand supported num-complex versions
When building an extension with rust-numpy and ndarray on the MSRV of
1.41 with complex numbers. The num-complex crate version needs to be
0.2 which was the pinned version as of ndarray 0.13.1 which was the last
release of ndarray that supported building with rust 1.41. However, the
pyo3 pinned version of 0.4 is incompatible with this and will cause an
error when building because of the version mismatch. To fix this This
commit expands the supported versions for num-complex to match what
rust-numpy uses [1] so that we can build pyo3, numpy, ndarray, and
num-complex in an extension with rust 1.41.

Fixes #1798

[1] https://github.com/PyO3/rust-numpy/blob/v0.14.1/Cargo.toml#L19
2021-08-16 14:43:07 -04:00
David Hewitt 78f269e946
Merge branch 'main' into setter-handle-del 2021-08-14 08:07:15 +01:00
David Hewitt 30e6f58080
Update CHANGELOG.md 2021-08-14 07:43:32 +01:00
David Hewitt 150f4adbba
Update CHANGELOG.md 2021-08-14 07:40:52 +01:00
Gregory Szorc 410c9f13c9 macros: raise AttributeError on property deletion requests
The setter function will receive a NULL value on deletion requests.
This wasn't properly handled before, leading to a panic.

The new code raises AttributeError in this scenario instead.

A test for the behavior has been added. Documentation has also
been updated to reflect the behavior.
2021-08-13 21:01:00 -07:00
Gregory Szorc d3762a679f ffi: fix PyStatus._type
The field wasn't defined previously. And the enum wasn't defined as
`[repr(C)]`.

This missing field could result in memory corruption if a Rust-allocated
`PyStatus` was passed to a Python API, which could perform an
out-of-bounds write. In my code, the out-of-bounds write corrupted a
variable on the stack, leading to a segfault due to illegal memory
access. However, this crash only occurred on Rust 1.54! So I initially
mis-attribted it as a compiler bug / regression. It appears that a
low-level Rust change in 1.54.0 changed the LLVM IR in such a way to
cause LLVM optimization passes to produce sufficiently different
assembly code, tickling the crash. See
https://github.com/rust-lang/rust/issues/87947 if you want to see
the wild goose chase I went on in Rust / LLVM land to potentially
pin this on a compiler bug.

Lessen learned: Rust crashes are almost certainly due to use of
`unsafe`.
2021-08-13 20:51:26 -07:00
David Hewitt 0bfd50d314 ffi: cleanup pystate 2021-08-13 08:26:38 +01:00
David Hewitt ebada76ae3 pyany: add PyAny::py() 2021-08-13 08:00:13 +01:00
messense 4c734ef72a
Merge pull request #1783 from PyO3/davidhewitt-patch-1
changelog: fix missing PR number
2021-08-12 10:33:10 +08:00
David Hewitt c59b51b85b
changelog: fix missing PR number 2021-08-11 23:49:01 +01:00
messense 3ba24bee14 `PyErr::api_call_failed` should return a `SystemError` when no error is set
17f94e2888/Python/ceval.c (L4330-L4333)
2021-08-11 23:45:09 +01:00
messense 9d0b92bf32 Change `PyErr::fetch` to return an `Option<PyErr>` 2021-08-11 23:44:40 +01:00
David Hewitt 1873264b7d release: 0.14.2 2021-08-09 07:58:31 +01:00
David Hewitt 575c448345
Merge pull request #1769 from indygreg/force-acquire-gil
gil: add unsafe variation for obtaining GILGuard without checks
2021-08-09 07:49:06 +01:00
Gregory Szorc 3a6740a459 gil: add unsafe variation for obtaining GIL without checks
GILGuard::acquire() cannot be called during multi-phase Python
interpreter initialization because it calls Py_IsInitialized(),
which doesn't report the interpreter as initialized until all
phases of initialization have completed.

PyOxidizer uses the multi-phase initialization API and needs to
interact with pyo3's high-level APIs (not the FFI bindings) after
partial interpreter initialization, before the interpreter is fully
initialized. Attempts to use GILGuard::acquire() result in a panic
due to the aforementioned Py_IsInitialized() check failing.

This commit refactors the GILGuard logic into a function that
obtains the actual GILGuard and another function to perform
checks before calling the aforementioned functions.

A new unsafe `Python::with_gil_unchecked()` has been defined
to acquire the GIL via the unchecked code path so we may obtain
a `Python` during multi-phase initialization (and possibly other
scenarios).
2021-08-08 15:40:10 -07:00
Gregory Szorc 495ac98eb3 ffi: fix Py_DecodeLocale() signature
Closes #1766.
2021-08-08 10:38:00 -07:00
Dean Li 03981b373a
add CHANGELOG.md 2021-08-07 16:38:24 +08:00
David Hewitt 5af835daed pyo3-build-config: fix build for windows gnu targets 2021-08-07 00:25:14 +01:00
David Hewitt c2d6a50b35 build: revert usage of cargo:rustc-cdylib-link-arg 2021-08-03 20:04:56 +01:00
David Hewitt 4c5aee92d5 pycell: fix calculation of dictoffset on 32-bit Windows 2021-07-31 15:09:12 +01:00
David Hewitt bbe0e846b0
Merge pull request #1738 from davidhewitt/latest-links
docs: use pyo3.rs/latest instead of pyo3.rs/main
2021-07-24 17:57:03 +01:00
David Hewitt 4a71f82099
Merge pull request #1724 from davidhewitt/err-new-no-gil
err: don't use with_gil internally in PyErr::new()
2021-07-24 10:13:50 +01:00
David Hewitt c09947a61c err: don't use with_gil internally in PyErr::new() 2021-07-24 08:51:17 +01:00
David Hewitt 3794aab11f docs: use pyo3.rs/latest instead of pyo3.rs/main 2021-07-24 08:47:02 +01:00
David Hewitt d46d3265cb pypy: fix FFI definition of Py_Buffer 2021-07-24 08:37:22 +01:00
Ivan Carvalho bd0e0d808f
Add optional support for conversion from `indexmap::IndexMap` (#1728)
* Add support to IndexMap

* Fix indexmap version to 1.6.2

* Remove code duplication by mistake

* Fix ambiguity in test

* Minor change for doc.rs

* Add to lib.rs docstring

* Add indexmap to conversion table

* Add indexmap flag in docs.rs action

* Add indexmap feature to CI

* Add note in changelog

* Use with_gil in tests

* Move code to src/conversions/indexmap.rs

* Add PR number to CHANGELOG

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

* Add round trip test

* Fix issue in MSRV Ubuntu build

* Fix Github workflow syntax

* Yet Another Attempt to Fix MSRV Ubuntu build

* Specify hashbrown to avoid ambiguity in CI

* Add suggestions

* More flexible version for indexmap

* Add documentation

* Address PR comments

* Export indexmap for docs

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-07-22 08:15:26 +01:00
Alex Gaynor a941b2c65f Added a changelog entry 2021-07-15 07:14:44 -04:00
David Hewitt d11943ab6d macros-backend: don't error on #[doc(hidden)] 2021-07-08 23:41:24 +01:00
David Hewitt 3f8c4ad38e release: 0.14.1 2021-07-04 16:49:36 +01:00
Georg Brandl f7235482eb PyPy: the PyList_GET/SET macros are defined as functions, the PyTuple_ ones do not exist 2021-07-04 15:54:40 +02:00
messense eaf5dcaab7 Implement `IntoPy<PyObject>` for `&PathBuf` and `&OsString` 2021-07-04 16:18:04 +08:00
David Hewitt adf6bdba8e release: 0.14.0 2021-07-03 08:37:00 +01:00
David Hewitt 0215054012
Merge pull request #1702 from ohadravid/to-python-set-non-default-hashbuilder
Make `ToPyObject` impl for `HashSet` accept non-default hashers.
2021-06-27 17:29:00 +01:00
Ohad Ravid fcffcdfae5 Added `size_hint` impls for `{PyDict,PyList,PySet,PyTuple}Iterator`s 2021-06-27 16:10:53 +03:00
Ohad Ravid 43fca5dad7 Make `ToPyObject` impl for `HashSet` accept non-default hashers. 2021-06-27 15:19:01 +03:00
messense b5b9a480cd Add `wrap_pyfunction` macro to prelude 2021-06-24 22:34:55 +08:00
mejrs 455cc95c54
implement ffi/cpython/pystate (#1687)
* dont reexport cpython items twice

* add ffi module level doc

* reorder to header file order

* cargo fmt

* implement cpython/pystate

* fix import errors

* make PyInterpreterState opaque

* update changelog

* fix formatting
2021-06-24 20:05:15 +08:00
David Hewitt a02353ce34
Merge pull request #1679 from messense/error-cause
Add support for setting and retrieving exception cause
2021-06-24 07:58:34 +01:00
messense 2bac6c5a3a Add support for setting and retrieving exception cause 2021-06-23 20:14:49 +08:00
Gabriel Majeri b048bfa75f Update the changelog 2021-06-23 15:03:03 +03:00
David Hewitt f916867375 pyclass: refactor initialization, call native type dealloc 2021-06-23 07:45:51 +01:00
David Hewitt a290971759
Merge pull request #1650 from davidhewitt/pymodule-name
pymodule: accept `#[pyo3(name = "...")]` option
2021-06-06 11:11:10 +01:00
Georg Brandl 98461a2ef6 PyList tests: simplify construction 2021-06-06 10:28:15 +02:00
David Hewitt 18e0aa17e0 pymodule: accept `#[pyo3(name = "...")]` option 2021-06-06 08:41:20 +01:00
Georg Brandl 3bebc19e2d PyList: remove get_parked_item, use macros for speed on !abi3 2021-06-06 07:54:38 +02:00
Georg Brandl 60862c308b Update changelog entry. 2021-06-06 07:08:23 +02:00
David Hewitt cec4c2d2e9 text_signature: move to `#[pyo3(text_signature = "...")]` 2021-06-05 16:33:03 +01:00
David Hewitt a5810eaffa
Merge pull request #1619 from birkenfeld/fastcall
Implement METH_FASTCALL for pyfunctions.
2021-06-05 12:32:16 +01:00
Georg Brandl 3e8d003faf Implement METH_FASTCALL for pyfunctions and pymethods. 2021-06-05 12:57:22 +02:00
David Hewitt 97d6f15b32
Merge pull request #1626 from alonblade/cross-sysconfig
build.rs: if found more than one candidate, filter on arch
2021-06-05 09:29:00 +01:00
messense bd1045e289 Add support for extracting PathBuf from pathlib.Path 2021-06-05 14:59:26 +08:00
Alon Levy e5542f2214 pyo3-build-config: if found more than one candidate, filter on arch
If we got more then one file, only take those that contain the arch name.
For ubuntu 20.04 with host architecture x86_64 and a foreign architecture of armhf
this reduces the number of candidates to 1:

  $ find /usr/lib/python3.8/ -name '_sysconfigdata*.py' -not -lname '*'
  /usr/lib/python3.8/_sysconfigdata__x86_64-linux-gnu.py
  /usr/lib/python3.8/_sysconfigdata__arm-linux-gnueabihf.py

CHANGELOG.md: add entry for cross-sysconfigdata filter on arch

commit changelog:
1. initial
2. if filtered list is empty, use pre filtered.
3. clippy is_empty and cloned
2021-05-30 10:07:03 +03:00
Erik Johnston a56f23d7f2 Add changelog entry 2021-05-26 12:23:47 +01:00
David Hewitt 3e87ea3593 pymodule: don't call PyEval_InitThreads 2021-05-25 11:02:16 +01:00
David Hewitt 355bd0c336 pymodule: tidy up module init 2021-05-25 10:54:16 +01:00
David Hewitt f4dfafa07b changelog: fix missing bits 2021-05-25 07:32:47 +01:00
David Hewitt a109640850 pyfn: deprecate name argument 2021-05-20 08:54:29 +01:00
Tim Robinson 50352f9137 Apply review suggestions 2021-05-15 10:34:34 +01:00
Tim Robinson c803033f5e Add to CHANGELOG 2021-05-13 13:17:56 +01:00
David Hewitt 4d46abde73 macros: support `#[pyo3(name = "...")]` 2021-05-07 22:35:52 +01:00
David Hewitt 4613b3dd7e
Merge pull request #1596 from davidhewitt/remove-pytypeinfo-layout
type_object: remove layout and base type from PyTypeInfo
2021-05-07 22:32:24 +01:00
David Hewitt d81abe8344 pyclass: support extending Exception types 2021-05-04 22:00:22 +01:00
David Hewitt 7536554ceb type_object: remove layout and base type from PyTypeInfo 2021-05-04 21:39:42 +01:00
David Hewitt 3ee84a3c26
Merge pull request #1128 from c410-f3r/array
Add support for arbitrary arrays
2021-05-01 16:02:22 +01:00
David Hewitt c0ff97e525
Merge pull request #1573 from davidhewitt/utc
ffi: support PyDateTime_TimeZone_UTC
2021-04-29 22:55:35 +01:00
David Hewitt 7ead166d9d array: safer implementation of try_create_array 2021-04-26 08:22:14 +01:00
Caio 9bc5089e4b Add support for arbitrary arrays 2021-04-26 08:22:14 +01:00
David Hewitt e95e73b55e ffi: support PyDateTime_TimeZone_UTC 2021-04-22 22:42:57 +01:00
Gregory Szorc 754c27f17d ffi: Define missing import APIs
Co-authored-by: Nicholas Sim <nsim+github@posteo.net>
2021-04-21 21:01:26 +01:00
David Hewitt 48823e22d6 pyproto: deprecate py_methods 2021-04-20 00:21:19 +01:00
David Hewitt 2b9085abdb build: avoid rebuilds when using clippy in a virtualenv 2021-04-19 09:45:01 +01:00
David Hewitt eaf75023ed ffi: prevent segfault with datetime bindings 2021-04-17 11:01:52 +01:00
David Hewitt aa0b5d8488 buffer: tidy up exceptions 2021-04-12 01:21:48 +01:00
David Hewitt b7b9f55a93
Merge pull request #1538 from davidhewitt/pypy-3.7
pypy: support PyPy 3.7
2021-04-03 07:03:43 +01:00
David Hewitt 5bf0bb80f6
Merge pull request #1539 from davidhewitt/macos-link-args
macos: automatically provide required linker arguments
2021-04-03 07:02:33 +01:00
David Hewitt b213f06df4 macos: automatically provide required linker arguments 2021-04-02 14:18:28 +01:00
David Hewitt 410f61934a pypy: support PyPy 3.7 2021-04-02 12:11:14 +01:00
David Hewitt e035b2abcf pypy: support EnvironmentError, OSError, WindowsError 2021-03-31 08:03:45 +01:00
David Hewitt 2702c33a61
changelog: fix code block 2021-03-28 22:11:15 +01:00
David Hewitt 8ad3827341
Merge pull request #1514 from jameshilliard/cross-env-detection
Ensure we are cross compiling when any cross env variables are set.
2021-03-28 12:46:59 +01:00
Sergey Kvachonok 80c747d2c0 Remove `pyconfig.h` header parsing
The config header parsing code was supposed to be only invoked when
cross-compiling for Windows, but in reality it fails to correctly parse
the config header files shipped with the upstream Python for Windows.

Given that there are now better options for reliable cross-compiling
for Windows such as `PYO3_CROSS_PYTHON_VERSION` or the `abi3-py3*` features,
it should be OK to remove this config for v0.14.

Update the cross-compilation instructions section of the user guide.

Fixes https://github.com/PyO3/pyo3/issues/1337
2021-03-26 09:57:18 +03:00
David Hewitt 93696889d3
Merge pull request #1496 from PyO3/dependabot/cargo/hashbrown-0.11
build(deps): update hashbrown requirement from 0.9 to 0.11
2021-03-25 08:01:31 +00:00
David Hewitt a2788b052d hashbrown: support 0.9 or 0.11 2021-03-24 22:35:37 +00:00
James Hilliard 2c3e8b1c50 Ensure we are cross compiling when any cross env variables are set. 2021-03-23 05:13:52 -06:00
David Hewitt 246335bee2
Merge pull request #1505 from scalexm/macro
Ignore `syn::Type::Group` in `is_python`
2021-03-20 11:09:04 +00:00
David Hewitt e34e87ad4a 1505: add CHANGELOG and test 2021-03-20 08:36:19 +00:00
Yuji Kanagawa acff3b1f3e
Merge pull request #1504 from PyO3/pyclass
Add tuple and unit struct support for pyclass macro
2021-03-20 16:14:15 +09:00
messense acd4601d2f Remove __doc__ from module's __all__ 2021-03-20 11:25:36 +08:00
messense 773a371ba5 Add tuple and unit struct support for pyclass macro 2021-03-19 10:17:06 +08:00
David Hewitt f22fb423cb
Merge pull request #1503 from davidhewitt/main-tweaks
main: tweaks from rename
2021-03-17 21:07:58 +00:00
Yuji Kanagawa 6137e3a726
Merge pull request #1456 from davidhewitt/pyclass-impl-flags
pyclass: move flags to PyClassImpl
2021-03-17 12:50:49 +09:00
David Hewitt 4d2913dc06 main: tweaks from rename 2021-03-16 22:14:57 +00:00
David Hewitt b10cefdca2 pymodule: remove call_function etc. 2021-03-14 11:19:55 +00:00
David Hewitt 31c7af2ac7 pyclass: move flags to PyClassImpl 2021-03-13 22:44:53 +00:00
David Hewitt 78080ebbd2 macros-backend: support noargs for pyproto py_methods 2021-03-08 23:56:08 +00:00
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