summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-03-30 03:17:24 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-03-30 03:17:24 (GMT)
commit1b145927d725b136b987df220dff0ec7529b6f29 (patch)
treea597728e07ca0af44f923c7f056aec396f61e784 /Lib/test/test_inspect.py
parent9098472299a18471f29b3ed471376be2d29178be (diff)
downloadcpython-1b145927d725b136b987df220dff0ec7529b6f29.zip
cpython-1b145927d725b136b987df220dff0ec7529b6f29.tar.gz
cpython-1b145927d725b136b987df220dff0ec7529b6f29.tar.bz2
#17526: fix an IndexError raised while passing code without filename to inspect.findsource(). Initial patch by Tyler Doyle.
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 6e3f04e..9f5e93b 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -416,6 +416,12 @@ class TestBuggyCases(GetSourceBase):
finally:
del linecache.cache[co.co_filename]
+ def test_findsource_without_filename(self):
+ for fname in ['', '<string>']:
+ co = compile('x=1', fname, "exec")
+ self.assertRaises(IOError, inspect.findsource, co)
+ self.assertRaises(IOError, inspect.getsource, co)
+
class TestNoEOL(GetSourceBase):
def __init__(self, *args, **kwargs):
self.tempdir = TESTFN + '_dir'