From ef22d5202df0e57cbf6d1ea3d87334fa4ad62d5f Mon Sep 17 00:00:00 2001 From: looooo Date: Wed, 17 May 2017 18:24:17 +0200 Subject: [PATCH] py3: define xrange for python3 this is done in files where the xrange is used. replace this with range once python2 is not supported anymore. issue 0000995 --- src/Mod/Arch/Dice3DS/dom3ds.py | 3 +++ src/Mod/Arch/Dice3DS/util.py | 4 ++++ src/Mod/Part/CompoundTools/CompoundFilter.py | 4 ++++ src/Mod/Path/PathScripts/PathDrilling.py | 5 +++++ src/Mod/Path/PathScripts/PathJob.py | 5 +++++ src/Mod/Path/PathScripts/PathSurface.py | 5 +++++ 6 files changed, 26 insertions(+) diff --git a/src/Mod/Arch/Dice3DS/dom3ds.py b/src/Mod/Arch/Dice3DS/dom3ds.py index 29f80940f7..84e140a17e 100644 --- a/src/Mod/Arch/Dice3DS/dom3ds.py +++ b/src/Mod/Arch/Dice3DS/dom3ds.py @@ -20,6 +20,9 @@ import os, sys, struct import numpy +# xrange is not available in python3 +if sys.version_info.major >= 3: + xrange = range # Exceptions diff --git a/src/Mod/Arch/Dice3DS/util.py b/src/Mod/Arch/Dice3DS/util.py index 12d8d84d9e..c19e928890 100644 --- a/src/Mod/Arch/Dice3DS/util.py +++ b/src/Mod/Arch/Dice3DS/util.py @@ -7,7 +7,11 @@ Defines some routines for calculating normals and transforming points. """ import numpy +import sys +# xrange is not available in python3 +if sys.version_info.major >= 3: + xrange = range # Can push numpy.float64 (or even numpy.float80) into this if you # would like to use higher precision when calculating; results will be diff --git a/src/Mod/Part/CompoundTools/CompoundFilter.py b/src/Mod/Part/CompoundTools/CompoundFilter.py index 805f6f07e5..584d0855cb 100644 --- a/src/Mod/Part/CompoundTools/CompoundFilter.py +++ b/src/Mod/Part/CompoundTools/CompoundFilter.py @@ -29,7 +29,11 @@ __doc__ = "Compound Filter: remove some children from a compound (features)." import FreeCAD import Part import math +import sys +# xrange is not available in python3 +if sys.version_info.major >= 3: + xrange = range # OCC's Precision::Confusion; should have taken this from FreeCAD but haven't found; unlikely to ever change (DeepSOIC) DistConfusion = 1e-7 diff --git a/src/Mod/Path/PathScripts/PathDrilling.py b/src/Mod/Path/PathScripts/PathDrilling.py index ab428cbf83..8655906f7c 100644 --- a/src/Mod/Path/PathScripts/PathDrilling.py +++ b/src/Mod/Path/PathScripts/PathDrilling.py @@ -23,6 +23,7 @@ # *************************************************************************** from __future__ import print_function +import sys import FreeCAD # from FreeCAD import Vector import Path @@ -35,6 +36,10 @@ from PathScripts.PathUtils import fmt import ArchPanel +# xrange is not available in python3 +if sys.version_info.major >= 3: + xrange = range + LOG_MODULE = 'PathDrilling' PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) PathLog.trackModule('PathDrilling') diff --git a/src/Mod/Path/PathScripts/PathJob.py b/src/Mod/Path/PathScripts/PathJob.py index fcc4682c5e..1f1a28a3ec 100644 --- a/src/Mod/Path/PathScripts/PathJob.py +++ b/src/Mod/Path/PathScripts/PathJob.py @@ -28,6 +28,11 @@ from PySide import QtCore, QtGui from PathScripts.PathPostProcessor import PostProcessor from PathScripts.PathPreferences import PathPreferences import Draft +import sys + +# xrange is not available in python3 +if sys.version_info.major >= 3: + xrange = range FreeCADGui = None diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py index 9619c7b657..5f5899ffe3 100644 --- a/src/Mod/Path/PathScripts/PathSurface.py +++ b/src/Mod/Path/PathScripts/PathSurface.py @@ -27,6 +27,11 @@ import FreeCAD import Path from PathScripts import PathUtils import PathScripts.PathLog as PathLog +import sys + +# xrange is not available in python3 +if sys.version_info.major >= 3: + xrange = range LOG_MODULE = 'PathSurface' PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE)