Commit graph

3593 commits

Author SHA1 Message Date
David Hewitt 150f4adbba
Update CHANGELOG.md 2021-08-14 07:40:52 +01: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 254ea53f3f
Merge pull request #1789 from davidhewitt/example-word-count
examples: make `word-count` example comparison fairer
2021-08-13 15:08:16 +01:00
David Hewitt e44920ef9c
Merge pull request #1790 from PyO3/davidhewitt-patch-1
ffi: fix PyPy symbols for `cpython/pystate.rs`
2021-08-13 15:07:29 +01:00
David Hewitt 06ff76fec2
examples: make word-count example comparison fairer 2021-08-13 14:19:46 +01:00
David Hewitt c439f97f1a
ffi: fix PyPy symbols for cpython/pystate.rs 2021-08-13 14:07:15 +01:00
David Hewitt 388c2552f8
Merge pull request #1786 from mejrs/with_gil2
tests: switch to python_with_gil
2021-08-13 12:39:17 +01:00
David Hewitt 874e7e5cab
Merge pull request #1787 from davidhewitt/ffi-pystate
ffi: cleanup pystate
2021-08-13 12:36:37 +01:00
David Hewitt 0bfd50d314 ffi: cleanup pystate 2021-08-13 08:26:38 +01:00
mejrs 596c3ff4b7 remove now unused imports 2021-08-12 12:08:54 +02:00
mejrs 9fe3e2b2b8
Apply suggestions from code review
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-12 11:52:56 +02:00
David Hewitt 0b269c4d3d
Merge pull request #1678 from sansyrox/main
Add documentation to call async python from rust
2021-08-12 08:58:46 +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
messense 2a7c4f495b
Merge pull request #1784 from davidhewitt/gh-actions-pages-v3
guide: allow using newer gh-actions-pages version
2021-08-12 10:32:35 +08:00
messense d197357478
Merge pull request #1785 from davidhewitt/pin-bitflags
ci: pin bitflags for MSRV job
2021-08-12 10:31:13 +08:00
mejrs f55a9c8ab0 tests: switch to python_with_gil 2021-08-12 02:47:41 +02:00
David Hewitt 4eee9009db ci: pin bitflags for MSRV job 2021-08-12 00:27:49 +01:00
David Hewitt bdad08ce6a
Merge pull request #1717 from messense/pyerr-fetch
Change `PyErr::fetch` to return an `Option<PyErr>`
2021-08-12 00:24:15 +01:00
Sanskar Jethi aac3d1da6e Add documentation to call async python from rust 2021-08-12 00:22:10 +01:00
David Hewitt 72f3f1131b guide: allow using newer gh-actions-pages version 2021-08-11 23:50:58 +01: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 93b25edba1 Use errror_on_minusone more often 2021-08-11 23:44:40 +01:00
messense 9d0b92bf32 Change PyErr::fetch to return an Option<PyErr> 2021-08-11 23:44:40 +01:00
David Hewitt 140c090504
Merge pull request #1780 from davidhewitt/pin-trybuild
ci: downgrade trybuild to 1.0.43
2021-08-11 09:26:41 +01:00
David Hewitt c59f518f76 ci: downgrade trybuild to 1.0.43 2021-08-11 08:39:37 +01:00
David Hewitt 76e79d615c
Merge pull request #1772 from davidhewitt/async-guide-fixes
guide: don't bother doctesting async guide
2021-08-11 00:52:25 +01:00
David Hewitt 290ded4d4e guide: don't bother doctesting async guide 2021-08-10 07:56:36 +01:00
David Hewitt 6a9ef543c1
Merge pull request #1771 from awestlake87/master
Problems with the new Async/Await guide
2021-08-10 07:48:58 +01:00
Andrew J Westlake f4975c6e1d Fixed broken link in async-await.md 2021-08-09 09:07:57 -05:00
David Hewitt ccdc26f971
Merge pull request #1760 from PyO3/release-0.14.2
release: 0.14.2
2021-08-09 09:03:51 +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
David Hewitt 91615338ae
Merge pull request #1764 from awestlake87/master
Updated async-await guide for pyo3-asyncio 0.14
2021-08-08 23:14:43 +01:00
David Hewitt edec1f12d6
Merge pull request #1763 from deantvv/ffi-cleanup
clean up ffi from pyframe to pyhash
2021-08-08 23:09:19 +01:00
David Hewitt 473cd5cc4f
Merge pull request #1765 from indygreg/frozen-public
ffi: make _frozen fields public
2021-08-08 23:09:00 +01:00
David Hewitt ac92b79f83
Merge pull request #1768 from indygreg/decodelocale-signature
ffi: fix Py_DecodeLocale() signature
2021-08-08 23:08:45 +01:00
Andrew J Westlake bf23f8bda7 Shortened the async/await guide 2021-08-08 14:58:46 -05:00
David Hewitt 3de5591534
Merge pull request #1767 from indygreg/packagecontext
ffi: define _Py_PackageContext
2021-08-08 19:23:18 +01:00
Gregory Szorc 495ac98eb3 ffi: fix Py_DecodeLocale() signature
Closes #1766.
2021-08-08 10:38:00 -07:00
Gregory Szorc 42eb8f26ae ffi: define _Py_PackageContext
This is needed for PyOxidizer.
2021-08-08 10:35:20 -07:00
Gregory Szorc 9a9362909f ffi: make _frozen fields public
PyOxidizer needs to access these fields.
2021-08-08 08:52:08 -07:00
Andrew J Westlake 9037697bed
Update guide/src/ecosystem/async-await.md
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-08 10:15:01 -05:00
Andrew J Westlake d578f37f70
Removed "auto-initialize" feature from uvloop example
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-08 10:13:47 -05:00
Andrew J Westlake 92c3af5088
Forgot to bump another pyo3 version
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-08 09:59:17 -05:00
Andrew J Westlake dbb956fd4c
Forgot to bump pyo3 version
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-08-08 09:59:01 -05:00
Dean Li 19eb3138f2
clean up ffi from pyframe to pyhash 2021-08-08 19:56:11 +08:00
David Hewitt e9cccd74bf
Merge pull request #1577 from davidhewitt/compile-errors-on-coverage
coverage: also run compile_error tests
2021-08-08 08:47:31 +01:00
Andrew J Westlake 5c5a406ce4 Updated async-await guide for pyo3-asyncio 0.14 2021-08-07 22:53:26 -05:00