Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
2c6a3aed
Kaydet (Commit)
2c6a3aed
authored
Tem 16, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 21044: tarfile.open() now handles fileobj with an integer 'name'
attribute. Based on patch by Martin Panter.
üst
8faecbfb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
7 deletions
+36
-7
tarfile.py
Lib/tarfile.py
+2
-1
test_tarfile.py
Lib/test/test_tarfile.py
+30
-6
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/tarfile.py
Dosyayı görüntüle @
2c6a3aed
...
@@ -1423,7 +1423,8 @@ class TarFile(object):
...
@@ -1423,7 +1423,8 @@ class TarFile(object):
fileobj
=
bltn_open
(
name
,
self
.
_mode
)
fileobj
=
bltn_open
(
name
,
self
.
_mode
)
self
.
_extfileobj
=
False
self
.
_extfileobj
=
False
else
:
else
:
if
name
is
None
and
hasattr
(
fileobj
,
"name"
):
if
(
name
is
None
and
hasattr
(
fileobj
,
"name"
)
and
isinstance
(
fileobj
.
name
,
(
str
,
bytes
))):
name
=
fileobj
.
name
name
=
fileobj
.
name
if
hasattr
(
fileobj
,
"mode"
):
if
hasattr
(
fileobj
,
"mode"
):
self
.
_mode
=
fileobj
.
mode
self
.
_mode
=
fileobj
.
mode
...
...
Lib/test/test_tarfile.py
Dosyayı görüntüle @
2c6a3aed
...
@@ -352,10 +352,16 @@ class CommonReadTest(ReadTest):
...
@@ -352,10 +352,16 @@ class CommonReadTest(ReadTest):
class
MiscReadTestBase
(
CommonReadTest
):
class
MiscReadTestBase
(
CommonReadTest
):
def
requires_name_attribute
(
self
):
pass
def
test_no_name_argument
(
self
):
def
test_no_name_argument
(
self
):
self
.
requires_name_attribute
()
with
open
(
self
.
tarname
,
"rb"
)
as
fobj
:
with
open
(
self
.
tarname
,
"rb"
)
as
fobj
:
tar
=
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
self
.
mode
)
self
.
assertIsInstance
(
fobj
.
name
,
str
)
self
.
assertEqual
(
tar
.
name
,
os
.
path
.
abspath
(
fobj
.
name
))
with
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
self
.
mode
)
as
tar
:
self
.
assertIsInstance
(
tar
.
name
,
str
)
self
.
assertEqual
(
tar
.
name
,
os
.
path
.
abspath
(
fobj
.
name
))
def
test_no_name_attribute
(
self
):
def
test_no_name_attribute
(
self
):
with
open
(
self
.
tarname
,
"rb"
)
as
fobj
:
with
open
(
self
.
tarname
,
"rb"
)
as
fobj
:
...
@@ -363,7 +369,7 @@ class MiscReadTestBase(CommonReadTest):
...
@@ -363,7 +369,7 @@ class MiscReadTestBase(CommonReadTest):
fobj
=
io
.
BytesIO
(
data
)
fobj
=
io
.
BytesIO
(
data
)
self
.
assertRaises
(
AttributeError
,
getattr
,
fobj
,
"name"
)
self
.
assertRaises
(
AttributeError
,
getattr
,
fobj
,
"name"
)
tar
=
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
self
.
mode
)
tar
=
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
self
.
mode
)
self
.
assert
Equal
(
tar
.
name
,
Non
e
)
self
.
assert
IsNone
(
tar
.
nam
e
)
def
test_empty_name_attribute
(
self
):
def
test_empty_name_attribute
(
self
):
with
open
(
self
.
tarname
,
"rb"
)
as
fobj
:
with
open
(
self
.
tarname
,
"rb"
)
as
fobj
:
...
@@ -371,7 +377,25 @@ class MiscReadTestBase(CommonReadTest):
...
@@ -371,7 +377,25 @@ class MiscReadTestBase(CommonReadTest):
fobj
=
io
.
BytesIO
(
data
)
fobj
=
io
.
BytesIO
(
data
)
fobj
.
name
=
""
fobj
.
name
=
""
with
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
self
.
mode
)
as
tar
:
with
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
self
.
mode
)
as
tar
:
self
.
assertEqual
(
tar
.
name
,
None
)
self
.
assertIsNone
(
tar
.
name
)
def
test_int_name_attribute
(
self
):
# Issue 21044: tarfile.open() should handle fileobj with an integer
# 'name' attribute.
fd
=
os
.
open
(
self
.
tarname
,
os
.
O_RDONLY
)
with
open
(
fd
,
'rb'
)
as
fobj
:
self
.
assertIsInstance
(
fobj
.
name
,
int
)
with
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
self
.
mode
)
as
tar
:
self
.
assertIsNone
(
tar
.
name
)
def
test_bytes_name_attribute
(
self
):
self
.
requires_name_attribute
()
tarname
=
os
.
fsencode
(
self
.
tarname
)
with
open
(
tarname
,
'rb'
)
as
fobj
:
self
.
assertIsInstance
(
fobj
.
name
,
bytes
)
with
tarfile
.
open
(
fileobj
=
fobj
,
mode
=
self
.
mode
)
as
tar
:
self
.
assertIsInstance
(
tar
.
name
,
bytes
)
self
.
assertEqual
(
tar
.
name
,
os
.
path
.
abspath
(
fobj
.
name
))
def
test_illegal_mode_arg
(
self
):
def
test_illegal_mode_arg
(
self
):
with
open
(
tmpname
,
'wb'
):
with
open
(
tmpname
,
'wb'
):
...
@@ -549,11 +573,11 @@ class GzipMiscReadTest(GzipTest, MiscReadTestBase, unittest.TestCase):
...
@@ -549,11 +573,11 @@ class GzipMiscReadTest(GzipTest, MiscReadTestBase, unittest.TestCase):
pass
pass
class
Bz2MiscReadTest
(
Bz2Test
,
MiscReadTestBase
,
unittest
.
TestCase
):
class
Bz2MiscReadTest
(
Bz2Test
,
MiscReadTestBase
,
unittest
.
TestCase
):
def
test_no_name_argument
(
self
):
def
requires_name_attribute
(
self
):
self
.
skipTest
(
"BZ2File have no name attribute"
)
self
.
skipTest
(
"BZ2File have no name attribute"
)
class
LzmaMiscReadTest
(
LzmaTest
,
MiscReadTestBase
,
unittest
.
TestCase
):
class
LzmaMiscReadTest
(
LzmaTest
,
MiscReadTestBase
,
unittest
.
TestCase
):
def
test_no_name_argument
(
self
):
def
requires_name_attribute
(
self
):
self
.
skipTest
(
"LZMAFile have no name attribute"
)
self
.
skipTest
(
"LZMAFile have no name attribute"
)
...
...
Misc/ACKS
Dosyayı görüntüle @
2c6a3aed
...
@@ -996,6 +996,7 @@ Mike Pall
...
@@ -996,6 +996,7 @@ Mike Pall
Todd R. Palmer
Todd R. Palmer
Juan David Ibáñez Palomar
Juan David Ibáñez Palomar
Jan Palus
Jan Palus
Martin Panter
Mathias Panzenböck
Mathias Panzenböck
M. Papillon
M. Papillon
Peter Parente
Peter Parente
...
...
Misc/NEWS
Dosyayı görüntüle @
2c6a3aed
...
@@ -27,6 +27,9 @@ Core and Builtins
...
@@ -27,6 +27,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue 21044: tarfile.open() now handles fileobj with an integer '
name
'
attribute. Based on patch by Martin Panter.
- Issue #19076: Don'
t
pass
the
redundant
'file'
argument
to
self
.
error
().
- Issue #19076: Don'
t
pass
the
redundant
'file'
argument
to
self
.
error
().
-
Issue
#
21942
:
Fixed
source
file
viewing
in
pydoc
's server mode on Windows.
-
Issue
#
21942
:
Fixed
source
file
viewing
in
pydoc
's server mode on Windows.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment