Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Version 4.12.1 is a bug fix release.

- Fixed a bug that could raise ``UnboundLocalError`` when creating asynchronous connections over SSL.
- Fixed a bug causing SRV hostname validation to fail when resolver and resolved hostnames are identical with three domain levels.
- Fixed a bug that caused direct use of ``pymongo.uri_parser`` to raise an ``AttributeError``.

Issues Resolved
...............
Expand Down
1 change: 1 addition & 0 deletions pymongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__.

]

ASCENDING = 1
Expand Down
9 changes: 8 additions & 1 deletion test/test_default_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"ConfigurationError",
"WriteConcern",
]
PYMONGO_IGNORE = []
PYMONGO_IGNORE = ["uri_parser"]
GLOBAL_INGORE = ["TYPE_CHECKING", "annotations"]


Expand Down Expand Up @@ -209,6 +209,13 @@ def test_pymongo_imports(self):
)
from pymongo.write_concern import WriteConcern, validate_boolean

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.

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

def test_gridfs_imports(self):
import gridfs
from gridfs.errors import CorruptGridFile, FileExists, GridFSError, NoFile
Expand Down
Loading