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

Avoid exception when __frame_data["code_context"] is None #83

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

dschult
Copy link
Contributor

@dschult dschult commented Nov 27, 2023

As part of DelayedImportErrorModule, an exception message is created for ModuleNotFound. That message creation uses __frame_data including code_context. But it raises a secondary TypeError exception if fd["code_context'] is None.

This PR handles the case of no code_context by adding or "" to get fd["code_context"] or ""
See networkx/networkx#7062

I wasn't able to make a test for this easily because I don't know how to create some code for a test with code_context showing up as None. But this change is presumably harmless at worst and hopes to reduce confusion when a moduleNotFound error is raised for a DelayedImportErrorModule.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fbd805b) 93.95% compared to head (0ece17a) 93.95%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #83   +/-   ##
=======================================
  Coverage   93.95%   93.95%           
=======================================
  Files           4        4           
  Lines         182      182           
=======================================
  Hits          171      171           
  Misses         11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stefanv stefanv added the type: Bug fix Something isn't working label Jan 25, 2024
@stefanv stefanv merged commit bf82b68 into scientific-python:main Jan 25, 2024
27 of 28 checks passed
@stefanv
Copy link
Member

stefanv commented Jan 25, 2024

Thanks @dschult!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: Bug fix Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants