#2211: properly document the Morsel behavior changes.
Also deprecate the undocumented set argument instead of removing
it already in 3.5.
Initial patch by Demian Brecht.
diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py
index 98489fb..26c9ac4 100644
--- a/Lib/http/cookies.py
+++ b/Lib/http/cookies.py
@@ -366,7 +366,14 @@
def isReservedKey(self, K):
return K.lower() in self._reserved
- def set(self, key, val, coded_val):
+ def set(self, key, val, coded_val, LegalChars=_LegalChars):
+ if LegalChars != _LegalChars:
+ import warnings
+ warnings.warn(
+ 'LegalChars parameter is deprecated, ignored and will '
+ 'be removed in future versions.', DeprecationWarning,
+ stacklevel=2)
+
if key.lower() in self._reserved:
raise CookieError('Attempt to set a reserved key %r' % (key,))
if not _is_legal_key(key):
diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py
index 5f1e74b..cf0f6b9 100644
--- a/Lib/test/test_http_cookies.py
+++ b/Lib/test/test_http_cookies.py
@@ -261,6 +261,8 @@
morsel.value = ''
with self.assertWarnsRegex(DeprecationWarning, r'\bcoded_value\b'):
morsel.coded_value = ''
+ with self.assertWarnsRegex(DeprecationWarning, r'\bLegalChars\b'):
+ morsel.set('key', 'value', 'coded_value', LegalChars='.*')
def test_eq(self):
base_case = ('key', 'value', '"value"')