summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-01-13 07:23:15 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-01-13 07:23:15 (GMT)
commitcc283378d65e8294895eead78815f8cda15653f5 (patch)
treec1d6c0768a57d75807a35e24083c9b354339ef6d /Lib
parent009b0a1face9c16b608b3cd18df8c88632006ae1 (diff)
downloadcpython-cc283378d65e8294895eead78815f8cda15653f5.zip
cpython-cc283378d65e8294895eead78815f8cda15653f5.tar.gz
cpython-cc283378d65e8294895eead78815f8cda15653f5.tar.bz2
Issue #29192: Removed deprecated features in the http.cookies module.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/http/cookies.py30
-rw-r--r--Lib/test/test_http_cookies.py22
2 files changed, 8 insertions, 44 deletions
diff --git a/Lib/http/cookies.py b/Lib/http/cookies.py
index be3b080..7e0259e 100644
--- a/Lib/http/cookies.py
+++ b/Lib/http/cookies.py
@@ -138,12 +138,6 @@ _nulljoin = ''.join
_semispacejoin = '; '.join
_spacejoin = ' '.join
-def _warn_deprecated_setter(setter):
- import warnings
- msg = ('The .%s setter is deprecated. The attribute will be read-only in '
- 'future releases. Please use the set() method instead.' % setter)
- warnings.warn(msg, DeprecationWarning, stacklevel=3)
-
#
# Define an exception visible to External modules
#
@@ -303,29 +297,14 @@ class Morsel(dict):
def key(self):
return self._key
- @key.setter
- def key(self, key):
- _warn_deprecated_setter('key')
- self._key = key
-
@property
def value(self):
return self._value
- @value.setter
- def value(self, value):
- _warn_deprecated_setter('value')
- self._value = value
-
@property
def coded_value(self):
return self._coded_value
- @coded_value.setter
- def coded_value(self, coded_value):
- _warn_deprecated_setter('coded_value')
- self._coded_value = coded_value
-
def __setitem__(self, K, V):
K = K.lower()
if not K in self._reserved:
@@ -366,14 +345,7 @@ class Morsel(dict):
def isReservedKey(self, K):
return K.lower() in self._reserved
- 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)
-
+ def set(self, key, val, coded_val):
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 2432e0b..ca21476 100644
--- a/Lib/test/test_http_cookies.py
+++ b/Lib/test/test_http_cookies.py
@@ -9,15 +9,6 @@ import warnings
class CookieTests(unittest.TestCase):
- def setUp(self):
- self._warnings_manager = check_warnings()
- self._warnings_manager.__enter__()
- warnings.filterwarnings("ignore", ".* class is insecure.*",
- DeprecationWarning)
-
- def tearDown(self):
- self._warnings_manager.__exit__(None, None, None)
-
def test_basic(self):
cases = [
{'data': 'chips=ahoy; vienna=finger',
@@ -256,6 +247,9 @@ class MorselTests(unittest.TestCase):
# Check output and js_output.
M['path'] = '/foo' # Try a reserved key as well
M.set(i, "%s_val" % i, "%s_coded_val" % i)
+ self.assertEqual(M.key, i)
+ self.assertEqual(M.value, "%s_val" % i)
+ self.assertEqual(M.coded_value, "%s_coded_val" % i)
self.assertEqual(
M.output(),
"Set-Cookie: %s=%s; Path=/foo" % (i, "%s_coded_val" % i))
@@ -272,16 +266,14 @@ class MorselTests(unittest.TestCase):
self.assertRaises(cookies.CookieError,
M.set, i, '%s_value' % i, '%s_value' % i)
- def test_deprecation(self):
+ def test_set_properties(self):
morsel = cookies.Morsel()
- with self.assertWarnsRegex(DeprecationWarning, r'\bkey\b'):
+ with self.assertRaises(AttributeError):
morsel.key = ''
- with self.assertWarnsRegex(DeprecationWarning, r'\bvalue\b'):
+ with self.assertRaises(AttributeError):
morsel.value = ''
- with self.assertWarnsRegex(DeprecationWarning, r'\bcoded_value\b'):
+ with self.assertRaises(AttributeError):
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"')