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
703f7c4b
Kaydet (Commit)
703f7c4b
authored
Haz 11, 2011
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge 3.2 (#9284)
üst
3ae42726
9620cc04
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
2 deletions
+26
-2
inspect.py
Lib/inspect.py
+6
-2
test_inspect.py
Lib/test/test_inspect.py
+17
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
Dosyayı görüntüle @
703f7c4b
...
...
@@ -518,9 +518,13 @@ def findsource(object):
or code object. The source code is returned as a list of all the lines
in the file and the line number indexes a line in that list. An IOError
is raised if the source code cannot be retrieved."""
file
=
getsourcefile
(
object
)
if
not
file
:
file
=
getfile
(
object
)
sourcefile
=
getsourcefile
(
object
)
if
not
sourcefile
and
file
[
0
]
+
file
[
-
1
]
!=
'<>'
:
raise
IOError
(
'source code not available'
)
file
=
sourcefile
if
sourcefile
else
file
module
=
getmodule
(
object
,
file
)
if
module
:
lines
=
linecache
.
getlines
(
file
,
module
.
__dict__
)
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
703f7c4b
...
...
@@ -298,6 +298,23 @@ class TestRetrievingSourceCode(GetSourceBase):
del
sys
.
modules
[
name
]
inspect
.
getmodule
(
compile
(
'a=10'
,
''
,
'single'
))
def
test_proceed_with_fake_filename
(
self
):
'''doctest monkeypatches linecache to enable inspection'''
fn
,
source
=
'<test>'
,
'def x(): pass
\n
'
getlines
=
linecache
.
getlines
def
monkey
(
filename
,
module_globals
=
None
):
if
filename
==
fn
:
return
source
.
splitlines
(
True
)
else
:
return
getlines
(
filename
,
module_globals
)
linecache
.
getlines
=
monkey
try
:
ns
=
{}
exec
(
compile
(
source
,
fn
,
'single'
),
ns
)
inspect
.
getsource
(
ns
[
"x"
])
finally
:
linecache
.
getlines
=
getlines
class
TestDecorators
(
GetSourceBase
):
fodderModule
=
mod2
...
...
Misc/NEWS
Dosyayı görüntüle @
703f7c4b
...
...
@@ -190,6 +190,9 @@ Library
- Issue #12240: Allow multiple setup hooks in packaging'
s
setup
.
cfg
files
.
Original
patch
by
Erik
Bray
.
-
Issue
#
9284
:
Allow
inspect
.
findsource
()
to
find
the
source
of
doctest
functions
.
-
Issue
#
11595
:
Fix
assorted
bugs
in
packaging
.
util
.
cfg_to_args
,
a
compatibility
helper
for
the
distutils
-
packaging
transition
.
Original
patch
by
Erik
Bray
.
...
...
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