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

Allow importing exceptions from nested modules #116

Merged
merged 1 commit into from Feb 21, 2018
Merged

Allow importing exceptions from nested modules #116

merged 1 commit into from Feb 21, 2018

Conversation

althonos
Copy link
Member

Some exceptions are not available in a top-level Python namespace (for instance exceptions defined in email.errors) but the current implementation of the import_exception macro didn't allow for dotted module names.

I added a macro to stringify a dotted path (dot_stringify!(a.b.c) => "a.b.c") and used to fix the import_exception macro. It's backward compatible with the current implementation.

As a test, I left the current test but added a test with MessageError exception from the email.errors module (which is available in the standard library of all Python version this library supports).

@althonos
Copy link
Member Author

I should probably add a little extra to the PyO3 guide as well.

@fafhrd91
Copy link
Contributor

looks good, but could you rebase against master

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@d50d1fb). Click here to learn what that means.
The diff coverage is 96.15%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #116   +/-   ##
=========================================
  Coverage          ?   80.91%           
=========================================
  Files             ?       81           
  Lines             ?     4961           
  Branches          ?        0           
=========================================
  Hits              ?     4014           
  Misses            ?      947           
  Partials          ?        0
Impacted Files Coverage Δ
src/typeob.rs 86.12% <ø> (ø)
src/lib.rs 100% <ø> (ø)
src/ffi3/objimpl.rs 0% <0%> (ø)
src/objectprotocol.rs 74.43% <100%> (ø)
src/objects/exc_impl.rs 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d50d1fb...cce9d0d. Read the comment docs.

@fafhrd91 fafhrd91 merged commit 995ec10 into PyO3:master Feb 21, 2018
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.

None yet

3 participants