cpython: 308f3c1e36d3 (original) (raw)

Mercurial > cpython

changeset 91708:308f3c1e36d3 2.7

Issue 21044: tarfile.open() now handles fileobj with an integer 'name' attribute. Based on patch by Martin Panter.

Serhiy Storchaka storchaka@gmail.com
date Wed, 16 Jul 2014 23:58:12 +0300
parents f3b9814fb81a
children 4c98086194d5
files Lib/tarfile.py Lib/test/test_tarfile.py Misc/ACKS Misc/NEWS
diffstat 4 files changed, 39 insertions(+), 6 deletions(-)[+] [-] Lib/tarfile.py 3 Lib/test/test_tarfile.py 38 Misc/ACKS 1 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1522,7 +1522,8 @@ class TarFile(object): fileobj = bltn_open(name, self._mode) self._extfileobj = False else:

--- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -1,6 +1,7 @@

-- coding: iso-8859-15 --

import sys +import io import os import shutil import StringIO @@ -289,24 +290,49 @@ class CommonReadTest(ReadTest): class MiscReadTest(CommonReadTest): taropen = tarfile.TarFile.taropen

+ def test_no_name_argument(self):

def test_no_name_attribute(self): data = open(self.tarname, "rb").read() fobj = StringIO.StringIO(data) self.assertRaises(AttributeError, getattr, fobj, "name") tar = tarfile.open(fileobj=fobj, mode=self.mode)

def test_empty_name_attribute(self): data = open(self.tarname, "rb").read() fobj = StringIO.StringIO(data) fobj.name = "" tar = tarfile.open(fileobj=fobj, mode=self.mode)

+

+

def test_illegal_mode_arg(self): with open(tmpname, 'wb'): @@ -1668,6 +1694,8 @@ class Bz2MiscReadTest(MiscReadTest): tarname = bz2name mode = "r:bz2" taropen = tarfile.TarFile.bz2open

class Bz2UstarReadTest(UstarReadTest): tarname = bz2name mode = "r:bz2"

--- a/Misc/ACKS +++ b/Misc/ACKS @@ -995,6 +995,7 @@ Mike Pall Todd R. Palmer Juan David Ibáñez Palomar Jan Palus +Martin Panter Mathias Panzenböck M. Papillon Peter Parente

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -13,6 +13,9 @@ Core and Builtins Library ------- +- Issue 21044: tarfile.open() now handles fileobj with an integer 'name'