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

Fix import pthonjsonlogger.jsonlogger #33

Merged
merged 10 commits into from
Dec 16, 2024
Merged

Conversation

nhairs
Copy link
Owner

@nhairs nhairs commented Dec 13, 2024

Fixes: #29

Although efforts were made for backwards compatibility using __getattr__ in pythonjsonlogger/__init__.py, this only worked if you were doing from pythonjsonlogger import jsonlogger. When importing by the full name import pythonjsonlogger.jsonlogger it it would fail to locate the module file and thus not be able to produce a module spec which then of course causes the import to fail.

We get around this by actually having a module that imports the names it needs from the new locations.

Test Plan

  • Run unit tests

Fixes: #29

Although efforts were made for backwards compatibility using
`__getattr__` in `pythonjsonlogger/__init__.py`, this only worked
if you were doing `from pythonjsonlogger import jsonlogger`. When
importing by the full name `import pythonjsonlogger.jsonlogger` it
it would fail to locate the module file and thus not be able to
produce a module spec which then of course causes the import to fail.

We get around this by actually having a module that imports the names
it needs from the new locations.
@nhairs nhairs linked an issue Dec 16, 2024 that may be closed by this pull request
@nhairs nhairs merged commit e7761e5 into main Dec 16, 2024
28 checks passed
@nhairs nhairs deleted the nhairs-jsonlogger-import branch December 16, 2024 06:46
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.

PyPI README refers to PEP 541 request that is no longer relevant Cannot import pythonjsonlogger.jsonlogger
1 participant