Skip to content

Commit 9055bb0

Browse files
PYTHON-2702 Remove deprecated URI options (#710)
1 parent b3118e0 commit 9055bb0

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed

doc/migrate-to-pymongo4.rst

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,34 @@ The old option names and their renamed equivalents are summarized in the table
8989
below. Some renamed options have different semantics from the option being
9090
replaced as noted in the 'Migration Notes' column.
9191

92-
+--------------------+-------------------------------+-------------------------------------------------------------+
93-
| Old URI Option | Renamed URI Option | Migration Notes |
94-
+====================+===============================+=============================================================+
95-
| ssl_pem_passphrase | tlsCertificateKeyFilePassword | - |
96-
+--------------------+-------------------------------+-------------------------------------------------------------+
97-
| ssl_ca_certs | tlsCAFile | - |
98-
+--------------------+-------------------------------+-------------------------------------------------------------+
99-
| ssl_crlfile | tlsCRLFile | - |
100-
+--------------------+-------------------------------+-------------------------------------------------------------+
101-
| ssl_match_hostname | tlsAllowInvalidHostnames | ``ssl_match_hostname=True`` is equivalent to |
102-
| | | ``tlsAllowInvalidHostnames=False`` and vice-versa. |
103-
+--------------------+-------------------------------+-------------------------------------------------------------+
104-
| ssl_cert_reqs | tlsAllowInvalidCertificates | Instead of ``ssl.CERT_NONE``, ``ssl.CERT_OPTIONAL`` |
105-
| | | and ``ssl.CERT_REQUIRED``, ``tlsAllowInvalidCertificates`` |
106-
| | | expects a boolean value - ``True`` is equivalent to |
107-
| | | ``ssl.CERT_NONE``, while ``False`` is equivalent to |
108-
| | | ``ssl.CERT_REQUIRED``. |
109-
+--------------------+-------------------------------+-------------------------------------------------------------+
110-
| ssl_certfile | tlsCertificateKeyFile | Instead of using ``ssl_certfile`` and ``ssl_keyfile`` |
111-
| | | to specify the certificate and private key files, |
112-
+--------------------+ | ``tlsCertificateKeyFile`` expects a single file containing |
113-
| ssl_keyfile | | both the client certificate and the private key. |
114-
+--------------------+-------------------------------+-------------------------------------------------------------+
92+
+--------------------+-------------------------------+--------------------------------------------------------+
93+
| Old URI Option | Renamed URI Option | Migration Notes |
94+
+====================+===============================+========================================================+
95+
| ssl_pem_passphrase | tlsCertificateKeyFilePassword | - |
96+
+--------------------+-------------------------------+--------------------------------------------------------+
97+
| ssl_ca_certs | tlsCAFile | - |
98+
+--------------------+-------------------------------+--------------------------------------------------------+
99+
| ssl_crlfile | tlsCRLFile | - |
100+
+--------------------+-------------------------------+--------------------------------------------------------+
101+
| ssl_match_hostname | tlsAllowInvalidHostnames | ``ssl_match_hostname=True`` is equivalent to |
102+
| | | ``tlsAllowInvalidHostnames=False`` and vice-versa. |
103+
+--------------------+-------------------------------+--------------------------------------------------------+
104+
| ssl_cert_reqs | tlsAllowInvalidCertificates | Instead of ``ssl.CERT_NONE``, ``ssl.CERT_OPTIONAL`` |
105+
| | | and ``ssl.CERT_REQUIRED``, the new option expects |
106+
| | | a boolean value - ``True`` is equivalent to |
107+
| | | ``ssl.CERT_NONE``, while ``False`` is equivalent to |
108+
| | | ``ssl.CERT_REQUIRED``. |
109+
+--------------------+-------------------------------+--------------------------------------------------------+
110+
| ssl_certfile | tlsCertificateKeyFile | Instead of using ``ssl_certfile`` and ``ssl_keyfile`` |
111+
| | | to specify the certificate and private key files |
112+
+--------------------+ | respectively, use ``tlsCertificateKeyFile`` to pass |
113+
| ssl_keyfile | | a single file containing both the client certificate |
114+
| | | and the private key. |
115+
+--------------------+-------------------------------+--------------------------------------------------------+
116+
| j | journal | - |
117+
+--------------------+-------------------------------+--------------------------------------------------------+
118+
| wtimeout | wTimeoutMS | - |
119+
+--------------------+-------------------------------+--------------------------------------------------------+
115120

116121
MongoClient.fsync is removed
117122
............................

pymongo/common.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,6 @@ def validate_tzinfo(dummy, value):
585585
# Dictionary where keys are the names of public URI options, and values
586586
# are lists of aliases for that option.
587587
URI_OPTIONS_ALIAS_MAP = {
588-
'journal': ['j'],
589-
'wtimeoutms': ['wtimeout'],
590588
'tls': ['ssl'],
591589
}
592590

@@ -666,8 +664,6 @@ def validate_tzinfo(dummy, value):
666664
# variant need not be included here. Options whose public and internal
667665
# names are the same need not be included here.
668666
INTERNAL_URI_OPTION_NAME_MAP = {
669-
'j': 'journal',
670-
'wtimeout': 'wtimeoutms',
671667
'ssl': 'tls',
672668
}
673669

@@ -681,8 +677,8 @@ def validate_tzinfo(dummy, value):
681677
# preserved for renamed options as they are part of user warnings.
682678
# - 'removed': <message> may suggest the rationale for deprecating the
683679
# option and/or recommend remedial action.
684-
'j': ('renamed', 'journal'),
685-
'wtimeout': ('renamed', 'wTimeoutMS'),
680+
# For example:
681+
# 'wtimeout': ('renamed', 'wTimeoutMS'),
686682
}
687683

688684
# Augment the option validator map with pymongo-specific option information.

test/test_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_write_concern(self):
110110
c = rs_or_single_client(connect=False)
111111
self.assertEqual(WriteConcern(), c.write_concern)
112112

113-
c = rs_or_single_client(connect=False, w=2, wtimeout=1000)
113+
c = rs_or_single_client(connect=False, w=2, wTimeoutMS=1000)
114114
wc = WriteConcern(w=2, wtimeout=1000)
115115
self.assertEqual(wc, c.write_concern)
116116

test/test_uri_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ def test_tlsinsecure_simple(self):
476476

477477
def test_normalize_options(self):
478478
# check that options are converted to their internal names correctly.
479-
uri = ("mongodb://example.com/?ssl=true&appname=myapp&wtimeout=10")
480-
res = {"tls": True, "appname": "myapp", "wtimeoutms": 10}
479+
uri = ("mongodb://example.com/?ssl=true&appname=myapp")
480+
res = {"tls": True, "appname": "myapp"}
481481
self.assertEqual(res, parse_uri(uri)["options"])
482482

483483
def test_unquote_after_parsing(self):

0 commit comments

Comments
 (0)