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
ab91902f
Kaydet (Commit)
ab91902f
authored
Haz 27, 2003
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
A bit o' reformatting and removal of non-_getframe currentframe().
üst
095f8173
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
19 deletions
+14
-19
inspect.py
Lib/inspect.py
+14
-19
No files found.
Lib/inspect.py
Dosyayı görüntüle @
ab91902f
...
...
@@ -309,12 +309,12 @@ def getfile(object):
if
ismodule
(
object
):
if
hasattr
(
object
,
'__file__'
):
return
object
.
__file__
raise
TypeError
,
'arg is a built-in module'
raise
TypeError
(
'arg is a built-in module'
)
if
isclass
(
object
):
object
=
sys
.
modules
.
get
(
object
.
__module__
)
if
hasattr
(
object
,
'__file__'
):
return
object
.
__file__
raise
TypeError
,
'arg is a built-in class'
raise
TypeError
(
'arg is a built-in class'
)
if
ismethod
(
object
):
object
=
object
.
im_func
if
isfunction
(
object
):
...
...
@@ -325,8 +325,8 @@ def getfile(object):
object
=
object
.
f_code
if
iscode
(
object
):
return
object
.
co_filename
raise
TypeError
,
'arg is not a module, class, method, '
\
'function, traceback, frame, or code object'
raise
TypeError
(
'arg is not a module, class, method, '
'function, traceback, frame, or code object'
)
def
getmoduleinfo
(
path
):
"""Get the module name, suffix, mode, and module type for a given file."""
...
...
@@ -405,7 +405,7 @@ def findsource(object):
file
=
getsourcefile
(
object
)
or
getfile
(
object
)
lines
=
linecache
.
getlines
(
file
)
if
not
lines
:
raise
IOError
,
'could not get source code'
raise
IOError
(
'could not get source code'
)
if
ismodule
(
object
):
return
lines
,
0
...
...
@@ -415,7 +415,8 @@ def findsource(object):
pat
=
re
.
compile
(
r'^\s*class\s*'
+
name
+
r'\b'
)
for
i
in
range
(
len
(
lines
)):
if
pat
.
match
(
lines
[
i
]):
return
lines
,
i
else
:
raise
IOError
,
'could not find class definition'
else
:
raise
IOError
(
'could not find class definition'
)
if
ismethod
(
object
):
object
=
object
.
im_func
...
...
@@ -427,14 +428,14 @@ def findsource(object):
object
=
object
.
f_code
if
iscode
(
object
):
if
not
hasattr
(
object
,
'co_firstlineno'
):
raise
IOError
,
'could not find function definition'
raise
IOError
(
'could not find function definition'
)
lnum
=
object
.
co_firstlineno
-
1
pat
=
re
.
compile
(
r'^(\s*def\s)|(.*\slambda(:|\s))'
)
while
lnum
>
0
:
if
pat
.
match
(
lines
[
lnum
]):
break
lnum
=
lnum
-
1
return
lines
,
lnum
raise
IOError
,
'could not find code object'
raise
IOError
(
'could not find code object'
)
def
getcomments
(
object
):
"""Get lines of comments immediately preceding an object's source code.
...
...
@@ -512,7 +513,8 @@ class BlockFinder:
self
.
indent
=
self
.
indent
+
1
elif
type
==
tokenize
.
DEDENT
:
self
.
indent
=
self
.
indent
-
1
if
self
.
indent
==
0
:
raise
EndOfBlock
,
self
.
last
if
self
.
indent
==
0
:
raise
EndOfBlock
,
self
.
last
elif
type
==
tokenize
.
NAME
and
scol
==
0
:
raise
EndOfBlock
,
self
.
last
...
...
@@ -739,7 +741,7 @@ def getframeinfo(frame, context=1):
if
istraceback
(
frame
):
frame
=
frame
.
tb_frame
if
not
isframe
(
frame
):
raise
TypeError
,
'arg is not a frame or traceback object'
raise
TypeError
(
'arg is not a frame or traceback object'
)
filename
=
getsourcefile
(
frame
)
or
getfile
(
frame
)
lineno
=
frame
.
f_lineno
...
...
@@ -786,18 +788,11 @@ def getinnerframes(tb, context=1):
tb
=
tb
.
tb_next
return
framelist
def
currentframe
():
"""Return the frame object for the caller's stack frame."""
try
:
1
/
0
except
ZeroDivisionError
:
return
sys
.
exc_info
()[
2
]
.
tb_frame
.
f_back
if
hasattr
(
sys
,
'_getframe'
):
currentframe
=
sys
.
_getframe
currentframe
=
sys
.
_getframe
def
stack
(
context
=
1
):
"""Return a list of records for the stack above the caller's frame."""
return
getouterframes
(
currentframe
()
.
f_back
,
context
)
return
getouterframes
(
sys
.
_getframe
(
1
)
,
context
)
def
trace
(
context
=
1
):
"""Return a list of records for the stack below the current exception."""
...
...
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