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
4925cde1
Kaydet (Commit)
4925cde1
authored
May 19, 2011
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #12124: zipimport doesn't keep a reference to zlib.decompress() anymore
to be able to unload the module.
üst
ae8856fe
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
25 deletions
+10
-25
test_zipimport.py
Lib/test/test_zipimport.py
+0
-17
NEWS
Misc/NEWS
+3
-0
zipimport.c
Modules/zipimport.c
+7
-8
No files found.
Lib/test/test_zipimport.py
Dosyayı görüntüle @
4925cde1
...
@@ -19,11 +19,6 @@ import io
...
@@ -19,11 +19,6 @@ import io
from
traceback
import
extract_tb
,
extract_stack
,
print_tb
from
traceback
import
extract_tb
,
extract_stack
,
print_tb
raise_src
=
'def do_raise(): raise TypeError
\n
'
raise_src
=
'def do_raise(): raise TypeError
\n
'
# so we only run testAFakeZlib once if this test is run repeatedly
# which happens when we look for ref leaks
test_imported
=
False
def
make_pyc
(
co
,
mtime
):
def
make_pyc
(
co
,
mtime
):
data
=
marshal
.
dumps
(
co
)
data
=
marshal
.
dumps
(
co
)
if
type
(
mtime
)
is
type
(
0.0
):
if
type
(
mtime
)
is
type
(
0.0
):
...
@@ -453,19 +448,7 @@ class BadFileZipImportTestCase(unittest.TestCase):
...
@@ -453,19 +448,7 @@ class BadFileZipImportTestCase(unittest.TestCase):
zipimport
.
_zip_directory_cache
.
clear
()
zipimport
.
_zip_directory_cache
.
clear
()
def
cleanup
():
# this is necessary if test is run repeated (like when finding leaks)
global
test_imported
if
test_imported
:
zipimport
.
_zip_directory_cache
.
clear
()
if
hasattr
(
UncompressedZipImportTestCase
,
'testAFakeZlib'
):
delattr
(
UncompressedZipImportTestCase
,
'testAFakeZlib'
)
if
hasattr
(
CompressedZipImportTestCase
,
'testAFakeZlib'
):
delattr
(
CompressedZipImportTestCase
,
'testAFakeZlib'
)
test_imported
=
True
def
test_main
():
def
test_main
():
cleanup
()
try
:
try
:
support
.
run_unittest
(
support
.
run_unittest
(
UncompressedZipImportTestCase
,
UncompressedZipImportTestCase
,
...
...
Misc/NEWS
Dosyayı görüntüle @
4925cde1
...
@@ -72,6 +72,9 @@ Core and Builtins
...
@@ -72,6 +72,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #12124: zipimport doesn't keep a reference to zlib.decompress() anymore
to be able to unload the module.
- Issue #10801: In zipfile, support different encodings for the header and
- Issue #10801: In zipfile, support different encodings for the header and
the filenames.
the filenames.
...
...
Modules/zipimport.c
Dosyayı görüntüle @
4925cde1
...
@@ -785,16 +785,13 @@ error:
...
@@ -785,16 +785,13 @@ error:
/* Return the zlib.decompress function object, or NULL if zlib couldn't
/* Return the zlib.decompress function object, or NULL if zlib couldn't
be imported. The function is cached when found, so subsequent calls
be imported. The function is cached when found, so subsequent calls
don't import zlib again. Returns a *borrowed* reference.
don't import zlib again. */
XXX This makes zlib.decompress immortal. */
static
PyObject
*
static
PyObject
*
get_decompress_func
(
void
)
get_decompress_func
(
void
)
{
{
static
PyObject
*
decompress
=
NULL
;
if
(
decompress
==
NULL
)
{
PyObject
*
zlib
;
static
int
importing_zlib
=
0
;
static
int
importing_zlib
=
0
;
PyObject
*
zlib
;
PyObject
*
decompress
;
if
(
importing_zlib
!=
0
)
if
(
importing_zlib
!=
0
)
/* Someone has a zlib.py[co] in their Zip file;
/* Someone has a zlib.py[co] in their Zip file;
...
@@ -808,12 +805,13 @@ get_decompress_func(void)
...
@@ -808,12 +805,13 @@ get_decompress_func(void)
"decompress"
);
"decompress"
);
Py_DECREF
(
zlib
);
Py_DECREF
(
zlib
);
}
}
else
else
{
PyErr_Clear
();
PyErr_Clear
();
decompress
=
NULL
;
}
if
(
Py_VerboseFlag
)
if
(
Py_VerboseFlag
)
PySys_WriteStderr
(
"# zipimport: zlib %s
\n
"
,
PySys_WriteStderr
(
"# zipimport: zlib %s
\n
"
,
zlib
!=
NULL
?
"available"
:
"UNAVAILABLE"
);
zlib
!=
NULL
?
"available"
:
"UNAVAILABLE"
);
}
return
decompress
;
return
decompress
;
}
}
...
@@ -904,6 +902,7 @@ get_data(char *archive, PyObject *toc_entry)
...
@@ -904,6 +902,7 @@ get_data(char *archive, PyObject *toc_entry)
goto
error
;
goto
error
;
}
}
data
=
PyObject_CallFunction
(
decompress
,
"Oi"
,
raw_data
,
-
15
);
data
=
PyObject_CallFunction
(
decompress
,
"Oi"
,
raw_data
,
-
15
);
Py_DECREF
(
decompress
);
error:
error:
Py_DECREF
(
raw_data
);
Py_DECREF
(
raw_data
);
return
data
;
return
data
;
...
...
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