diff options
Diffstat (limited to 'klippy/util.py')
-rw-r--r-- | klippy/util.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/klippy/util.py b/klippy/util.py index 0321014e..6d110e47 100644 --- a/klippy/util.py +++ b/klippy/util.py @@ -91,6 +91,27 @@ def dump_mcu_build(): ###################################################################### +# Python2 wrapper hacks +###################################################################### + +def setup_python2_wrappers(): + if sys.version_info.major >= 3: + return + # Add module hacks so that common Python3 module imports work in Python2 + import Queue, io, StringIO, ConfigParser, time + sys.modules["queue"] = Queue + io.StringIO = StringIO.StringIO + time.process_time = time.clock + sys.modules["configparser"] = ConfigParser + OrigRawConfigParser = ConfigParser.RawConfigParser + def RCP(strict=False, *args, **kwargs): + return OrigRawConfigParser(*args, **kwargs) + RCP.SECTCRE = OrigRawConfigParser.SECTCRE + ConfigParser.RawConfigParser = RCP +setup_python2_wrappers() + + +###################################################################### # General system and software information ###################################################################### |