Skip to content

add import_exception_bound! macro#4027

Merged
davidhewitt merged 2 commits intoPyO3:mainfrom
davidhewitt:import-exception
Mar 31, 2024
Merged

add import_exception_bound! macro#4027
davidhewitt merged 2 commits intoPyO3:mainfrom
davidhewitt:import-exception

Conversation

@davidhewitt
Copy link
Copy Markdown
Member

For #3989

The idea here is that this macro implements only the traits needed to use an imported exception inside a Bound (and not as a GIL Ref). This should help with coverage.

cc @alex - want to give this a try?

@alex
Copy link
Copy Markdown
Member

alex commented Mar 30, 2024

I think there's a syntax error or something somewhere:

   Compiling cryptography-rust v0.1.0 (/Users/alex_gaynor/projects/cryptography/src/rust)
error: expected one of `!` or `[`, found `module`
   --> src/exceptions.rs:26:1
    |
26  | pyo3::import_exception_bound!(cryptography.exceptions, AlreadyUpdated);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected one of `!` or `[`
    |
   ::: /Users/alex_gaynor/.cargo/git/checkouts/pyo3-8f6c8fc902a366fa/33371a4/src/types/mod.rs:233:34
    |
233 |     ($name:ty, $typeobject:expr, $module:expr $(, #checkfunction=$checkfunction:path)? $(;$generics:ident)*) => {
    |                                  ------------ while parsing argument for this `expr` macro fragment
    |
    = note: this error originates in the macro `pyo3::import_exception_bound` (in Nightly builds, run with -Z macro-backtrace for more info)

@davidhewitt
Copy link
Copy Markdown
Member Author

Ugh, sorry, force-pushed and actually moved some tests over to it now 🤦

@alex
Copy link
Copy Markdown
Member

alex commented Mar 30, 2024

Ok, local check looks good, pushing to CI for coverage.

@alex
Copy link
Copy Markdown
Member

alex commented Mar 30, 2024

Yeah, looks green pyca/cryptography#10671

Comment thread src/impl_/exceptions.rs
@davidhewitt
Copy link
Copy Markdown
Member Author

Great!

@davidhewitt davidhewitt marked this pull request as ready for review March 31, 2024 19:36
@davidhewitt davidhewitt enabled auto-merge March 31, 2024 19:44
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 31, 2024

CodSpeed Performance Report

Merging #4027 will improve performances by 24.29%

Comparing davidhewitt:import-exception (5ce07c3) with main (22e8dd1)

Summary

⚡ 1 improvements
✅ 71 untouched benchmarks

Benchmarks breakdown

Benchmark main davidhewitt:import-exception Change
drop_many_objects 68.6 µs 55.2 µs +24.29%

@davidhewitt davidhewitt added this pull request to the merge queue Mar 31, 2024
Merged via the queue into PyO3:main with commit 336b1c9 Mar 31, 2024
@davidhewitt davidhewitt deleted the import-exception branch March 31, 2024 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants