##// 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 from IPython.core.ultratb import ColorTB, VerboseTB
15 from IPython.core.ultratb import ColorTB, VerboseTB
16 from IPython.testing import tools as tt
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 from IPython.utils.syspathcontext import prepended_to_syspath
18 from IPython.utils.syspathcontext import prepended_to_syspath
19
19
20 file_1 = """1
20 file_1 = """1
@@ -177,6 +177,20 b' class IndentationErrorTest(unittest.TestCase):'
177 with tt.AssertPrints("zoon()", suppress=False):
177 with tt.AssertPrints("zoon()", suppress=False):
178 ip.magic('run %s' % fname)
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 se_file_1 = """1
194 se_file_1 = """1
181 2
195 2
182 7/
196 7/
@@ -743,6 +743,7 b' class FrameInfo:'
743 lineno: Tuple[int]
743 lineno: Tuple[int]
744 # number of context lines to use
744 # number of context lines to use
745 context: Optional[int]
745 context: Optional[int]
746 raw_lines: List[str]
746
747
747 @classmethod
748 @classmethod
748 def _from_stack_data_FrameInfo(cls, frame_info):
749 def _from_stack_data_FrameInfo(cls, frame_info):
@@ -777,8 +778,13 b' class FrameInfo:'
777
778
778 # self.lines = []
779 # self.lines = []
779 if sd is None:
780 if sd is None:
780 ix = inspect.getsourcelines(frame)
781 try:
781 self.raw_lines = ix[0]
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 @property
789 @property
784 def variables_in_executing_piece(self):
790 def variables_in_executing_piece(self):
General Comments 0
You need to be logged in to leave comments. Login now