From 7fabfde0ef0447d3fbc02762c43f744cc7cf95af 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 bf606711cd5f..a1313c0e7811 100644 --- a/src/Mod/Arch/importJSON.py +++ b/src/Mod/Arch/importJSON.py @@ -35,7 +35,8 @@ 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 a6f46e8082d0..73a7a7744ff4 100644 --- a/src/Mod/Material/importFCMat.py +++ b/src/Mod/Material/importFCMat.py @@ -36,7 +36,7 @@ # 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 8e838fe602b7..6fc69f2b6542 100644 --- a/src/Mod/OpenSCAD/prototype.py +++ b/src/Mod/OpenSCAD/prototype.py @@ -11,7 +11,7 @@ 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 fd9591cee54d..42e7f81a7f53 100644 --- a/src/Mod/Path/PathScripts/post/centroid_post.py +++ b/src/Mod/Path/PathScripts/post/centroid_post.py @@ -113,7 +113,7 @@ # 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 ed58d570d6ce..a460f8f56595 100644 --- a/src/Mod/Path/PathScripts/post/dumper_post.py +++ b/src/Mod/Path/PathScripts/post/dumper_post.py @@ -35,7 +35,7 @@ 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 f3942ec1c549..6be0a3e83253 100644 --- a/src/Mod/Path/PathScripts/post/dynapath_post.py +++ b/src/Mod/Path/PathScripts/post/dynapath_post.py @@ -106,7 +106,7 @@ # 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 96f139ac45b2..50d95f1c7327 100644 --- a/src/Mod/Path/PathScripts/post/example_post.py +++ b/src/Mod/Path/PathScripts/post/example_post.py @@ -35,7 +35,7 @@ # 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 e4068cd1a817..c3a7e956801c 100644 --- a/src/Mod/Path/PathScripts/post/example_pre.py +++ b/src/Mod/Path/PathScripts/post/example_pre.py @@ -44,7 +44,7 @@ # 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 d9c8ec7312fa..aecd74f55b6e 100644 --- a/src/Mod/Path/PathScripts/post/fablin_post.py +++ b/src/Mod/Path/PathScripts/post/fablin_post.py @@ -91,7 +91,7 @@ # 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 8795b3dd6d61..8cd76020aa64 100644 --- a/src/Mod/Path/PathScripts/post/grbl_post.py +++ b/src/Mod/Path/PathScripts/post/grbl_post.py @@ -99,7 +99,7 @@ # 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 80f4c3e36713..b3e186ce56e4 100644 --- a/src/Mod/Path/PathScripts/post/linuxcnc_post.py +++ b/src/Mod/Path/PathScripts/post/linuxcnc_post.py @@ -97,7 +97,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/opensbp_post.py b/src/Mod/Path/PathScripts/post/opensbp_post.py index 8c64b7de915b..495f7a36629c 100644 --- a/src/Mod/Path/PathScripts/post/opensbp_post.py +++ b/src/Mod/Path/PathScripts/post/opensbp_post.py @@ -80,7 +80,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 CurrentState = {} diff --git a/src/Mod/Path/PathScripts/post/opensbp_pre.py b/src/Mod/Path/PathScripts/post/opensbp_pre.py index a9d1ac715f2e..61db9d9db4f2 100644 --- a/src/Mod/Path/PathScripts/post/opensbp_pre.py +++ b/src/Mod/Path/PathScripts/post/opensbp_pre.py @@ -55,7 +55,7 @@ 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 be264d618025..df22d91b888b 100644 --- a/src/Mod/Path/PathScripts/post/philips_post.py +++ b/src/Mod/Path/PathScripts/post/philips_post.py @@ -290,7 +290,7 @@ def mkHeader(selection): 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 1efe599c2fe6..1df990ef72e5 100644 --- a/src/Mod/Path/PathScripts/post/rml_post.py +++ b/src/Mod/Path/PathScripts/post/rml_post.py @@ -39,7 +39,7 @@ 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 82c77f77fe23..83de3eec0eb2 100644 --- a/src/Mod/Path/PathScripts/post/slic3r_pre.py +++ b/src/Mod/Path/PathScripts/post/slic3r_pre.py @@ -30,7 +30,7 @@ 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 98221a605478..051bbd4ae19e 100644 --- a/src/Mod/Path/PathScripts/post/smoothie_post.py +++ b/src/Mod/Path/PathScripts/post/smoothie_post.py @@ -108,7 +108,7 @@ # 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 3644b50fd35f..186feb9d0d2a 100644 --- a/src/Mod/Spreadsheet/importXLSX.py +++ b/src/Mod/Spreadsheet/importXLSX.py @@ -62,7 +62,7 @@ except ValueError: gui = False else: gui = True -if open.__module__ == '__builtin__': +if open.__module__ in ['__builtin__','io']: pythonopen = open