changeset: 96756:08fad9037206 parent: 96752:dbb4fb46fc1d parent: 96755:1692065524cc user: Lars Gustäbel date: Thu Jul 02 19:42:09 2015 +0200 files: Misc/NEWS description: Merge with 3.5: Issue #24514: tarfile now tolerates number fields consisting of only whitespace. diff -r dbb4fb46fc1d -r 08fad9037206 Lib/tarfile.py --- a/Lib/tarfile.py Wed Jul 01 22:36:37 2015 -0500 +++ b/Lib/tarfile.py Thu Jul 02 19:42:09 2015 +0200 @@ -178,7 +178,8 @@ n = -(256 ** (len(s) - 1) - n) else: try: - n = int(nts(s, "ascii", "strict") or "0", 8) + s = nts(s, "ascii", "strict") + n = int(s.strip() or "0", 8) except ValueError: raise InvalidHeaderError("invalid header") return n diff -r dbb4fb46fc1d -r 08fad9037206 Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py Wed Jul 01 22:36:37 2015 -0500 +++ b/Lib/test/test_tarfile.py Thu Jul 02 19:42:09 2015 +0200 @@ -1952,6 +1952,10 @@ self.assertEqual(tarfile.nti(b"\xff\x00\x00\x00\x00\x00\x00\x00"), -0x100000000000000) + # Issue 24514: Test if empty number fields are converted to zero. + self.assertEqual(tarfile.nti(b"\0"), 0) + self.assertEqual(tarfile.nti(b" \0"), 0) + def test_write_number_fields(self): self.assertEqual(tarfile.itn(1), b"0000001\x00") self.assertEqual(tarfile.itn(0o7777777), b"7777777\x00") diff -r dbb4fb46fc1d -r 08fad9037206 Misc/NEWS --- a/Misc/NEWS Wed Jul 01 22:36:37 2015 -0500 +++ b/Misc/NEWS Thu Jul 02 19:42:09 2015 +0200 @@ -52,6 +52,9 @@ Library ------- +- Issue #24514: tarfile now tolerates number fields consisting of only + whitespace. + - Issue #19176: Fixed doctype() related bugs in C implementation of ElementTree. A deprecation warning no longer issued by XMLParser subclass with default doctype() method. Direct call of doctype() now issues a warning. Parser's