diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-02 10:39:48 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-03-02 10:39:48 -0500 |
| commit | 6750c39a4fc6be01502f3c9b1c6ba2d3f67a030e (patch) | |
| tree | e9b70a288b8d8e09ad572da32900048436f8ebc3 /lib/sqlalchemy | |
| parent | fa23570a338b53c813b6342fba0cacd4f5e61384 (diff) | |
| download | sqlalchemy-6750c39a4fc6be01502f3c9b1c6ba2d3f67a030e.tar.gz | |
- Fixed some test/feature failures occurring in Python 3.4,
in particular the logic used to wrap "column default" callables
wouldn't work properly for Python built-ins.
fixes #2979
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 9 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 14 |
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index a9d5a69b1..2614c08c8 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -27,6 +27,7 @@ Since these objects are part of the SQL expression language, they are usable as components in SQL expressions. """ +from __future__ import absolute_import import inspect from .. import exc, util, event, inspection @@ -41,6 +42,7 @@ from .selectable import TableClause import collections import sqlalchemy from . import ddl +import types RETAIN_SCHEMA = util.symbol('retain_schema') @@ -1844,7 +1846,12 @@ class ColumnDefault(DefaultGenerator): on everyone. """ - if inspect.isfunction(fn) or inspect.ismethod(fn): + # TODO: why aren't we using a util.langhelpers function + # for this? e.g. get_callable_argspec + + if isinstance(fn, (types.BuiltinMethodType, types.BuiltinFunctionType)): + return lambda ctx: fn() + elif inspect.isfunction(fn) or inspect.ismethod(fn): inspectable = fn elif inspect.isclass(fn): inspectable = fn.__init__ diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 82e37ce99..94ddb242c 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -362,15 +362,15 @@ def format_argspec_init(method, grouped=True): other unreflectable (usually C) -> (self, *args, **kwargs) """ - try: - return format_argspec_plus(method, grouped=grouped) - except TypeError: - if method is object.__init__: - args = grouped and '(self)' or 'self' - else: + if method is object.__init__: + args = grouped and '(self)' or 'self' + else: + try: + return format_argspec_plus(method, grouped=grouped) + except TypeError: args = (grouped and '(self, *args, **kwargs)' or 'self, *args, **kwargs') - return dict(self_arg='self', args=args, apply_pos=args, apply_kw=args) + return dict(self_arg='self', args=args, apply_pos=args, apply_kw=args) def getargspec_init(method): |
