diff options
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/types.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index ebcffca6e..e31cecfe2 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -817,6 +817,9 @@ class TypeDecorator(TypeEngine): """ return self.impl.compare_values(x, y) + def __repr__(self): + return util.generic_repr(self, to_inspect=self.impl) + class Variant(TypeDecorator): """A wrapping type that selects among a variety of diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 9761aeae9..55b78090a 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -281,14 +281,16 @@ def unbound_method_to_callable(func_or_cls): else: return func_or_cls -def generic_repr(obj, additional_kw=()): +def generic_repr(obj, additional_kw=(), to_inspect=None): """Produce a __repr__() based on direct association of the __init__() specification vs. same-named attributes present. """ + if to_inspect is None: + to_inspect = obj def genargs(): try: - (args, vargs, vkw, defaults) = inspect.getargspec(obj.__init__) + (args, vargs, vkw, defaults) = inspect.getargspec(to_inspect.__init__) except TypeError: return |
