[Python-checkins] cpython: #17485: Delete the Content-Length header if the data attribute is deleted.
r.david.murray
python-checkins at python.org
Wed Mar 20 05:16:00 CET 2013
http://hg.python.org/cpython/rev/b1579eb4e1bc
changeset: 82820:b1579eb4e1bc
user: R David Murray <rdmurray at bitdance.com>
date: Wed Mar 20 00:10:51 2013 -0400
summary:
#17485: Delete the Content-Length header if the data attribute is deleted.
This is a follow on to issue 16464. Original patch by Daniel Wozniak.
files:
Lib/test/test_urllib2.py | 13 +++++++++++--
Lib/urllib/request.py | 2 +-
Misc/ACKS | 1 +
Misc/NEWS | 3 +++
4 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -1488,11 +1488,20 @@
# 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
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -296,7 +296,7 @@
@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
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1341,6 +1341,7 @@
Gordon Worley
Darren Worrall
Thomas Wouters
+Daniel Wozniak
Heiko Wundram
Doug Wyatt
Robert Xiao
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -292,6 +292,9 @@
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.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list