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

Add error messages for unsupported macro features on compilation #4194

Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ffa283f
First implementation
cojmeister Mar 23, 2024
61c488f
tweak error message wording
codeguru42 May 20, 2024
2dda39c
Fix boolean logic
codeguru42 May 20, 2024
f1f3efb
Remove redundant parens
codeguru42 May 20, 2024
e4719c3
Add test for weakref error
codeguru42 May 20, 2024
0e25b7c
Fix test
codeguru42 May 20, 2024
36b28d2
Reword error message
codeguru42 May 20, 2024
bfa8cb6
Add expected error output
codeguru42 May 20, 2024
219202f
Rinse and repeat for `dict`
codeguru42 May 20, 2024
03c2cdc
Add test output file
codeguru42 May 20, 2024
2df737c
Ignore Rust Rover config files
codeguru42 May 20, 2024
08891c9
cargo fmt
codeguru42 May 20, 2024
af3d93d
Add newsfragment
codeguru42 May 20, 2024
e22a51a
Update newsfragments/4194.added.md
codeguru42 May 22, 2024
aaf6fa7
Use ensure_spanned! macro
codeguru42 May 22, 2024
0336aeb
Use ensure_spanned! macro for weakref error, too
codeguru42 May 22, 2024
c5dcad8
Revert "Ignore Rust Rover config files"
codeguru42 May 22, 2024
6e83437
Update wording for error message
codeguru42 May 25, 2024
490cee4
Update weakref error message, too
codeguru42 May 25, 2024
9fb5196
Refactor constant to a pyversions module
codeguru42 May 25, 2024
5253cf4
Fix compiler errors
codeguru42 May 25, 2024
a2a9452
Another wording update
codeguru42 May 26, 2024
77a9101
And make weakref wording the same
codeguru42 May 26, 2024
28cbbc6
Fix compiler error due to using weakref in our own code
codeguru42 May 26, 2024
abd1075
Merge remote-tracking branch 'refs/remotes/upstream/main' into add-er…
codeguru42 Jun 4, 2024
680f471
Fix after merge
codeguru42 Jun 4, 2024
4fbbe98
apply conditional pyclass
davidhewitt Jun 6, 2024
7177d53
update conditional compilation in tests
davidhewitt Jun 6, 2024
3c7e898
Merge remote-tracking branch 'refs/remotes/upstream/main' into add-er…
codeguru42 Jun 16, 2024
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
Fix boolean logic
  • Loading branch information
codeguru42 committed May 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2dda39cf876de39a00146097dbe884d83460c3c7
27 changes: 14 additions & 13 deletions pyo3-macros-backend/src/pyclass.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
use std::borrow::Cow;

use proc_macro2::{Ident, Span, TokenStream};
use quote::{format_ident, quote};
use syn::{parse_quote, Result, spanned::Spanned, Token};
use syn::ext::IdentExt;
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;

use pyo3_build_config::PythonVersion;

use crate::attributes::{self, CrateAttribute, ExtendsAttribute, FreelistAttribute, kw, ModuleAttribute, NameAttribute, NameLitStr, RenameAllAttribute, take_pyo3_options};
use crate::attributes::kw::frozen;
use crate::attributes::{self, kw, take_pyo3_options, CrateAttribute, ExtendsAttribute, FreelistAttribute, ModuleAttribute, NameAttribute, NameLitStr, RenameAllAttribute, get_pyo3_options};
use crate::deprecations::Deprecations;
use crate::konst::{ConstAttributes, ConstSpec};
use crate::method::{FnArg, FnSpec, PyArg, RegularArg};
use crate::pyfunction::ConstructorAttribute;
use crate::PyFunctionOptions;
use crate::pyimpl::{gen_py_const, PyClassMethodsType};
use crate::pymethod::{
impl_py_getter_def, impl_py_setter_def, MethodAndMethodDef, MethodAndSlotDef, PropertyType,
SlotDef, __GETITEM__, __INT__, __LEN__, __REPR__, __RICHCMP__,
__GETITEM__, __INT__, __LEN__, __REPR__, __RICHCMP__,
impl_py_getter_def, impl_py_setter_def, MethodAndMethodDef, MethodAndSlotDef, PropertyType, SlotDef,
};
use crate::utils::{Ctx, is_abi3};
use crate::utils::{self, apply_renaming_rule, PythonDoc};
use crate::PyFunctionOptions;
use proc_macro2::{Ident, Span, TokenStream};
use quote::{format_ident, quote};
use syn::ext::IdentExt;
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::{parse_quote, spanned::Spanned, Result, Token};
use pyo3_build_config::PythonVersion;


const PY_3_9: PythonVersion = PythonVersion {
major: 3,
@@ -185,7 +186,7 @@ impl PyClassPyO3Options {
PyClassPyO3Option::Subclass(subclass) => set_option!(subclass),
PyClassPyO3Option::Unsendable(unsendable) => set_option!(unsendable),
PyClassPyO3Option::Weakref(weakref) => {
if is_abi3() && python_version >= PY_3_9 {
if python_version >= PY_3_9 || !is_abi3() {
set_option!(weakref);
} else {
return Err(syn::Error::new((weakref.span()), "`weakref` requires >= python 3.9",));