Skip to content

PYTHON-5310 - Fix uri_parser AttributeError when used directly #2283

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
Apr 15, 2025

Conversation

NoahStapp
Copy link
Contributor

No description provided.

def test_pymongo_submodule_attributes(self):
import pymongo

self.assertTrue(hasattr(pymongo, "uri_parser"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this test fail before this fix? Also can we add:

        self.assertTrue(pymongo.uri_parser)
        self.assertTrue(pymongo.uri_parser.parse_uri))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this assertion fails before this fix.

@@ -45,6 +45,7 @@
"WriteConcern",
"has_c",
"timeout",
"uri_parser",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried about unintentional side effects of including it in __all__.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, we don't actually need to include uri_parser in __all__.

@NoahStapp NoahStapp merged commit e6a4a71 into mongodb:master Apr 15, 2025
42 of 46 checks passed
ShaneHarvey pushed a commit to ShaneHarvey/mongo-python-driver that referenced this pull request Apr 22, 2025
ShaneHarvey added a commit that referenced this pull request Apr 23, 2025
…2283) (#2302)

Co-authored-by: Noah Stapp <noah.stapp@mongodb.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants