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
d979e433
Kaydet (Commit)
d979e433
authored
Şub 09, 2014
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Close #20500: Don't trigger PyObject_Str assertion at shutdown
üst
c9d1a6b8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
2 deletions
+28
-2
test_cmd_line_script.py
Lib/test/test_cmd_line_script.py
+18
-0
NEWS
Misc/NEWS
+4
-1
object.c
Objects/object.c
+1
-1
pythonrun.c
Python/pythonrun.c
+5
-0
No files found.
Lib/test/test_cmd_line_script.py
Dosyayı görüntüle @
d979e433
...
...
@@ -405,6 +405,24 @@ class CmdLineTest(unittest.TestCase):
'stdout=
%
r stderr=
%
r'
%
(
stdout
,
stderr
))
self
.
assertEqual
(
0
,
rc
)
def
test_issue20500_exit_with_exception_value
(
self
):
script
=
textwrap
.
dedent
(
"""
\
import sys
error = None
try:
raise ValueError('some text')
except ValueError as err:
error = err
if error:
sys.exit(error)
"""
)
with
temp_dir
()
as
script_dir
:
script_name
=
_make_test_script
(
script_dir
,
'script'
,
script
)
exitcode
,
stdout
,
stderr
=
assert_python_failure
(
script_name
)
text
=
stderr
.
decode
(
'ascii'
)
self
.
assertEqual
(
text
,
"some text"
)
def
test_main
():
support
.
run_unittest
(
CmdLineTest
)
...
...
Misc/NEWS
Dosyayı görüntüle @
d979e433
...
...
@@ -10,7 +10,10 @@ Release date: 2014-02-09
Core and Builtins
-----------------
- Issue #20538: UTF-7 incremental decoder produced inconsistant string when
- Issue #20500: Displaying an exception at interpreter shutdown no longer
risks triggering an assertion failure in PyObject_Str.
- Issue #20538: UTF-7 incremental decoder produced inconsistent string when
input was truncated in BASE64 section.
- Issue #20404: io.TextIOWrapper (and hence the open() builtin) now uses the
...
...
Objects/object.c
Dosyayı görüntüle @
d979e433
...
...
@@ -508,7 +508,7 @@ PyObject_Str(PyObject *v)
#ifdef Py_DEBUG
/* PyObject_Str() must not be called with an exception set,
because it may clear it (directly or indirectly) and so the
caller lo
o
ses its exception */
caller loses its exception */
assert
(
!
PyErr_Occurred
());
#endif
...
...
Python/pythonrun.c
Dosyayı görüntüle @
d979e433
...
...
@@ -1792,6 +1792,11 @@ handle_system_exit(void)
exitcode
=
(
int
)
PyLong_AsLong
(
value
);
else
{
PyObject
*
sys_stderr
=
_PySys_GetObjectId
(
&
PyId_stderr
);
/* We clear the exception here to avoid triggering the assertion
* in PyObject_Str that ensures it won't silently lose exception
* details.
*/
PyErr_Clear
();
if
(
sys_stderr
!=
NULL
&&
sys_stderr
!=
Py_None
)
{
PyFile_WriteObject
(
value
,
sys_stderr
,
Py_PRINT_RAW
);
}
else
{
...
...
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