diff options
author | Steven Knight <knight@baldmt.com> | 2010-05-19 16:41:32 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2010-05-19 16:41:32 (GMT) |
commit | 093701db6b7b705bc0f73afc6c933a32c4df100a (patch) | |
tree | 4407cabad6f5c89ba64993a38e4c4d1733e9c2e5 | |
parent | 435a720015d6950aac38096509290d7577b08688 (diff) | |
download | SCons-093701db6b7b705bc0f73afc6c933a32c4df100a.zip SCons-093701db6b7b705bc0f73afc6c933a32c4df100a.tar.gz SCons-093701db6b7b705bc0f73afc6c933a32c4df100a.tar.bz2 |
Convert SubstitutionEnvironment from an old-style class to a new-style class.
-rw-r--r-- | src/engine/SCons/Environment.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 14 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 44f916d..96f42da 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -335,7 +335,7 @@ def is_valid_construction_var(varstr): -class SubstitutionEnvironment: +class SubstitutionEnvironment(object): """Base class for different flavors of construction environments. This class contains a minimal set of methods that handle contruction diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 54e738f..bd653ec 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -1356,7 +1356,7 @@ def make_path_relative(path): # ASPN: Python Cookbook : Dynamically added methods to a class # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81732 -def AddMethod(object, function, name = None): +def AddMethod(obj, function, name=None): """ Adds either a bound method to an instance or an unbound method to a class. If name is ommited the name of the specified function @@ -1376,14 +1376,12 @@ def AddMethod(object, function, name = None): else: function = RenameFunction(function, name) - try: - klass = object.__class__ - except AttributeError: - # "object" is really a class, so it gets an unbound method. - object.__dict__[name] = types.MethodType(function, None, object) + if hasattr(obj, '__class__') and obj.__class__ != types.TypeType: + # "obj" is an instance, so it gets a bound method. + setattr(obj, name, types.MethodType(function, obj, cls)) else: - # "object" is really an instance, so it gets a bound method. - object.__dict__[name] = types.MethodType(function, object, klass) + # "obj" is a class, so it gets an unbound method. + setattr(obj, name, types.MethodType(function, None, obj)) def RenameFunction(function, name): """ |