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
194e20a9
Kaydet (Commit)
194e20a9
authored
Eyl 20, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add file parameter to all printing fns, default stderr
üst
095e9c69
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
12 deletions
+30
-12
traceback.py
Lib/traceback.py
+30
-12
No files found.
Lib/traceback.py
Dosyayı görüntüle @
194e20a9
# Format and print Python stack traces
# Format and print Python stack traces
#
# updated to take optional "file" named parameter
# by Tommy Burnette, 9/20/95
import
linecache
import
linecache
import
string
import
string
import
sys
import
sys
import
types
import
types
def
print_tb
(
tb
,
limit
=
None
):
def
_print
(
file
,
str
=
''
,
terminator
=
'
\n
'
):
file
.
write
(
str
+
terminator
)
def
print_tb
(
tb
,
limit
=
None
,
file
=
None
):
if
not
file
:
file
=
sys
.
stderr
if
limit
is
None
:
if
limit
is
None
:
if
hasattr
(
sys
,
'tracebacklimit'
):
if
hasattr
(
sys
,
'tracebacklimit'
):
limit
=
sys
.
tracebacklimit
limit
=
sys
.
tracebacklimit
...
@@ -16,9 +25,10 @@ def print_tb(tb, limit = None):
...
@@ -16,9 +25,10 @@ def print_tb(tb, limit = None):
co
=
f
.
f_code
co
=
f
.
f_code
filename
=
co
.
co_filename
filename
=
co
.
co_filename
name
=
co
.
co_name
name
=
co
.
co_name
print
' File "
%
s", line
%
d, in
%
s'
%
(
filename
,
lineno
,
name
)
_print
(
file
,
' File "
%
s", line
%
d, in
%
s'
%
(
filename
,
lineno
,
name
))
line
=
linecache
.
getline
(
filename
,
lineno
)
line
=
linecache
.
getline
(
filename
,
lineno
)
if
line
:
print
' '
+
string
.
strip
(
line
)
if
line
:
_print
(
file
,
' '
+
string
.
strip
(
line
)
)
tb
=
tb
.
tb_next
tb
=
tb
.
tb_next
n
=
n
+
1
n
=
n
+
1
...
@@ -52,12 +62,16 @@ def extract_tb(tb, limit = None):
...
@@ -52,12 +62,16 @@ def extract_tb(tb, limit = None):
return
list
return
list
def
print_exception
(
etype
,
value
,
tb
,
limit
=
None
):
def
print_exception
(
etype
,
value
,
tb
,
limit
=
None
,
file
=
None
):
if
not
file
:
file
=
sys
.
stderr
if
tb
:
if
tb
:
print
'Traceback (innermost last):'
_print
(
file
,
'Traceback (innermost last):'
)
print_tb
(
tb
,
limit
)
print_tb
(
tb
,
limit
,
file
)
for
line
in
format_exception_only
(
etype
,
value
):
lines
=
format_exception_only
(
etype
,
value
)
print
line
,
for
line
in
lines
[:
-
1
]:
_print
(
file
,
line
,
' '
)
_print
(
file
,
lines
[
-
1
],
''
)
def
format_exception
(
etype
,
value
,
tb
,
limit
=
None
):
def
format_exception
(
etype
,
value
,
tb
,
limit
=
None
):
if
tb
:
if
tb
:
...
@@ -101,10 +115,14 @@ def format_exception_only(etype, value):
...
@@ -101,10 +115,14 @@ def format_exception_only(etype, value):
return
list
return
list
def
print_exc
(
limit
=
None
):
def
print_exc
(
limit
=
None
,
file
=
None
):
if
not
file
:
file
=
sys
.
stderr
print_exception
(
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
,
print_exception
(
sys
.
exc_type
,
sys
.
exc_value
,
sys
.
exc_traceback
,
limit
)
limit
,
file
)
def
print_last
(
limit
=
None
):
def
print_last
(
limit
=
None
,
file
=
None
):
if
not
file
:
file
=
sys
.
stderr
print_exception
(
sys
.
last_type
,
sys
.
last_value
,
sys
.
last_traceback
,
print_exception
(
sys
.
last_type
,
sys
.
last_value
,
sys
.
last_traceback
,
limit
)
limit
,
file
)
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