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
65bf9f26
Kaydet (Commit)
65bf9f26
authored
Nis 29, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Quickly renamed.
üst
04e30c18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
57 deletions
+57
-57
sysmodule.c
Python/sysmodule.c
+0
-0
traceback.c
Python/traceback.c
+57
-57
No files found.
Python/sysmodule.c
Dosyayı görüntüle @
65bf9f26
This diff is collapsed.
Click to expand it.
Python/traceback.c
Dosyayı görüntüle @
65bf9f26
...
...
@@ -31,19 +31,17 @@ PERFORMANCE OF THIS SOFTWARE.
/* Traceback implementation */
#include "
allobjects
.h"
#include "
Python
.h"
#include "sysmodule.h"
#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
#include "structmember.h"
#include "osdefs.h"
typedef
struct
_tracebackobject
{
OB
_HEAD
PyObject
_HEAD
struct
_tracebackobject
*
tb_next
;
frameo
bject
*
tb_frame
;
PyFrameO
bject
*
tb_frame
;
int
tb_lasti
;
int
tb_lineno
;
}
tracebackobject
;
...
...
@@ -58,28 +56,28 @@ static struct memberlist tb_memberlist[] = {
{
NULL
}
/* Sentinel */
};
static
o
bject
*
static
PyO
bject
*
tb_getattr
(
tb
,
name
)
tracebackobject
*
tb
;
char
*
name
;
{
return
getmember
((
char
*
)
tb
,
tb_memberlist
,
name
);
return
PyMember_Get
((
char
*
)
tb
,
tb_memberlist
,
name
);
}
static
void
tb_dealloc
(
tb
)
tracebackobject
*
tb
;
{
XDECREF
(
tb
->
tb_next
);
XDECREF
(
tb
->
tb_frame
);
DEL
(
tb
);
Py_
XDECREF
(
tb
->
tb_next
);
Py_
XDECREF
(
tb
->
tb_frame
);
PyMem_
DEL
(
tb
);
}
#define Tracebacktype PyTraceBack_Type
#define is_tracebackobject PyTraceBack_Check
typeo
bject
Tracebacktype
=
{
OB_HEAD_INIT
(
&
Typet
ype
)
PyTypeO
bject
Tracebacktype
=
{
PyObject_HEAD_INIT
(
&
PyType_T
ype
)
0
,
"traceback"
,
sizeof
(
tracebackobject
),
...
...
@@ -98,20 +96,20 @@ typeobject Tracebacktype = {
static
tracebackobject
*
newtracebackobject
(
next
,
frame
,
lasti
,
lineno
)
tracebackobject
*
next
;
frameo
bject
*
frame
;
PyFrameO
bject
*
frame
;
int
lasti
,
lineno
;
{
tracebackobject
*
tb
;
if
((
next
!=
NULL
&&
!
is_tracebackobject
(
next
))
||
frame
==
NULL
||
!
is_frameobject
(
frame
))
{
err_badc
all
();
frame
==
NULL
||
!
PyFrame_Check
(
frame
))
{
PyErr_BadInternalC
all
();
return
NULL
;
}
tb
=
NEWOBJ
(
tracebackobject
,
&
Tracebacktype
);
tb
=
PyObject_NEW
(
tracebackobject
,
&
Tracebacktype
);
if
(
tb
!=
NULL
)
{
XINCREF
(
next
);
Py_
XINCREF
(
next
);
tb
->
tb_next
=
next
;
XINCREF
(
frame
);
Py_
XINCREF
(
frame
);
tb
->
tb_frame
=
frame
;
tb
->
tb_lasti
=
lasti
;
tb
->
tb_lineno
=
lineno
;
...
...
@@ -122,44 +120,45 @@ newtracebackobject(next, frame, lasti, lineno)
static
tracebackobject
*
tb_current
=
NULL
;
int
tb_h
ere
(
frame
)
frameo
bject
*
frame
;
PyTraceBack_H
ere
(
frame
)
PyFrameO
bject
*
frame
;
{
tracebackobject
*
tb
;
tb
=
newtracebackobject
(
tb_current
,
frame
,
frame
->
f_lasti
,
frame
->
f_lineno
);
tb
=
newtracebackobject
(
tb_current
,
frame
,
frame
->
f_lasti
,
frame
->
f_lineno
);
if
(
tb
==
NULL
)
return
-
1
;
XDECREF
(
tb_current
);
Py_
XDECREF
(
tb_current
);
tb_current
=
tb
;
return
0
;
}
o
bject
*
tb_f
etch
()
PyO
bject
*
PyTraceBack_F
etch
()
{
o
bject
*
v
;
v
=
(
o
bject
*
)
tb_current
;
PyO
bject
*
v
;
v
=
(
PyO
bject
*
)
tb_current
;
tb_current
=
NULL
;
return
v
;
}
int
tb_s
tore
(
v
)
o
bject
*
v
;
PyTraceBack_S
tore
(
v
)
PyO
bject
*
v
;
{
if
(
v
!=
NULL
&&
!
is_tracebackobject
(
v
))
{
err_badc
all
();
PyErr_BadInternalC
all
();
return
-
1
;
}
XDECREF
(
tb_current
);
XINCREF
(
v
);
Py_
XDECREF
(
tb_current
);
Py_
XINCREF
(
v
);
tb_current
=
(
tracebackobject
*
)
v
;
return
0
;
}
static
void
tb_displayline
(
f
,
filename
,
lineno
,
name
)
o
bject
*
f
;
PyO
bject
*
f
;
char
*
filename
;
int
lineno
;
char
*
name
;
...
...
@@ -177,25 +176,25 @@ tb_displayline(f, filename, lineno, name)
xfp
=
fopen
(
filename
,
"r"
);
if
(
xfp
==
NULL
)
{
/* Search tail of filename in sys.path before giving up */
o
bject
*
path
;
PyO
bject
*
path
;
char
*
tail
=
strrchr
(
filename
,
SEP
);
if
(
tail
==
NULL
)
tail
=
filename
;
else
tail
++
;
path
=
sysge
t
(
"path"
);
if
(
path
!=
NULL
&&
is_listobject
(
path
))
{
int
npath
=
getlists
ize
(
path
);
path
=
PySys_GetObjec
t
(
"path"
);
if
(
path
!=
NULL
&&
PyList_Check
(
path
))
{
int
npath
=
PyList_S
ize
(
path
);
int
taillen
=
strlen
(
tail
);
char
namebuf
[
MAXPATHLEN
+
1
];
for
(
i
=
0
;
i
<
npath
;
i
++
)
{
object
*
v
=
getlisti
tem
(
path
,
i
);
if
(
is_stringobject
(
v
))
{
PyObject
*
v
=
PyList_GetI
tem
(
path
,
i
);
if
(
PyString_Check
(
v
))
{
int
len
;
len
=
getstrings
ize
(
v
);
len
=
PyString_S
ize
(
v
);
if
(
len
+
1
+
taillen
>=
MAXPATHLEN
)
continue
;
/* Too long */
strcpy
(
namebuf
,
getstringvalue
(
v
));
strcpy
(
namebuf
,
PyString_AsString
(
v
));
if
((
int
)
strlen
(
namebuf
)
!=
len
)
continue
;
/* v contains '\0' */
if
(
len
>
0
&&
namebuf
[
len
-
1
]
!=
SEP
)
...
...
@@ -211,7 +210,7 @@ tb_displayline(f, filename, lineno, name)
}
}
sprintf
(
linebuf
,
FMT
,
filename
,
lineno
,
name
);
writes
tring
(
linebuf
,
f
);
PyFile_WriteS
tring
(
linebuf
,
f
);
if
(
xfp
==
NULL
)
return
;
for
(
i
=
0
;
i
<
lineno
;
i
++
)
{
...
...
@@ -222,10 +221,10 @@ tb_displayline(f, filename, lineno, name)
char
*
p
=
linebuf
;
while
(
*
p
==
' '
||
*
p
==
'\t'
||
*
p
==
'\014'
)
p
++
;
writes
tring
(
" "
,
f
);
writes
tring
(
p
,
f
);
PyFile_WriteS
tring
(
" "
,
f
);
PyFile_WriteS
tring
(
p
,
f
);
if
(
strchr
(
p
,
'\n'
)
==
NULL
)
writes
tring
(
"
\n
"
,
f
);
PyFile_WriteS
tring
(
"
\n
"
,
f
);
}
fclose
(
xfp
);
}
...
...
@@ -233,7 +232,7 @@ tb_displayline(f, filename, lineno, name)
static
void
tb_printinternal
(
tb
,
f
,
limit
)
tracebackobject
*
tb
;
o
bject
*
f
;
PyO
bject
*
f
;
int
limit
;
{
int
depth
=
0
;
...
...
@@ -242,14 +241,15 @@ tb_printinternal(tb, f, limit)
depth
++
;
tb1
=
tb1
->
tb_next
;
}
while
(
tb
!=
NULL
&&
!
intrcheck
())
{
while
(
tb
!=
NULL
&&
!
PyOS_InterruptOccurred
())
{
if
(
depth
<=
limit
)
{
tb
->
tb_lineno
=
PyCode_Addr2Line
(
tb
->
tb_frame
->
f_code
,
tb
->
tb_lasti
);
tb_displayline
(
f
,
getstringvalue
(
tb
->
tb_frame
->
f_code
->
co_filename
),
PyString_AsString
(
tb
->
tb_frame
->
f_code
->
co_filename
),
tb
->
tb_lineno
,
getstringvalue
(
tb
->
tb_frame
->
f_code
->
co_name
));
PyString_AsString
(
tb
->
tb_frame
->
f_code
->
co_name
));
}
depth
--
;
tb
=
tb
->
tb_next
;
...
...
@@ -257,25 +257,25 @@ tb_printinternal(tb, f, limit)
}
int
tb_p
rint
(
v
,
f
)
o
bject
*
v
;
o
bject
*
f
;
PyTraceBack_P
rint
(
v
,
f
)
PyO
bject
*
v
;
PyO
bject
*
f
;
{
o
bject
*
limitv
;
PyO
bject
*
limitv
;
int
limit
=
1000
;
if
(
v
==
NULL
)
return
0
;
if
(
!
is_tracebackobject
(
v
))
{
err_badc
all
();
PyErr_BadInternalC
all
();
return
-
1
;
}
limitv
=
sysge
t
(
"tracebacklimit"
);
if
(
limitv
&&
is_intobject
(
limitv
))
{
limit
=
getintvalue
(
limitv
);
limitv
=
PySys_GetObjec
t
(
"tracebacklimit"
);
if
(
limitv
&&
PyInt_Check
(
limitv
))
{
limit
=
PyInt_AsLong
(
limitv
);
if
(
limit
<=
0
)
return
0
;
}
writes
tring
(
"Traceback (innermost last):
\n
"
,
f
);
PyFile_WriteS
tring
(
"Traceback (innermost last):
\n
"
,
f
);
tb_printinternal
((
tracebackobject
*
)
v
,
f
,
limit
);
return
0
;
}
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