summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_urllib2.py13
-rw-r--r--Lib/urllib/request.py2
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
4 files changed, 16 insertions, 3 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 3e19ecf..0e05723 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -1488,11 +1488,20 @@ class RequestTests(unittest.TestCase):
# if we change data we need to remove content-length header
# (cause it's most probably calculated for previous value)
def test_setting_data_should_remove_content_length(self):
- self.assertFalse("Content-length" in self.get.unredirected_hdrs)
+ self.assertNotIn("Content-length", self.get.unredirected_hdrs)
self.get.add_unredirected_header("Content-length", 42)
self.assertEqual(42, self.get.unredirected_hdrs["Content-length"])
self.get.data = "spam"
- self.assertFalse("Content-length" in self.get.unredirected_hdrs)
+ self.assertNotIn("Content-length", self.get.unredirected_hdrs)
+
+ # issue 17485 same for deleting data.
+ def test_deleting_data_should_remove_content_length(self):
+ self.assertNotIn("Content-length", self.get.unredirected_hdrs)
+ self.get.data = 'foo'
+ self.get.add_unredirected_header("Content-length", 3)
+ self.assertEqual(3, self.get.unredirected_hdrs["Content-length"])
+ del self.get.data
+ self.assertNotIn("Content-length", self.get.unredirected_hdrs)
def test_get_full_url(self):
self.assertEqual("http://www.python.org/~jeremy/",
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 90731cb..8b3cdf9 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -296,7 +296,7 @@ class Request:
@data.deleter
def data(self):
- self._data = None
+ self.data = None
def _parse(self):
self.type, rest = splittype(self.full_url)
diff --git a/Misc/ACKS b/Misc/ACKS
index 600e0bf..21f2cd5 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1341,6 +1341,7 @@ Steven Work
Gordon Worley
Darren Worrall
Thomas Wouters
+Daniel Wozniak
Heiko Wundram
Doug Wyatt
Robert Xiao
diff --git a/Misc/NEWS b/Misc/NEWS
index e7c59b1..8e46c60 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -292,6 +292,9 @@ Core and Builtins
Library
-------
+- Issue #17485: Also delete the Request Content-Length header if the data
+ attribute is deleted. (Follow on to issue 16464).
+
- Issue #15927: CVS now correctly parses escaped newlines and carriage
when parsing with quoting turned off.