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
91cb298f
Kaydet (Commit)
91cb298f
authored
Agu 24, 2018
tarafından
Vladimir Matveev
Kaydeden (comit)
Tal Einat
Agu 24, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-6700: Fix inspect.getsourcelines for module level frames/tracebacks (GH-8864)
üst
075b3c32
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
3 deletions
+26
-3
inspect.py
Lib/inspect.py
+6
-1
inspect_fodder.py
Lib/test/inspect_fodder.py
+6
-0
test_inspect.py
Lib/test/test_inspect.py
+12
-2
2018-08-22-17-43-52.bpo-6700.hp7C4B.rst
...WS.d/next/Library/2018-08-22-17-43-52.bpo-6700.hp7C4B.rst
+2
-0
No files found.
Lib/inspect.py
Dosyayı görüntüle @
91cb298f
...
...
@@ -954,7 +954,12 @@ def getsourcelines(object):
object
=
unwrap
(
object
)
lines
,
lnum
=
findsource
(
object
)
if
ismodule
(
object
):
if
istraceback
(
object
):
object
=
object
.
tb_frame
# for module or frame that corresponds to module, return all source lines
if
(
ismodule
(
object
)
or
(
isframe
(
object
)
and
object
.
f_code
.
co_name
==
"<module>"
)):
return
lines
,
0
else
:
return
getblock
(
lines
[
lnum
:]),
lnum
+
1
...
...
Lib/test/inspect_fodder.py
Dosyayı görüntüle @
91cb298f
...
...
@@ -74,3 +74,9 @@ class FesteringGob(MalodorousPervert, ParrotDroppings):
async
def
lobbest
(
grenade
):
pass
currentframe
=
inspect
.
currentframe
()
try
:
raise
Exception
()
except
:
tb
=
sys
.
exc_info
()[
2
]
Lib/test/test_inspect.py
Dosyayı görüntüle @
91cb298f
...
...
@@ -344,7 +344,7 @@ class GetSourceBase(unittest.TestCase):
def
sourcerange
(
self
,
top
,
bottom
):
lines
=
self
.
source
.
split
(
"
\n
"
)
return
"
\n
"
.
join
(
lines
[
top
-
1
:
bottom
])
+
"
\n
"
return
"
\n
"
.
join
(
lines
[
top
-
1
:
bottom
])
+
(
"
\n
"
if
bottom
else
""
)
def
assertSourceEqual
(
self
,
obj
,
top
,
bottom
):
self
.
assertEqual
(
inspect
.
getsource
(
obj
),
...
...
@@ -527,6 +527,16 @@ class TestRetrievingSourceCode(GetSourceBase):
def
test_getsource_on_code_object
(
self
):
self
.
assertSourceEqual
(
mod
.
eggs
.
__code__
,
12
,
18
)
class
TestGettingSourceOfToplevelFrames
(
GetSourceBase
):
fodderModule
=
mod
def
test_range_toplevel_frame
(
self
):
self
.
maxDiff
=
None
self
.
assertSourceEqual
(
mod
.
currentframe
,
1
,
None
)
def
test_range_traceback_toplevel_frame
(
self
):
self
.
assertSourceEqual
(
mod
.
tb
,
1
,
None
)
class
TestDecorators
(
GetSourceBase
):
fodderModule
=
mod2
...
...
@@ -3870,7 +3880,7 @@ def test_main():
TestBoundArguments
,
TestSignaturePrivateHelpers
,
TestSignatureDefinitions
,
TestIsDataDescriptor
,
TestGetClosureVars
,
TestUnwrap
,
TestMain
,
TestReload
,
TestGetCoroutineState
TestGetCoroutineState
,
TestGettingSourceOfToplevelFrames
)
if
__name__
==
"__main__"
:
...
...
Misc/NEWS.d/next/Library/2018-08-22-17-43-52.bpo-6700.hp7C4B.rst
0 → 100644
Dosyayı görüntüle @
91cb298f
Fix inspect.getsourcelines for module level frames/tracebacks.
Patch by Vladimir Matveev.
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