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
fcf66962
Kaydet (Commit)
fcf66962
authored
Eki 12, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #1550524: better heuristics to find correct class definition
in inspect.findsource(). (backport from rev. 52299)
üst
8984370c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
inspect.py
Lib/inspect.py
+17
-2
No files found.
Lib/inspect.py
Dosyayı görüntüle @
fcf66962
...
...
@@ -472,9 +472,24 @@ def findsource(object):
if
isclass
(
object
):
name
=
object
.
__name__
pat
=
re
.
compile
(
r'^\s*class\s*'
+
name
+
r'\b'
)
pat
=
re
.
compile
(
r'^(\s*)class\s*'
+
name
+
r'\b'
)
# make some effort to find the best matching class definition:
# use the one with the least indentation, which is the one
# that's most probably not inside a function definition.
candidates
=
[]
for
i
in
range
(
len
(
lines
)):
if
pat
.
match
(
lines
[
i
]):
return
lines
,
i
match
=
pat
.
match
(
lines
[
i
])
if
match
:
# if it's at toplevel, it's already the best one
if
lines
[
i
][
0
]
==
'c'
:
return
lines
,
i
# else add whitespace to candidate list
candidates
.
append
((
match
.
group
(
1
),
i
))
if
candidates
:
# this will sort by whitespace, and by line number,
# less whitespace first
candidates
.
sort
()
return
lines
,
candidates
[
0
][
1
]
else
:
raise
IOError
(
'could not find class definition'
)
...
...
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