Skip to content

createmodule.py fails when used with Python 3. #315

@awehrfritz

Description

@awehrfritz

The createmodule.py script fails when used with Python 3.

Here the patch to fix this:

--- createmodule.py.old	2020-02-17 17:44:36.598753762 +1100
+++ createmodule.py.new	2020-02-17 17:45:08.855552992 +1100
@@ -211,10 +211,10 @@ if chdir is not None:
 # Function to format output line with tabs and substituting prefix
 def formatline(item, key, value=None):
     print(item, end=' ')
-    print("\t"*(2-(len(item)+1)/8), end=' ')
+    print("\t"*(2-(len(item)+1)//8), end=' ')
     print(key, end=' ')
     if value is not None:
-        print("\t"*(3-(len(key)+1)/8), end=' ')
+        print("\t"*(3-(len(key)+1)//8), end=' ')
         if prefix is not None:
             # Prefer usage of regular expression to perform a none
             # case-sensitive substitution (cygwin vs cmd.exe)
@@ -227,7 +227,7 @@ def formatline(item, key, value=None):
 
 # Paths first, grouped by variable name
 for sepkey in prependpath.keys():
-    pathkeys = prependpath[sepkey].keys()
+    pathkeys = list(prependpath[sepkey].keys())
     pathkeys.sort()
     for key in pathkeys:
         if sepkey == ":":
@@ -236,7 +236,7 @@ for sepkey in prependpath.keys():
             formatline("prepend-path --delim %s" % sepkey,key,prependpath[sepkey][key])
 
 for sepkey in appendpath.keys():
-    pathkeys = appendpath[sepkey].keys()
+    pathkeys = list(appendpath[sepkey].keys())
     pathkeys.sort()
     for key in pathkeys:
         if sepkey == ":":

I tested this with Python2 and Python3 on Fedora 31 and it works for my case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions