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
28f35a2a
Kaydet (Commit)
28f35a2a
authored
Ock 19, 2003
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Backport 1.40 and 1.41 so that inspect isn't fooled by single line
definitions, pass statements, and lambdas.
üst
4e4f830e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
inspect.py
Lib/inspect.py
+5
-1
No files found.
Lib/inspect.py
Dosyayı görüntüle @
28f35a2a
...
...
@@ -410,7 +410,7 @@ def findsource(object):
if
not
hasattr
(
object
,
'co_firstlineno'
):
raise
IOError
,
'could not find function definition'
lnum
=
object
.
co_firstlineno
-
1
pat
=
re
.
compile
(
r'^
\s*def\s
'
)
pat
=
re
.
compile
(
r'^
(\s*def\s)|(.*\slambda(:|\s))
'
)
while
lnum
>
0
:
if
pat
.
match
(
lines
[
lnum
]):
break
lnum
=
lnum
-
1
...
...
@@ -489,6 +489,8 @@ class BlockFinder:
elif
type
==
tokenize
.
DEDENT
:
self
.
indent
=
self
.
indent
-
1
if
self
.
indent
==
0
:
raise
EndOfBlock
,
self
.
last
elif
type
==
tokenize
.
NAME
and
scol
==
0
:
raise
EndOfBlock
,
self
.
last
def
getblock
(
lines
):
"""Extract the block of code at the top of the given list of lines."""
...
...
@@ -496,6 +498,8 @@ def getblock(lines):
tokenize
.
tokenize
(
ListReader
(
lines
)
.
readline
,
BlockFinder
()
.
tokeneater
)
except
EndOfBlock
,
eob
:
return
lines
[:
eob
.
args
[
0
]]
# Fooling the indent/dedent logic implies a one-line definition
return
lines
[:
1
]
def
getsourcelines
(
object
):
"""Return a list of source lines and starting line number for an object.
...
...
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