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
b271b3e1
Kaydet (Commit)
b271b3e1
authored
Kas 07, 2012
tarafından
Hynek Schlawack
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15001: fix segfault on "del sys.modules['__main__']"
Patch by Victor Stinner.
üst
6cad3712
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
test_cmd_line.py
Lib/test/test_cmd_line.py
+17
-2
NEWS
Misc/NEWS
+3
-0
pythonrun.c
Python/pythonrun.c
+5
-5
No files found.
Lib/test/test_cmd_line.py
Dosyayı görüntüle @
b271b3e1
...
...
@@ -2,9 +2,12 @@
# All tests are executed with environment variables ignored
# See test_cmd_line_script.py for testing of script execution
import
test.test_support
,
unittest
import
test.test_support
import
sys
from
test.script_helper
import
spawn_python
,
kill_python
,
python_exit_code
import
unittest
from
test.script_helper
import
(
assert_python_ok
,
spawn_python
,
kill_python
,
python_exit_code
)
class
CmdLineTest
(
unittest
.
TestCase
):
...
...
@@ -101,6 +104,18 @@ class CmdLineTest(unittest.TestCase):
data
=
self
.
start_python
(
'-R'
,
'-c'
,
code
)
self
.
assertTrue
(
'hash_randomization=1'
in
data
)
def
test_del___main__
(
self
):
# Issue #15001: PyRun_SimpleFileExFlags() did crash because it kept a
# borrowed reference to the dict of __main__ module and later modify
# the dict whereas the module was destroyed
filename
=
test
.
test_support
.
TESTFN
self
.
addCleanup
(
test
.
test_support
.
unlink
,
filename
)
with
open
(
filename
,
"w"
)
as
script
:
print
>>
script
,
"import sys"
print
>>
script
,
"del sys.modules['__main__']"
assert_python_ok
(
filename
)
def
test_main
():
test
.
test_support
.
run_unittest
(
CmdLineTest
)
test
.
test_support
.
reap_children
()
...
...
Misc/NEWS
Dosyayı görüntüle @
b271b3e1
...
...
@@ -9,6 +9,9 @@ What's New in Python 2.7.4
Core and Builtins
-----------------
- Issue #15001: fix segfault on "del sys.modules['
__main__
']". Patch by Victor
Stinner.
- Issue #5057: the peepholer no longer optimizes subscription on unicode
literals (e.g. u'
foo
'[0]) in order to produce compatible pyc files between
narrow and wide builds.
...
...
Python/pythonrun.c
Dosyayı görüntüle @
b271b3e1
...
...
@@ -907,19 +907,20 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
{
PyObject
*
m
,
*
d
,
*
v
;
const
char
*
ext
;
int
set_file_name
=
0
,
ret
,
len
;
int
set_file_name
=
0
,
len
,
ret
=
-
1
;
m
=
PyImport_AddModule
(
"__main__"
);
if
(
m
==
NULL
)
return
-
1
;
Py_INCREF
(
m
);
d
=
PyModule_GetDict
(
m
);
if
(
PyDict_GetItemString
(
d
,
"__file__"
)
==
NULL
)
{
PyObject
*
f
=
PyString_FromString
(
filename
);
if
(
f
==
NULL
)
return
-
1
;
goto
done
;
if
(
PyDict_SetItemString
(
d
,
"__file__"
,
f
)
<
0
)
{
Py_DECREF
(
f
);
return
-
1
;
goto
done
;
}
set_file_name
=
1
;
Py_DECREF
(
f
);
...
...
@@ -932,7 +933,6 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
fclose
(
fp
);
if
((
fp
=
fopen
(
filename
,
"rb"
))
==
NULL
)
{
fprintf
(
stderr
,
"python: Can't reopen .pyc file
\n
"
);
ret
=
-
1
;
goto
done
;
}
/* Turn on optimization if a .pyo file is given */
...
...
@@ -945,7 +945,6 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
}
if
(
v
==
NULL
)
{
PyErr_Print
();
ret
=
-
1
;
goto
done
;
}
Py_DECREF
(
v
);
...
...
@@ -955,6 +954,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
done:
if
(
set_file_name
&&
PyDict_DelItemString
(
d
,
"__file__"
))
PyErr_Clear
();
Py_DECREF
(
m
);
return
ret
;
}
...
...
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