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
a6e59719
Kaydet (Commit)
a6e59719
authored
Mar 10, 2001
tarafından
Ka-Ping Yee
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix findsource() to work for derived classes.
üst
63085d4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
inspect.py
Lib/inspect.py
+5
-5
No files found.
Lib/inspect.py
Dosyayı görüntüle @
a6e59719
...
@@ -27,7 +27,7 @@ Here are some of the useful functions provided by this module:
...
@@ -27,7 +27,7 @@ Here are some of the useful functions provided by this module:
__author__
=
'Ka-Ping Yee <ping@lfw.org>'
__author__
=
'Ka-Ping Yee <ping@lfw.org>'
__date__
=
'1 Jan 2001'
__date__
=
'1 Jan 2001'
import
sys
,
os
,
types
,
string
,
dis
,
imp
,
tokenize
import
sys
,
os
,
types
,
string
,
re
,
dis
,
imp
,
tokenize
# ----------------------------------------------------------- type-checking
# ----------------------------------------------------------- type-checking
def
ismodule
(
object
):
def
ismodule
(
object
):
...
@@ -259,10 +259,9 @@ def findsource(object):
...
@@ -259,10 +259,9 @@ def findsource(object):
if
isclass
(
object
):
if
isclass
(
object
):
name
=
object
.
__name__
name
=
object
.
__name__
matches
=
([
'class'
,
name
],
[
'class'
,
name
+
':'
]
)
pat
=
re
.
compile
(
r'^\s*class\s*'
+
name
+
r'\b'
)
for
i
in
range
(
len
(
lines
)):
for
i
in
range
(
len
(
lines
)):
if
string
.
split
(
lines
[
i
])[:
2
]
in
matches
:
if
pat
.
match
(
lines
[
i
]):
return
lines
,
i
return
lines
,
i
else
:
raise
IOError
,
'could not find class definition'
else
:
raise
IOError
,
'could not find class definition'
if
ismethod
(
object
):
if
ismethod
(
object
):
...
@@ -277,8 +276,9 @@ def findsource(object):
...
@@ -277,8 +276,9 @@ def findsource(object):
if
not
hasattr
(
object
,
'co_firstlineno'
):
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
lnum
=
object
.
co_firstlineno
-
1
pat
=
re
.
compile
(
r'^\s*def\s'
)
while
lnum
>
0
:
while
lnum
>
0
:
if
string
.
split
(
lines
[
lnum
])[:
1
]
==
[
'def'
]
:
break
if
pat
.
match
(
lines
[
lnum
])
:
break
lnum
=
lnum
-
1
lnum
=
lnum
-
1
return
lines
,
lnum
return
lines
,
lnum
...
...
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