PYTHON-5310 - Fix uri_parser AttributeError when used directly#2283
Merged
NoahStapp merged 5 commits intomongodb:masterfrom Apr 15, 2025
Merged
PYTHON-5310 - Fix uri_parser AttributeError when used directly#2283NoahStapp merged 5 commits intomongodb:masterfrom
NoahStapp merged 5 commits intomongodb:masterfrom
Conversation
ShaneHarvey
requested changes
Apr 14, 2025
| def test_pymongo_submodule_attributes(self): | ||
| import pymongo | ||
|
|
||
| self.assertTrue(hasattr(pymongo, "uri_parser")) |
Member
There was a problem hiding this comment.
Does this test fail before this fix? Also can we add:
self.assertTrue(pymongo.uri_parser)
self.assertTrue(pymongo.uri_parser.parse_uri))
Contributor
Author
There was a problem hiding this comment.
Yes, this assertion fails before this fix.
ShaneHarvey
requested changes
Apr 14, 2025
pymongo/__init__.py
Outdated
| "WriteConcern", | ||
| "has_c", | ||
| "timeout", | ||
| "uri_parser", |
Member
There was a problem hiding this comment.
Is this the right fix? Back in 4.7 uri_parser wasn't part of __all__ and this bug didn't exist. Perhaps we shouldn't include uri_parser here and instead we should import pymongo.uri_parser like we did before.
Member
There was a problem hiding this comment.
I'm worried about unintentional side effects of including it in __all__.
Contributor
Author
There was a problem hiding this comment.
Good catch, we don't actually need to include uri_parser in __all__.
ShaneHarvey
approved these changes
Apr 14, 2025
ShaneHarvey
pushed a commit
to ShaneHarvey/mongo-python-driver
that referenced
this pull request
Apr 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.