Skip to content

Commit e6a4a71

Browse files
authored
PYTHON-5310 - Fix uri_parser AttributeError when used directly (#2283)
1 parent 3723edc commit e6a4a71

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

Diff for: doc/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Version 4.12.1 is a bug fix release.
99

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

1314
Issues Resolved
1415
...............

Diff for: pymongo/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@
105105
from pymongo.synchronous.mongo_client import MongoClient
106106
from pymongo.write_concern import WriteConcern
107107

108+
# Public module compatibility imports
109+
import pymongo.uri_parser # noqa: F401 # isort: skip
110+
108111
version = __version__
109112
"""Current version of PyMongo."""
110113

Diff for: test/test_default_exports.py

+7
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ def test_pymongo_imports(self):
209209
)
210210
from pymongo.write_concern import WriteConcern, validate_boolean
211211

212+
def test_pymongo_submodule_attributes(self):
213+
import pymongo
214+
215+
self.assertTrue(hasattr(pymongo, "uri_parser"))
216+
self.assertTrue(pymongo.uri_parser)
217+
self.assertTrue(pymongo.uri_parser.parse_uri)
218+
212219
def test_gridfs_imports(self):
213220
import gridfs
214221
from gridfs.errors import CorruptGridFile, FileExists, GridFSError, NoFile

0 commit comments

Comments
 (0)