Icxolu
4f8ee96881
fix `AsRef` and `Deref` impls on `Bound<T>` ( #3879 )
...
* fix `AsRef` and `Deref` of `Bound<T>` to `Bound<PyAny>`
* cleanup unnessesary `.as_any()` calls
* remove trait bound on `AsRef` impl
* add comment for `Deref` trait bound
* rename marker trait
2024-02-22 22:38:42 +00:00
David Hewitt
9e74c858c2
add `PyModule::new_bound` and `PyModule::import_bound` ( #3775 )
...
* add `PyModule::new` and `PyModule::import_bound`
* review: Icxolu feedback
2024-02-22 09:35:47 +00:00
Icxolu
61bc02d927
deprecate `PyCell::new` in favor of `Py::new` or `Bound::new` ( #3872 )
...
* deprecate `PyCell::new` in favor of `Py::new` or `Bound::new`
* update deprecation warning
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-20 07:45:47 +00:00
David Hewitt
4efc4b82a3
ci: fix redundant import warnings on nightly ( #3873 )
2024-02-19 22:07:05 +00:00
Icxolu
4ce9c35983
port `Python::get_type` to `Bound` API ( #3846 )
...
* port `Python::get_type` to `Bound` API
* fix `is_subclass_and_is_instance` FIXME
2024-02-18 18:27:19 +00:00
Lily Foote
0dd568d397
Use the new bound API instead of .as_ref(py) ( #3853 )
...
* Use the new bound API instead of .as_ref(py)
* Move import into a nested scope
* Use to_cow instead of to_str for compatibility
`to_str` is not available before Python 3.10 on the limited api.
* Relax &self lifetimes
* Use Bound<'py, PyAny> in test Mapping signatures
* Use .as_bytes(py)
* Simplify ThrowCallback::throw signature
* Avoid .as_any call with Py api instead of Bound
2024-02-18 00:09:56 +00:00
Icxolu
e45fbe493c
port `IntoPyDict` to `Bound` API
2024-02-10 15:47:26 +01:00
Icxolu
4d423b0c67
port `Python::run` to `Bound` API
2024-02-09 22:09:16 +01:00
Icxolu
33dc33ecec
port `Python::eval` to `Bound` API
2024-02-09 17:52:00 +01:00
David Hewitt
7d486bb72a
tests/common.rs -> src/tests/common.rs
2023-09-24 13:34:53 +01:00
David Hewitt
a15614844d
add PyErr::display
2023-07-24 22:14:55 +01:00
David Hewitt
248230b8e4
refactor PyAny::is_instance_of for performance
2023-05-18 22:25:27 +01:00
David Hewitt
00ddd21535
change PyModule::add_class to return an error if class creation fails
2023-02-14 22:08:35 +00:00
Georg Brandl
99c8dea30e
Use Python::get_type() instead of PyTypeInfo::type_object()
...
The former needs one less import and uses a familiar object.
2022-11-20 15:16:18 +01:00
Georg Brandl
2a630a2a52
Fix being able to call arg-less `#[new]` with any args from Python
...
Fixes #2748
2022-11-20 08:25:19 +01:00
mejrs
984fdf57c7
Use Python:;with_gil in tests
2022-07-19 19:34:23 +02:00
David Hewitt
cdf86482d8
ffi: many fixes to pypy definitions
2022-06-04 12:47:40 +01:00
David Hewitt
7e2d3117ce
cleanup: deprecate PyTypeObject trait
2022-04-23 13:36:32 +01:00
David Hewitt
6433d884fc
dev: remove self dev dependency
2021-12-08 07:48:58 +00:00
Georg Brandl
43893158b1
switch is_instance/is_instance_of, is_subclass/is_subclass_of
2021-11-20 13:18:43 +00:00
Georg Brandl
a83c31a3af
add PyType::is_subclass_of and PyAny::is_instance_of
...
which get the type to check against as an arguments,
as opposed to a compile-time generic type.
2021-11-20 13:16:15 +00:00
David Hewitt
f916867375
pyclass: refactor initialization, call native type dealloc
2021-06-23 07:45:51 +01:00
David Hewitt
d011467e63
pyclass: allow `#[pyo3(get, set, name = "foo")]`
2021-06-04 11:30:40 +01:00
David Hewitt
d81abe8344
pyclass: support extending Exception types
2021-05-04 22:00:22 +01:00
David Hewitt
b92441cd7c
pyclass: fix reference count issue in subclass new
2021-01-08 00:13:49 +00:00
David Hewitt
45599620b5
pyerr: improve debug & display impls
2020-11-15 16:22:45 +00:00
kngwyu
7644d67ad8
Inhibit subclassing native types with ABI3 set
2020-09-20 00:42:55 +09:00
Alex Gaynor
ba1056006a
Get all the tests building, everythign except doctests passes!
2020-09-16 08:42:22 -04:00
Alex Gaynor
400462063d
Proof of concept of using PEP384s PyType_Spec
2020-09-02 16:54:39 -04:00
David Hewitt
4ed9748b45
Rename exceptions to PyException etc; reintroduce deprecated ones
2020-07-18 06:02:57 +01:00
David Hewitt
a7e0c6bfa7
Make exceptions proper native types.
2020-07-18 01:57:39 +01:00
kngwyu
02ee7a5afc
Expose PyAny to lib.rs and prelude
2020-03-18 13:38:18 +09:00
kngwyu
1f5cb83ef8
Add tests for mutability checking
2020-02-18 15:28:04 +09:00
kngwyu
8f8b42591a
Fix PySelf and AsPyRef
2020-02-16 23:54:55 +09:00
kngwyu
a2408cacbb
Rename PyClassShell with PyCell
2020-02-08 15:05:13 +09:00
Alexander Niederbühl
0a84c201f7
Revert "Disable segfaulty subclassing by default"
...
This reverts commit 5096f936dc
.
2020-01-12 01:22:32 +01:00
kngwyu
c57177a169
Refine tests and documents around pyclass.rs
2020-01-08 22:44:50 +09:00
kngwyu
b602b4bf6c
Enhance documentation and tests around #[new]
2020-01-07 12:49:36 +09:00
kngwyu
18e565fab5
New PyClassInitializer
2020-01-05 16:01:05 +09:00
kngwyu
ea51756933
Resolve some clippy complains
2019-12-23 18:05:06 +09:00
kngwyu
e2dc843de5
Fix a corner case for PyClassInitializer
2019-12-22 23:54:41 +09:00
kngwyu
6b84401126
Make it enable to safely inherit native types
2019-12-21 23:28:55 +09: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
konstin
5096f936dc
Disable segfaulty subclassing by default
...
See https://github.com/PyO3/pyo3/issues/220 and https://github.com/PyO3/pyo3/issues/407 for details on those segfaults
2019-08-05 11:52:47 +02:00
kngwyu
0f9a3b1194
Expose py_run macro
2019-06-13 18:18:06 +09:00
Miles Granger
711155d7ad
Update tests & docs with IntoPyDict::into_py_dict(py)
2019-03-20 20:04:00 +01:00
konstin
6cd07c369c
Simpler new and clippy fixes
2019-02-23 18:38:00 +01:00
konstin
ad590bd158
Some api improvements
2019-02-23 18:01:22 +01:00
konstin
d02f7c3aa5
Big proc macro refactoring
...
* Removed a lot of clutter, unified some code
* Started using syn::parse::Parse for pyfunction attributes
* No more newlines between imports
* Renamed `#[prop(get, set)]` to `#[pyo3(get, set)]`
* `#[pyfunction]` now supports the same arguments as `#[pyfn()]`
* Some macros now emit proper spanned errors instead of panics.
2019-02-18 20:07:56 +01:00