src/eric7/DebugClients/Python/DebugBase.py

branch
eric7
changeset 10287
0322776373ed
parent 10275
76a32e9f16b4
child 10289
490388ca210c
diff -r 612ce5e79d08 -r 0322776373ed src/eric7/DebugClients/Python/DebugBase.py
--- a/src/eric7/DebugClients/Python/DebugBase.py	Sun Nov 05 17:17:29 2023 +0100
+++ b/src/eric7/DebugClients/Python/DebugBase.py	Mon Nov 06 12:00:55 2023 +0100
@@ -678,18 +678,25 @@
                     frame.f_globals.get("__file__"), frame.f_code.co_firstlineno
                 ] = False
                 return False
-            lineNo = frame.f_code.co_firstlineno
-            lineNumbers = [lineNo]
 
-            co_lnotab = frame.f_code.co_lnotab[1::2]
+            try:
+                lineNumbers = [
+                    l for _, _, l in frame.f_code.co_lines() if l is not None
+                ]
+            except AttributeError:
+                # backward compatibility code for Python 3.10 and below
+                lineNo = frame.f_code.co_firstlineno
+                lineNumbers = [lineNo]
 
-            # No need to handle special case if a lot of lines between
-            # (e.g. closure), because the additional lines won't cause a bp
-            for co_lno in co_lnotab:
-                if co_lno >= 0x80:
-                    lineNo -= 0x100
-                lineNo += co_lno
-                lineNumbers.append(lineNo)
+                co_lnotab = frame.f_code.co_lnotab[1::2]
+
+                # No need to handle special case if a lot of lines between
+                # (e.g. closure), because the additional lines won't cause a bp
+                for co_lno in co_lnotab:
+                    if co_lno >= 0x80:
+                        lineNo -= 0x100
+                    lineNo += co_lno
+                    lineNumbers.append(lineNo)
 
             for bp in Breakpoint.breakInFile[filename]:
                 if bp in lineNumbers:

eric ide

mercurial