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
33363f43
Kaydet (Commit)
33363f43
authored
Kas 07, 2012
tarafından
Hynek Schlawack
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #15001: fix segfault on "del sys.module['__main__']"
Patch by Victor Stinner.
üst
c3fb3c3f
5c6b3e21
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
6 deletions
+21
-6
test_cmd_line.py
Lib/test/test_cmd_line.py
+12
-0
NEWS
Misc/NEWS
+3
-0
pythonrun.c
Python/pythonrun.c
+6
-6
No files found.
Lib/test/test_cmd_line.py
Dosyayı görüntüle @
33363f43
...
@@ -358,6 +358,18 @@ class CmdLineTest(unittest.TestCase):
...
@@ -358,6 +358,18 @@ class CmdLineTest(unittest.TestCase):
self
.
assertEqual
(
rc
,
0
)
self
.
assertEqual
(
rc
,
0
)
self
.
assertIn
(
b
'random is 1'
,
out
)
self
.
assertIn
(
b
'random is 1'
,
out
)
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
.
support
.
TESTFN
self
.
addCleanup
(
test
.
support
.
unlink
,
filename
)
with
open
(
filename
,
"w"
)
as
script
:
print
(
"import sys"
,
file
=
script
)
print
(
"del sys.modules['__main__']"
,
file
=
script
)
assert_python_ok
(
filename
)
def
test_main
():
def
test_main
():
test
.
support
.
run_unittest
(
CmdLineTest
)
test
.
support
.
run_unittest
(
CmdLineTest
)
test
.
support
.
reap_children
()
test
.
support
.
reap_children
()
...
...
Misc/NEWS
Dosyayı görüntüle @
33363f43
...
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
...
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #15001: fix segfault on "del sys.module['
__main__
']". Patch by Victor
Stinner.
- Issue #8271: the utf-8 decoder now outputs the correct number of U+FFFD
- Issue #8271: the utf-8 decoder now outputs the correct number of U+FFFD
characters when used with the '
replace
' error handler on invalid utf-8
characters when used with the '
replace
' error handler on invalid utf-8
sequences. Patch by Serhiy Storchaka, tests by Ezio Melotti.
sequences. Patch by Serhiy Storchaka, tests by Ezio Melotti.
...
...
Python/pythonrun.c
Dosyayı görüntüle @
33363f43
...
@@ -1390,25 +1390,26 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
...
@@ -1390,25 +1390,26 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
{
{
PyObject
*
m
,
*
d
,
*
v
;
PyObject
*
m
,
*
d
,
*
v
;
const
char
*
ext
;
const
char
*
ext
;
int
set_file_name
=
0
,
ret
;
int
set_file_name
=
0
,
ret
=
-
1
;
size_t
len
;
size_t
len
;
m
=
PyImport_AddModule
(
"__main__"
);
m
=
PyImport_AddModule
(
"__main__"
);
if
(
m
==
NULL
)
if
(
m
==
NULL
)
return
-
1
;
return
-
1
;
Py_INCREF
(
m
);
d
=
PyModule_GetDict
(
m
);
d
=
PyModule_GetDict
(
m
);
if
(
PyDict_GetItemString
(
d
,
"__file__"
)
==
NULL
)
{
if
(
PyDict_GetItemString
(
d
,
"__file__"
)
==
NULL
)
{
PyObject
*
f
;
PyObject
*
f
;
f
=
PyUnicode_DecodeFSDefault
(
filename
);
f
=
PyUnicode_DecodeFSDefault
(
filename
);
if
(
f
==
NULL
)
if
(
f
==
NULL
)
return
-
1
;
goto
done
;
if
(
PyDict_SetItemString
(
d
,
"__file__"
,
f
)
<
0
)
{
if
(
PyDict_SetItemString
(
d
,
"__file__"
,
f
)
<
0
)
{
Py_DECREF
(
f
);
Py_DECREF
(
f
);
return
-
1
;
goto
done
;
}
}
if
(
PyDict_SetItemString
(
d
,
"__cached__"
,
Py_None
)
<
0
)
{
if
(
PyDict_SetItemString
(
d
,
"__cached__"
,
Py_None
)
<
0
)
{
Py_DECREF
(
f
);
Py_DECREF
(
f
);
return
-
1
;
goto
done
;
}
}
set_file_name
=
1
;
set_file_name
=
1
;
Py_DECREF
(
f
);
Py_DECREF
(
f
);
...
@@ -1422,7 +1423,6 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
...
@@ -1422,7 +1423,6 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
fclose
(
fp
);
fclose
(
fp
);
if
((
pyc_fp
=
fopen
(
filename
,
"rb"
))
==
NULL
)
{
if
((
pyc_fp
=
fopen
(
filename
,
"rb"
))
==
NULL
)
{
fprintf
(
stderr
,
"python: Can't reopen .pyc file
\n
"
);
fprintf
(
stderr
,
"python: Can't reopen .pyc file
\n
"
);
ret
=
-
1
;
goto
done
;
goto
done
;
}
}
/* Turn on optimization if a .pyo file is given */
/* Turn on optimization if a .pyo file is given */
...
@@ -1451,7 +1451,6 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
...
@@ -1451,7 +1451,6 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
flush_io
();
flush_io
();
if
(
v
==
NULL
)
{
if
(
v
==
NULL
)
{
PyErr_Print
();
PyErr_Print
();
ret
=
-
1
;
goto
done
;
goto
done
;
}
}
Py_DECREF
(
v
);
Py_DECREF
(
v
);
...
@@ -1459,6 +1458,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
...
@@ -1459,6 +1458,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
done:
done:
if
(
set_file_name
&&
PyDict_DelItemString
(
d
,
"__file__"
))
if
(
set_file_name
&&
PyDict_DelItemString
(
d
,
"__file__"
))
PyErr_Clear
();
PyErr_Clear
();
Py_DECREF
(
m
);
return
ret
;
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