##// END OF EJS Templates
Fix for dynamically evaluated source code traceback...
Matthias Bussonnier -
Show More
@@ -14,7 +14,7 b' from tempfile import TemporaryDirectory'
14 14
15 15 from IPython.core.ultratb import ColorTB, VerboseTB
16 16 from IPython.testing import tools as tt
17 from IPython.testing.decorators import onlyif_unicode_paths
17 from IPython.testing.decorators import onlyif_unicode_paths, skip_without
18 18 from IPython.utils.syspathcontext import prepended_to_syspath
19 19
20 20 file_1 = """1
@@ -177,6 +177,20 b' class IndentationErrorTest(unittest.TestCase):'
177 177 with tt.AssertPrints("zoon()", suppress=False):
178 178 ip.magic('run %s' % fname)
179 179
180 @skip_without("pandas")
181 def test_dynamic_code():
182 code = """
183 import pandas
184 df = pandas.DataFrame([])
185
186 # Important: only fails inside of an "exec" call:
187 exec("df.foobarbaz()")
188 """
189
190 with tt.AssertPrints("Could not get source"):
191 ip.run_cell(code)
192
193
180 194 se_file_1 = """1
181 195 2
182 196 7/
@@ -743,6 +743,7 b' class FrameInfo:'
743 743 lineno: Tuple[int]
744 744 # number of context lines to use
745 745 context: Optional[int]
746 raw_lines: List[str]
746 747
747 748 @classmethod
748 749 def _from_stack_data_FrameInfo(cls, frame_info):
@@ -777,8 +778,13 b' class FrameInfo:'
777 778
778 779 # self.lines = []
779 780 if sd is None:
780 ix = inspect.getsourcelines(frame)
781 self.raw_lines = ix[0]
781 try:
782 # return a list of source lines and a starting line number
783 self.raw_lines = inspect.getsourcelines(frame)[0]
784 except OSError:
785 self.raw_lines = [
786 "'Could not get source, probably due dynamically evaluated source code.'"
787 ]
782 788
783 789 @property
784 790 def variables_in_executing_piece(self):
General Comments 0
You need to be logged in to leave comments. Login now