]> granicus.if.org Git - python/commitdiff
Merged revisions 73114 via svnmerge from
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 1 Jun 2009 21:28:37 +0000 (21:28 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 1 Jun 2009 21:28:37 +0000 (21:28 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73114 | amaury.forgeotdarc | 2009-06-01 22:53:18 +0200 (lun., 01 juin 2009) | 3 lines

  #4547: When debugging a very large function, it was not always
  possible to update the lineno attribute of the current frame.
........

Lib/test/test_trace.py
Misc/NEWS
Objects/frameobject.c

index ecb588c262694f66240d01d92cfe43b39c65b115..43134e98bd49beee75eab8b428596ccb6107555f 100644 (file)
@@ -741,6 +741,23 @@ class JumpTestCase(unittest.TestCase):
     def test_19_no_jump_without_trace_function(self):
         no_jump_without_trace_function()
 
+    def test_20_large_function(self):
+        d = {}
+        exec("""def f(output):        # line 0
+            x = 0                     # line 1
+            y = 1                     # line 2
+            '''                       # line 3
+            %s                        # lines 4-1004
+            '''                       # line 1005
+            x += 1                    # line 1006
+            output.append(x)          # line 1007
+            return""" % ('\n' * 1000,), d)
+        f = d['f']
+
+        f.jump = (2, 1007)
+        f.output = [0]
+        self.run_test(f)
+
     def test_jump_to_firstlineno(self):
         # This tests that PDB can jump back to the first line in a
         # file.  See issue #1689458.  It can only be triggered in a
index 570caeaf9c7bba7e301bc02c7b552b4b074f06be..6c39463a2e12e5c641a3cbaafd499c01261ef070 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.1 Release Candidate 2?
 Core and Builtins
 -----------------
 
+- Issue #4547: When debugging a very large function, it was not always
+  possible to update the lineno attribute of the current frame.
+
 - Issue #5330: C functions called with keyword arguments were not reported by
   the various profiling modules (profile, cProfile). Patch by Hagen Fürstenau.
 
index 8bb0f9c6277cf44af4d001428d9e5e8bbd1ca080..a49499286c04a329181e716939b7e61c50e9843e 100644 (file)
@@ -69,7 +69,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
        int new_iblock = 0;             /* The new value of f_iblock */
        unsigned char *code = NULL;     /* The bytecode for the frame... */
        Py_ssize_t code_len = 0;        /* ...and its length */
-       char *lnotab = NULL;            /* Iterating over co_lnotab */
+       unsigned char *lnotab = NULL;   /* Iterating over co_lnotab */
        Py_ssize_t lnotab_len = 0;      /* (ditto) */
        int offset = 0;                 /* (ditto) */
        int line = 0;                   /* (ditto) */
@@ -131,7 +131,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
                /* Find the bytecode offset for the start of the given
                 * line, or the first code-owning line after it. */
                PyBytes_AsStringAndSize(f->f_code->co_lnotab,
-                                       &lnotab, &lnotab_len);
+                                       &(char*)lnotab, &lnotab_len);
                addr = 0;
                line = f->f_code->co_firstlineno;
                new_lasti = -1;