PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.

Thu, 24 Sep 2020 19:13:41 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 24 Sep 2020 19:13:41 +0200
changeset 7714
79bde78e3e16
parent 7713
ab61050423ef
child 7715
ae49e290890d

PythonDisViewer: fixed an issue caused by Python < 3.8.0 not knowing about co_posonlyargcount of code objects.

eric6/DebugClients/Python/DebugBase.py file | annotate | diff | comparison | revisions
eric6/UI/PythonDisViewer.py file | annotate | diff | comparison | revisions
--- a/eric6/DebugClients/Python/DebugBase.py	Wed Sep 23 19:17:00 2020 +0200
+++ b/eric6/DebugClients/Python/DebugBase.py	Thu Sep 24 19:13:41 2020 +0200
@@ -969,6 +969,11 @@
             "freevars": [str(var) for var in co.co_freevars],
             "cellvars": [str(var) for var in co.co_cellvars],
         }
+        try:
+            disDict["codeinfo"]["posonlyargcount"] = co.co_posonlyargcount
+        except AttributeError:
+            # does not exist prior to 3.8.0
+            disDict["codeinfo"]["posonlyargcount"] = 0
         
         return disDict
     
--- a/eric6/UI/PythonDisViewer.py	Wed Sep 23 19:17:00 2020 +0200
+++ b/eric6/UI/PythonDisViewer.py	Thu Sep 24 19:13:41 2020 +0200
@@ -416,12 +416,11 @@
         @return dictionary containing the code info data
         @rtype dict
         """
-        return {
+        codeInfoDict = {
             "name": co.co_name,
             "filename": co.co_filename,
             "firstlineno": co.co_firstlineno,
             "argcount": co.co_argcount,
-            "posonlyargcount": co.co_posonlyargcount,
             "kwonlyargcount": co.co_kwonlyargcount,
             "nlocals": co.co_nlocals,
             "stacksize": co.co_stacksize,
@@ -432,6 +431,11 @@
             "freevars": [str(var) for var in co.co_freevars],
             "cellvars": [str(var) for var in co.co_cellvars],
         }
+        try:
+            codeInfoDict["posonlyargcount"] = co.co_posonlyargcount
+        except AttributeError:
+            # does not exist prior to 3.8.0
+            codeInfoDict["posonlyargcount"] = 0
     
     def __loadDIS(self):
         """

eric ide

mercurial