##// END OF EJS Templates
Patch bundled simplegeneric for Python 3 compatibility.
Thomas Kluyver -
Show More
@@ -1,5 +1,6 b''
1 1 """This is version 0.7 of Philip J. Eby's simplegeneric module
2 (http://pypi.python.org/pypi/simplegeneric)
2 (http://pypi.python.org/pypi/simplegeneric), patched to work with Python 3,
3 which doesn't support old-style classes.
3 4 """
4 5
5 6 #Name: simplegeneric
@@ -12,7 +13,11 b''
12 13
13 14 __all__ = ["generic"]
14 15
16 try:
15 17 from types import ClassType, InstanceType
18 except ImportError:
19 classtypes = type
20 else:
16 21 classtypes = type, ClassType
17 22
18 23 def generic(func):
@@ -29,7 +34,12 b' def generic(func):'
29 34 else:
30 35 return func(*args, **kw)
31 36
32 _by_type = {object: func, InstanceType: _by_class}
37 _by_type = {object: func}
38 try:
39 _by_type[InstanceType] = _by_class
40 except NameError: # Python 3
41 pass
42
33 43 _gbt = _by_type.get
34 44
35 45 def when_type(*types):
General Comments 0
You need to be logged in to leave comments. Login now