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
32b18cc2
Kaydet (Commit)
32b18cc2
authored
Nis 07, 2009
tarafından
Hirokazu Yamamoto
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Rolled back revisions 71237 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
üst
cfbb18f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
21 deletions
+17
-21
test_traceback.py
Lib/test/test_traceback.py
+12
-17
traceback.py
Lib/traceback.py
+5
-4
No files found.
Lib/test/test_traceback.py
Dosyayı görüntüle @
32b18cc2
...
...
@@ -8,6 +8,16 @@ from test.test_support import run_unittest, is_jython, Error
import
traceback
try
:
raise
KeyError
except
KeyError
:
type_
,
value
,
tb
=
sys
.
exc_info
()
file_
=
StringIO
()
traceback_print
(
tb
,
file_
)
example_traceback
=
file_
.
getvalue
()
else
:
raise
Error
(
"unable to create test traceback string"
)
class
TracebackCases
(
unittest
.
TestCase
):
# For now, a very minimal set of tests. I want to be sure that
...
...
@@ -152,24 +162,9 @@ def test():
class
TracebackFormatTests
(
unittest
.
TestCase
):
def
test_traceback_format
(
self
):
try
:
raise
KeyError
(
'blah'
)
except
KeyError
:
type_
,
value
,
tb
=
sys
.
exc_info
()
traceback_fmt
=
'Traceback (most recent call last):
\n
'
+
\
''
.
join
(
traceback
.
format_tb
(
tb
))
file_
=
StringIO
()
traceback_print
(
tb
,
file_
)
python_fmt
=
file_
.
getvalue
()
else
:
raise
Error
(
"unable to create test traceback string"
)
# Make sure that Python and the traceback module format the same thing
self
.
assertEquals
(
traceback_fmt
,
python_fmt
)
def
test_traceback_indentation
(
self
):
# Make sure that the traceback is properly indented.
tb_lines
=
python_fmt
.
splitlines
()
tb_lines
=
example_traceback
.
splitlines
()
self
.
assertEquals
(
len
(
tb_lines
),
3
)
banner
,
location
,
source_line
=
tb_lines
self
.
assert_
(
banner
.
startswith
(
'Traceback'
))
...
...
Lib/traceback.py
Dosyayı görüntüle @
32b18cc2
...
...
@@ -64,7 +64,7 @@ def print_tb(tb, limit=None, file=None):
filename
=
co
.
co_filename
name
=
co
.
co_name
_print
(
file
,
' File "
%
s", line
%
d, in
%
s'
%
(
filename
,
lineno
,
name
))
' File "
%
s", line
%
d, in
%
s'
%
(
filename
,
lineno
,
name
))
linecache
.
checkcache
(
filename
)
line
=
linecache
.
getline
(
filename
,
lineno
,
f
.
f_globals
)
if
line
:
_print
(
file
,
' '
+
line
.
strip
())
...
...
@@ -124,8 +124,9 @@ def print_exception(etype, value, tb, limit=None, file=None):
_print
(
file
,
'Traceback (most recent call last):'
)
print_tb
(
tb
,
limit
,
file
)
lines
=
format_exception_only
(
etype
,
value
)
for
line
in
lines
:
_print
(
file
,
line
,
''
)
for
line
in
lines
[:
-
1
]:
_print
(
file
,
line
,
' '
)
_print
(
file
,
lines
[
-
1
],
''
)
def
format_exception
(
etype
,
value
,
tb
,
limit
=
None
):
"""Format a stack trace and the exception information.
...
...
@@ -194,7 +195,7 @@ def format_exception_only(etype, value):
caretspace
=
((
c
.
isspace
()
and
c
or
' '
)
for
c
in
caretspace
)
# only three spaces to account for offset1 == pos 0
lines
.
append
(
'
%
s^
\n
'
%
''
.
join
(
caretspace
))
value
=
msg
value
=
msg
lines
.
append
(
_format_final_exc_line
(
stype
,
value
))
return
lines
...
...
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