From ce0f871cbadfa2e6fc39d8a4c9fa9c8939e05e4d Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 27 Oct 2018 16:04:51 -0300 Subject: [PATCH] py3 compatibility fixes --- src/Mod/Arch/importJSON.py | 3 ++- src/Mod/Material/importFCMat.py | 2 +- src/Mod/OpenSCAD/prototype.py | 2 +- src/Mod/Path/PathScripts/post/centroid_post.py | 2 +- src/Mod/Path/PathScripts/post/dumper_post.py | 2 +- src/Mod/Path/PathScripts/post/dynapath_post.py | 2 +- src/Mod/Path/PathScripts/post/example_post.py | 2 +- src/Mod/Path/PathScripts/post/example_pre.py | 2 +- src/Mod/Path/PathScripts/post/fablin_post.py | 2 +- src/Mod/Path/PathScripts/post/grbl_post.py | 2 +- src/Mod/Path/PathScripts/post/linuxcnc_post.py | 2 +- src/Mod/Path/PathScripts/post/opensbp_post.py | 2 +- src/Mod/Path/PathScripts/post/opensbp_pre.py | 2 +- src/Mod/Path/PathScripts/post/philips_post.py | 2 +- src/Mod/Path/PathScripts/post/rml_post.py | 2 +- src/Mod/Path/PathScripts/post/slic3r_pre.py | 2 +- src/Mod/Path/PathScripts/post/smoothie_post.py | 2 +- src/Mod/Spreadsheet/importXLSX.py | 2 +- 18 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/Mod/Arch/importJSON.py b/src/Mod/Arch/importJSON.py index bf606711cd..a1313c0e78 100644 --- a/src/Mod/Arch/importJSON.py +++ b/src/Mod/Arch/importJSON.py @@ -35,7 +35,8 @@ else: def translate(ctxt, txt): return txt -if open.__module__ == '__builtin__': pythonopen = open +if open.__module__ in ['__builtin__','io']: + pythonopen = open def export(exportList, filename): diff --git a/src/Mod/Material/importFCMat.py b/src/Mod/Material/importFCMat.py index a6f46e8082..73a7a7744f 100644 --- a/src/Mod/Material/importFCMat.py +++ b/src/Mod/Material/importFCMat.py @@ -36,7 +36,7 @@ __url__ = "http://www.freecadweb.org" # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/OpenSCAD/prototype.py b/src/Mod/OpenSCAD/prototype.py index 8e838fe602..6fc69f2b65 100644 --- a/src/Mod/OpenSCAD/prototype.py +++ b/src/Mod/OpenSCAD/prototype.py @@ -11,7 +11,7 @@ from OpenSCADFeatures import * from OpenSCAD2Dgeom import * from OpenSCADUtils import * -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open # to distinguish python built-in open function from the one declared here def openscadmesh(doc,scadstr,objname): diff --git a/src/Mod/Path/PathScripts/post/centroid_post.py b/src/Mod/Path/PathScripts/post/centroid_post.py index fd9591cee5..42e7f81a7f 100644 --- a/src/Mod/Path/PathScripts/post/centroid_post.py +++ b/src/Mod/Path/PathScripts/post/centroid_post.py @@ -113,7 +113,7 @@ TOOL_CHANGE = '''''' # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open def processArguments(argstring): diff --git a/src/Mod/Path/PathScripts/post/dumper_post.py b/src/Mod/Path/PathScripts/post/dumper_post.py index ed58d570d6..a460f8f565 100644 --- a/src/Mod/Path/PathScripts/post/dumper_post.py +++ b/src/Mod/Path/PathScripts/post/dumper_post.py @@ -35,7 +35,7 @@ now = datetime.datetime.now() SHOW_EDITOR = True # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/dynapath_post.py b/src/Mod/Path/PathScripts/post/dynapath_post.py index f3942ec1c5..6be0a3e832 100644 --- a/src/Mod/Path/PathScripts/post/dynapath_post.py +++ b/src/Mod/Path/PathScripts/post/dynapath_post.py @@ -106,7 +106,7 @@ TOOL_CHANGE = '''''' # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/example_post.py b/src/Mod/Path/PathScripts/post/example_post.py index 96f139ac45..50d95f1c73 100644 --- a/src/Mod/Path/PathScripts/post/example_post.py +++ b/src/Mod/Path/PathScripts/post/example_post.py @@ -35,7 +35,7 @@ now = datetime.datetime.now() # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/example_pre.py b/src/Mod/Path/PathScripts/post/example_pre.py index e4068cd1a8..c3a7e95680 100644 --- a/src/Mod/Path/PathScripts/post/example_pre.py +++ b/src/Mod/Path/PathScripts/post/example_pre.py @@ -44,7 +44,7 @@ else: # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/fablin_post.py b/src/Mod/Path/PathScripts/post/fablin_post.py index d9c8ec7312..aecd74f55b 100644 --- a/src/Mod/Path/PathScripts/post/fablin_post.py +++ b/src/Mod/Path/PathScripts/post/fablin_post.py @@ -91,7 +91,7 @@ TOOL_CHANGE = '''''' # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open def processArguments(argstring): diff --git a/src/Mod/Path/PathScripts/post/grbl_post.py b/src/Mod/Path/PathScripts/post/grbl_post.py index 8795b3dd6d..8cd76020aa 100644 --- a/src/Mod/Path/PathScripts/post/grbl_post.py +++ b/src/Mod/Path/PathScripts/post/grbl_post.py @@ -99,7 +99,7 @@ SUPPRESS_TOOL_CHANGE=0 # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/linuxcnc_post.py b/src/Mod/Path/PathScripts/post/linuxcnc_post.py index 80f4c3e367..b3e186ce56 100644 --- a/src/Mod/Path/PathScripts/post/linuxcnc_post.py +++ b/src/Mod/Path/PathScripts/post/linuxcnc_post.py @@ -97,7 +97,7 @@ POST_OPERATION = '''''' TOOL_CHANGE = '''''' # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/opensbp_post.py b/src/Mod/Path/PathScripts/post/opensbp_post.py index 8c64b7de91..495f7a3662 100644 --- a/src/Mod/Path/PathScripts/post/opensbp_post.py +++ b/src/Mod/Path/PathScripts/post/opensbp_post.py @@ -80,7 +80,7 @@ POST_OPERATION = '''''' TOOL_CHANGE = '''''' # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open CurrentState = {} diff --git a/src/Mod/Path/PathScripts/post/opensbp_pre.py b/src/Mod/Path/PathScripts/post/opensbp_pre.py index a9d1ac715f..61db9d9db4 100644 --- a/src/Mod/Path/PathScripts/post/opensbp_pre.py +++ b/src/Mod/Path/PathScripts/post/opensbp_pre.py @@ -55,7 +55,7 @@ AXIS = 'X','Y','Z','A','B' #OpenSBP always puts multiaxis move parameters in th SPEEDS = 'XY','Z','A','B' # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/philips_post.py b/src/Mod/Path/PathScripts/post/philips_post.py index be264d6180..df22d91b88 100644 --- a/src/Mod/Path/PathScripts/post/philips_post.py +++ b/src/Mod/Path/PathScripts/post/philips_post.py @@ -290,7 +290,7 @@ GCODE_FOOTER = "M30" linenr = 0 # variable has to be global because it is used by linenumberify and export -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/rml_post.py b/src/Mod/Path/PathScripts/post/rml_post.py index 1efe599c2f..1df990ef72 100644 --- a/src/Mod/Path/PathScripts/post/rml_post.py +++ b/src/Mod/Path/PathScripts/post/rml_post.py @@ -39,7 +39,7 @@ import Part import PathScripts.PostUtils as PostUtils # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/slic3r_pre.py b/src/Mod/Path/PathScripts/post/slic3r_pre.py index 82c77f77fe..83de3eec0e 100644 --- a/src/Mod/Path/PathScripts/post/slic3r_pre.py +++ b/src/Mod/Path/PathScripts/post/slic3r_pre.py @@ -30,7 +30,7 @@ import Path import FreeCAD # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open diff --git a/src/Mod/Path/PathScripts/post/smoothie_post.py b/src/Mod/Path/PathScripts/post/smoothie_post.py index 98221a6054..051bbd4ae1 100644 --- a/src/Mod/Path/PathScripts/post/smoothie_post.py +++ b/src/Mod/Path/PathScripts/post/smoothie_post.py @@ -108,7 +108,7 @@ TOOL_CHANGE = '''''' # to distinguish python built-in open function from the one declared below -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open def processArguments(argstring): diff --git a/src/Mod/Spreadsheet/importXLSX.py b/src/Mod/Spreadsheet/importXLSX.py index 3644b50fd3..186feb9d0d 100644 --- a/src/Mod/Spreadsheet/importXLSX.py +++ b/src/Mod/Spreadsheet/importXLSX.py @@ -62,7 +62,7 @@ try: import FreeCADGui except ValueError: gui = False else: gui = True -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open