Commit c8092063 authored by Charles Ferguson's avatar Charles Ferguson
Browse files

Compatibility for Python 3.

Under Python 3, the 'new' module for creating classes is no longer
present. Instead this operation is in the 'types' module.
parent 1d9fc9a7
......@@ -4,10 +4,18 @@ Timer management for setting arbitrary timeouts on OSX and Linux.
"""
import os
import new
import signal
import time
try:
# Python 2 can use the 'new' module
import new
new_class = new.classobj
except ImportError:
# Python 3 must use the 'types' module
import types
new_class = types.new_class
from functools import total_ordering
......@@ -246,7 +254,7 @@ class Timer(object):
self.start_time = None
self.end_time = None
if self.timeout_in_seconds:
self.exception = new.classobj('Timeout_%s' % (self.idname,), (TimerTimeout,), {})
self.exception = new_class('Timeout_%s' % (self.idname,), (TimerTimeout,), {})
else:
self.exception = TimerTimeout
self.alarm = None
......
File mode changed from 100644 to 100755
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment