Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete abi3 support #1152

Merged
merged 65 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4004620
Proof of concept of using PEP384s PyType_Spec
alex Sep 1, 2020
62a175e
Merge pull request #1132 from alex/abi3-class-creation
kngwyu Sep 5, 2020
d2a10b6
Introduce all-apis feature to support abi3
kngwyu Sep 5, 2020
c2f10e2
Restructure protcol-table initialization
kngwyu Sep 5, 2020
1941f4d
Rename all-apis with unstable-api
kngwyu Sep 6, 2020
e0f75f8
Fix missing PyGetSetDef_INIT and Adress clippy warnings
kngwyu Sep 6, 2020
4cd6d4c
Fixed a few compilation errors on the abi3 branch
alex Sep 6, 2020
3b61df2
Merge pull request #1161 from alex/abi3-fix-errors
kngwyu Sep 7, 2020
80e2497
Complete the process of disabling buffers with Py_LIMITED_API
alex Sep 7, 2020
71a7b1a
Properly mark a funtion as limited API only
alex Sep 7, 2020
4325a59
Merge pull request #1164 from alex/abi3-no-free-func
kngwyu Sep 8, 2020
e8936be
Merge pull request #1162 from alex/disable-buffer-more
kngwyu Sep 8, 2020
0709a02
Fill tp_dict on types in an abi3-friendly way
alex Sep 8, 2020
679326e
Merge pull request #1165 from alex/abi3-fill-dict
kngwyu Sep 8, 2020
117f60b
Make PyType::name abi3 compatible
alex Sep 8, 2020
a009c23
Merge pull request #1166 from alex/abi3-name
kngwyu Sep 9, 2020
d6c9435
Implement set iterators in terms of limited API
alex Sep 8, 2020
0bc2393
Merge pull request #1167 from alex/abi3-sets
davidhewitt Sep 9, 2020
7a4c5e2
Merge branch 'master' into abi3
kngwyu Sep 9, 2020
5bfb467
Merge branch 'master' into abi3-merge-master
alex Sep 10, 2020
4d5c208
fixes
alex Sep 10, 2020
3cb0b11
Update src/err/mod.rs
alex Sep 12, 2020
afc2d10
Merge pull request #1172 from alex/abi3-merge-master
kngwyu Sep 13, 2020
d0c2ebf
Remove finalizer code that was never reachable and switch field access
alex Sep 13, 2020
1b2d267
Make unicode handling abi3 friendly
alex Sep 15, 2020
517af8c
Merge pull request #1183 from alex/abi3-tp-finalizer
kngwyu Sep 15, 2020
2ec1c3b
Merge pull request #1187 from alex/abi3-to-str
kngwyu Sep 15, 2020
870914d
Make check warning clean in limited API mode
alex Sep 15, 2020
a2dc4c1
Merge pull request #1188 from alex/abi3-warnings
kngwyu Sep 16, 2020
ba10560
Get all the tests building, everythign except doctests passes!
alex Sep 15, 2020
c87a59c
Merge pull request #1189 from alex/abi3-tests-compile
kngwyu Sep 18, 2020
c07e1aa
Use abi3 feature, instead of unstable-api
kngwyu Sep 19, 2020
2a85c17
Run abi3 tests in CI
alex Sep 19, 2020
7644d67
Inhibit subclassing native types with ABI3 set
kngwyu Sep 19, 2020
9d85591
Hack __text_signature__ back to working with abi3
alex Sep 19, 2020
4862f56
Merge pull request #1202 from alex/patch-1
kngwyu Sep 19, 2020
869a5e2
Fix an abi3 ui test for the latest Rustc
kngwyu Sep 20, 2020
1985578
Don't compile extends=PyDict test in class.md with abi3
kngwyu Sep 20, 2020
e33e58f
Merge pull request #1201 from alex/abi3-text-signature
kngwyu Sep 20, 2020
d8c8c17
Link python3.lib instead of python3x.lib on Windows in abi3 mode
alex Sep 23, 2020
e615ce8
Start documenting abi3 support
alex Sep 20, 2020
c22dd6c
Remove symbols not available in abi3
alex Sep 23, 2020
0fde737
Merge pull request #1207 from alex/abi3-link-python3
kngwyu Sep 28, 2020
20a93ed
Merge pull request #1203 from alex/abi3-docs
davidhewitt Oct 9, 2020
140790b
Merge branch 'master' into abi3-merge-master
alex Oct 10, 2020
398369f
Fixed warning
alex Oct 10, 2020
d42dbda
Merge pull request #1220 from alex/abi3-merge-master
kngwyu Oct 10, 2020
877667a
Improved documentation
alex Oct 11, 2020
137196d
Merge pull request #1227 from alex/abi3-improvements
davidhewitt Oct 11, 2020
aabad7c
Assorted updates to the abi3 branch from review
alex Oct 11, 2020
0665c02
Merge pull request #1230 from alex/abi3-final
davidhewitt Oct 12, 2020
9e34835
Merge branch 'master' into abi3-merge-master
alex Oct 12, 2020
5060379
Fix changelog
alex Oct 12, 2020
2923b4d
Fix for MSRV
alex Oct 12, 2020
4298435
Merge pull request #1237 from alex/abi3-merge-master
davidhewitt Oct 12, 2020
ba6f0ec
Merge branch 'master' into abi3-merge-master
alex Oct 18, 2020
265db33
Fixes for PyIterator
alex Oct 18, 2020
781bb9f
Merge branch 'master' into abi3-merge-master
alex Oct 18, 2020
90a825d
Merge branch 'master' into abi3-merge-master
alex Oct 19, 2020
f74b649
Merge pull request #1245 from alex/abi3-merge-master
davidhewitt Oct 19, 2020
eb8ff15
Renew PyProtoMethods for new ABI3-based type construction
kngwyu Oct 17, 2020
6627658
Renew proc-macros for new `#[pyproto]` backend
kngwyu Oct 19, 2020
16ad3bf
Use TypedSlot as internal representation of ffi::PyType_Slot
kngwyu Oct 26, 2020
95bec25
Merge pull request #1254 from PyO3/abi3-new-proto
kngwyu Oct 27, 2020
eb0e6f6
Note the minimum required version of maturin supporting abi3
kngwyu Oct 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make PyType::name abi3 compatible
The implementation is more complex, because there's no equivalent to tp_name in the limited API
  • Loading branch information
alex committed Sep 8, 2020
commit 117f60bed0f906fed843455b3dd77aa03303fe5f
8 changes: 4 additions & 4 deletions guide/src/trait_bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ impl Model for UserModel {
.call_method("get_results", (), None)
.unwrap();

if py_result.get_type().name() != "list" {
panic!("Expected a list for the get_results() method signature, got {}", py_result.get_type().name());
if py_result.get_type().name().unwrap() != "list" {
panic!("Expected a list for the get_results() method signature, got {}", py_result.get_type().name().unwrap());
}
py_result.extract()
})
Expand Down Expand Up @@ -536,8 +536,8 @@ impl Model for UserModel {
.call_method("get_results", (), None)
.unwrap();

if py_result.get_type().name() != "list" {
panic!("Expected a list for the get_results() method signature, got {}", py_result.get_type().name());
if py_result.get_type().name().unwrap() != "list" {
panic!("Expected a list for the get_results() method signature, got {}", py_result.get_type().name().unwrap());
}
py_result.extract()
})
Expand Down
2 changes: 1 addition & 1 deletion pyo3-derive-backend/src/from_pyobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl<'a> Enum<'a> {
};
quote!(
#(#var_extracts)*
let type_name = obj.get_type().name();
let type_name = obj.get_type().name()?;
let from = obj
.repr()
.map(|s| format!("{} ({})", s.to_string_lossy(), type_name))
Expand Down
11 changes: 7 additions & 4 deletions src/err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,13 @@ impl<'a> std::fmt::Display for PyDowncastError<'a> {
write!(
f,
"Can't convert {} to {}",
self.from
.repr()
.map(|s| s.to_string_lossy())
.unwrap_or_else(|_| self.from.get_type().name()),
self.from.repr().map(|s| s.to_string_lossy()).or_else(|_| {
self.from
.get_type()
.name()
.map_err(|_| std::fmt::Error)
.map(|s| s.into())
})?,
self.to
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ macro_rules! impl_exception_boilerplate {

impl std::fmt::Debug for $name {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let type_name = self.get_type().name();
f.debug_struct(&*type_name)
let type_name = self.get_type().name().map_err(|_| std::fmt::Error)?;
f.debug_struct(type_name)
// TODO: print out actual fields!
.finish()
}
}

impl std::fmt::Display for $name {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
let type_name = self.get_type().name();
let type_name = self.get_type().name().map_err(|_| std::fmt::Error)?;
write!(f, "{}", type_name)?;
if let Ok(s) = self.str() {
write!(f, ": {}", &s.to_string_lossy())
Expand Down
6 changes: 2 additions & 4 deletions src/types/typeobject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ use crate::err::{PyErr, PyResult};
use crate::instance::PyNativeType;
use crate::type_object::PyTypeObject;
use crate::{ffi, AsPyPointer, PyAny, Python};
use std::borrow::Cow;
use std::ffi::CStr;

/// Represents a reference to a Python `type object`.
#[repr(transparent)]
Expand Down Expand Up @@ -39,8 +37,8 @@ impl PyType {
}

/// Gets the name of the `PyType`.
pub fn name(&self) -> Cow<str> {
unsafe { CStr::from_ptr((*self.as_type_ptr()).tp_name).to_string_lossy() }
pub fn name(&self) -> PyResult<&str> {
self.getattr("__qualname__")?.extract()
}

/// Checks whether `self` is subclass of type `T`.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl ClassMethod {
#[classmethod]
/// Test class method.
fn method(cls: &PyType) -> PyResult<String> {
Ok(format!("{}.method()!", cls.name()))
Ok(format!("{}.method()!", cls.name()?))
}
}

Expand Down Expand Up @@ -104,7 +104,7 @@ struct ClassMethodWithArgs {}
impl ClassMethodWithArgs {
#[classmethod]
fn method(cls: &PyType, input: &PyString) -> PyResult<String> {
Ok(format!("{}.method({})", cls.name(), input))
Ok(format!("{}.method({})", cls.name()?, input))
}
}

Expand Down