diff options
-rw-r--r-- | Lib/test/test_urllib2.py | 13 | ||||
-rw-r--r-- | Lib/urllib/request.py | 2 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
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) @@ -1341,6 +1341,7 @@ Steven Work Gordon Worley Darren Worrall Thomas Wouters +Daniel Wozniak Heiko Wundram Doug Wyatt Robert Xiao @@ -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. |