Alex Gaynor
5061b501a9
Remove IntoPyPointer
...
it wasn't used in any public APIs following #3359
2023-08-14 16:28:20 -04:00
David Hewitt
a541925f00
Merge pull request #3359 from davidhewitt/py-pointer-methods
...
add as_ptr and into_ptr inherent methods
2023-08-11 19:50:22 +00:00
David Hewitt
8031794f2a
Merge pull request #3378 from GoldsteinE/implicit-builtins
...
add `__builtins__` to globals in `py.run()` if they're missing
2023-08-11 14:11:31 +00:00
Goldstein
0be94a5442
add `__builtins__` to globals in `py.run()` if they're missing
...
Python code doesn't like to run without `__builtins__`, so adding them
if missing seems to be a good idea. Also that's what CPython >3.10 does.
See https://github.com/python/cpython/pull/24564
Resolves #3370
2023-08-11 15:48:05 +03:00
David Hewitt
64adab1a76
add as_ptr and into_ptr inherent methods
2023-08-11 10:49:42 +01:00
Tpt
1e5a49557d
Makes PathBuf FromPyObject implementation work on all os.PathLike
...
PyOS_FSPath is in abi3-py36
2023-08-08 22:15:56 +02:00
Adam Reichold
a371fbe4f8
Implement DoubleEndedIterator for PyListIterator by caching the length while still validating it before access.
2023-08-07 21:37:50 +02:00
Adam Reichold
4ce3e9649f
Implement DoubleEndedIterator for PyTupleIterator
2023-08-07 21:37:50 +02:00
David Hewitt
ef43731993
update tests of refcounting to use a non-immortal object
2023-07-30 15:37:06 +01:00
David Hewitt
4e957e8bd4
update object.h definitions for Python 3.12
2023-07-30 15:37:06 +01:00
Juniper Tyree
16fe7a83a7
Add a PySlice::full() constructor for ::
2023-07-29 07:39:47 +00:00
David Hewitt
e2c88d5a4e
optimize `float` -> `f64` conversions on non-abi3
2023-07-28 20:45:37 +01:00
David Hewitt
34881fc952
add PyAny::downcast_exact
2023-07-28 15:11:56 +01:00
David Hewitt
a15614844d
add PyErr::display
2023-07-24 22:14:55 +01:00
David Hewitt
ab078258d1
fix exception handling on Python 3.12
2023-07-19 22:33:25 +01:00
Zak Stucke
f2b7e86e2e
Prevent traceback loss on conversion to and from PyErr
2023-07-19 12:07:41 +03:00
David Hewitt
2e2dde910a
Preserve panic message after exception is normalized
2023-07-18 22:20:41 +01:00
David Hewitt
421e13a89c
Merge pull request #3323 from davidhewitt/pyerr-simplification
...
merge PyErr internal states for simplicity
2023-07-17 21:46:39 +00:00
David Hewitt
2d1b8e02a8
merge PyErr internal states for simplicity
2023-07-17 22:21:28 +01:00
David Hewitt
e5a7400f24
Merge pull request #3319 from davidhewitt/used-underscore-binding
...
clippy: deny / fix used-underscope-binding lint
2023-07-16 20:53:56 +00:00
David Hewitt
45ff25cd2a
clippy: deny / fix used-underscope-binding lint
2023-07-16 20:49:45 +01:00
David Hewitt
6f30215566
collect arrays of objects prior to filling tuple in fixed-size conversions
2023-07-16 20:17:02 +01:00
Adam Reichold
65312b43b2
Merge pull request #3312 from davidhewitt/opt-baseexception
...
optimize is_instance for PyBaseException
2023-07-14 16:37:24 +00:00
David Hewitt
f39dd52cf9
remove concept of "normalize" from PyErr docs
2023-07-14 13:20:48 +01:00
David Hewitt
92b724f64f
normalize exception in `PyErr::matches` and `PyErr::get_type`
2023-07-14 13:18:30 +01:00
David Hewitt
b65cbb958b
ci: updates for rust 1.71
2023-07-14 12:10:37 +01:00
David Hewitt
272997555e
optimize is_instance for PyBaseException
2023-07-11 21:48:46 +01:00
Adam Reichold
ff78b92e77
Start adding a performance section to the guide.
2023-07-09 14:32:59 +02:00
Adam Reichold
bd7aed4b12
Add implementation of Iterator::size_hint for PyIterator
...
When the Python iterator backing `PyIterator` has a `__length_hint__` special
method, we can use this as a lower bound for Rust's `Iterator::size_hint` to
e.g. support pre-allocation of collections.
This is implemented using `PyObject_LengthHint` which is not available in the
stable ABI and hence so is `Iterator::size_hint`. This should be fine since this
is an optimization in any case and the stable ABI is expected to have slightly
worse performance overall.
2023-07-09 10:16:20 +02:00
David Hewitt
81c0328d91
use concrete inner for `PyErr:matches`
2023-07-04 21:03:24 +01:00
David Hewitt
76f3a395ef
move `unsafe` block inside `error_on_minusone` calls
2023-07-04 21:03:24 +01:00
David Hewitt
43477a8e30
use error_on_minusone in more cases
2023-07-04 21:03:24 +01:00
David Hewitt
7613f65c89
apply conventions for ffi calls
2023-07-04 21:03:24 +01:00
David Hewitt
bf2f441567
prefer inner / _private naming
2023-07-04 21:03:24 +01:00
Adam Reichold
54ab9090be
Merge pull request #3269 from grantslatton/timezone-conversion-bugfix
...
Fix fixed offset timezone conversion bug.
2023-07-04 18:22:13 +00:00
Alex Gaynor
0b78bb851e
Allow `#[new]` to return existing instances
...
fixes #2384
2023-07-02 19:57:53 -04:00
Adam Reichold
e006b34b5e
Apparently, PySet_Add does not steal a reference, hence we should not forget to clean up ours.
2023-07-02 20:43:43 +02:00
David Hewitt
135535e668
Merge pull request #3280 from davidhewitt/option-to-tz
...
clarify ownership of opt_to_pyobj helper function
2023-06-28 21:23:33 +00:00
Adam Reichold
afc1d4cc42
Merge pull request #3281 from davidhewitt/set-discard
...
handle exceptions properly in `PySet::discard`
2023-06-28 17:09:01 +00:00
David Hewitt
b7d391d994
clarify ownership of opt_to_pyobj helper function
2023-06-28 08:54:56 +01:00
David Hewitt
c0b9502c0e
handle exceptions properly in `PySet::discard`
2023-06-28 08:54:06 +01:00
David Hewitt
4867ef8dd3
stop suppressing unrelated exceptions in `PyAny::hasattr`
2023-06-27 23:20:22 +01:00
David Hewitt
20f909c97f
refactor `PyDict::get_item[_with_error]` implementations
2023-06-25 20:13:52 +01:00
David Hewitt
db91642bae
add `PyDict::get_item_with_error` for PyPy
2023-06-25 19:26:08 +01:00
Grant Slatton
b1e7ed8a58
Fix fixed offset timezone conversion bug.
...
See https://github.com/PyO3/pyo3/issues/3267
2023-06-25 11:06:46 -07:00
Adam Reichold
4afa994449
Mark Python::with_pool as safe on stable.
2023-06-21 09:12:10 +02:00
Adam Reichold
d7e147509b
Add Python::with_pool as a safer alternative to Python::new_pool.
2023-06-21 08:05:19 +02:00
mejrs
686f5eb0ad
Simplify doctests macro
2023-06-19 18:12:01 +02:00
Adam Reichold
5eed73f1c0
Rework pyobject_native_type_info! to expect callables
...
Most native types have static type objects which just need to be turned into a
pointer using addr_of_mut!, but sometimes like for exceptions we do call a
function which lazily initializes a type object.
This makes the pyobject_native_type_info! macro expect callable and passes it
the GIL token so that we do not need to call Python::assume_gil_acquired. The
case of static type objects is handled by the
pyobject_native_static_type_object! helper macro.
2023-06-19 10:30:03 +02:00
Adam Reichold
42bbd52e15
Keep the dynamic borrow checking enabled for debug builds.
2023-06-18 15:38:37 +02:00