diff --git a/doc/changelog.rst b/doc/changelog.rst index e82804565f..597f75f873 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -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 ............... diff --git a/pymongo/__init__.py b/pymongo/__init__.py index e392508912..9a35750811 100644 --- a/pymongo/__init__.py +++ b/pymongo/__init__.py @@ -105,6 +105,9 @@ from pymongo.synchronous.mongo_client import MongoClient from pymongo.write_concern import WriteConcern +# Public module compatibility imports +import pymongo.uri_parser # noqa: F401 # isort: skip + version = __version__ """Current version of PyMongo.""" diff --git a/test/test_default_exports.py b/test/test_default_exports.py index d9301d2223..5f3e749d36 100644 --- a/test/test_default_exports.py +++ b/test/test_default_exports.py @@ -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")) + 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