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
7b0d4a23
Kaydet (Commit)
7b0d4a23
authored
Kas 28, 2009
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #4486: When an exception has an explicit cause, do not print its implicit context too.
üst
1fc0d2b3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
5 deletions
+30
-5
test_traceback.py
Lib/test/test_traceback.py
+20
-0
traceback.py
Lib/traceback.py
+5
-4
NEWS
Misc/NEWS
+4
-0
pythonrun.c
Python/pythonrun.c
+1
-1
No files found.
Lib/test/test_traceback.py
Dosyayı görüntüle @
7b0d4a23
...
...
@@ -253,6 +253,26 @@ class BaseExceptionReportingTests:
self
.
check_zero_div
(
blocks
[
0
])
self
.
assertTrue
(
'inner_raise() # Marker'
in
blocks
[
2
])
def
test_cause_and_context
(
self
):
# When both a cause and a context are set, only the cause should be
# displayed and the context should be muted.
def
inner_raise
():
try
:
self
.
zero_div
()
except
ZeroDivisionError
as
_e
:
e
=
_e
try
:
xyzzy
except
NameError
:
raise
KeyError
from
e
def
outer_raise
():
inner_raise
()
# Marker
blocks
=
boundaries
.
split
(
self
.
get_report
(
outer_raise
))
self
.
assertEquals
(
len
(
blocks
),
3
)
self
.
assertEquals
(
blocks
[
1
],
cause_message
)
self
.
check_zero_div
(
blocks
[
0
])
self
.
assert_
(
'inner_raise() # Marker'
in
blocks
[
2
])
def
test_cause_recursive
(
self
):
def
inner_raise
():
try
:
...
...
Lib/traceback.py
Dosyayı görüntüle @
7b0d4a23
...
...
@@ -120,13 +120,14 @@ def _iter_chain(exc, custom_tb=None, seen=None):
seen
.
add
(
exc
)
its
=
[]
cause
=
exc
.
__cause__
context
=
exc
.
__context__
if
cause
is
not
None
and
cause
not
in
seen
:
its
.
append
(
_iter_chain
(
cause
,
None
,
seen
))
its
.
append
([(
_cause_message
,
None
)])
if
context
is
not
None
and
context
is
not
cause
and
context
not
in
seen
:
its
.
append
(
_iter_chain
(
context
,
None
,
seen
))
its
.
append
([(
_context_message
,
None
)])
else
:
context
=
exc
.
__context__
if
context
is
not
None
and
context
not
in
seen
:
its
.
append
(
_iter_chain
(
context
,
None
,
seen
))
its
.
append
([(
_context_message
,
None
)])
its
.
append
([(
exc
,
custom_tb
or
exc
.
__traceback__
)])
# itertools.chain is in an extension module and may be unavailable
for
it
in
its
:
...
...
Misc/NEWS
Dosyayı görüntüle @
7b0d4a23
...
...
@@ -140,6 +140,10 @@ C-API
Library
-------
- Issue #4486: When an exception has an explicit cause, do not print its
implicit context too. This affects the `traceback` module as well as
built-in exception printing.
- Issue #1515: Enable use of deepcopy() with instance methods. Patch by
Robert Collins.
...
...
Python/pythonrun.c
Dosyayı görüntüle @
7b0d4a23
...
...
@@ -1576,7 +1576,7 @@ print_exception_recursive(PyObject *f, PyObject *value, PyObject *seen)
cause_message
,
f
);
}
}
if
(
context
)
{
else
if
(
context
)
{
res
=
PySet_Contains
(
seen
,
context
);
if
(
res
==
-
1
)
PyErr_Clear
();
...
...
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