.. changelog::
:version: 0.9.4
+ .. change::
+ :tags: bug, general
+ :tickets: 2979
+
+ 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.
+
.. change::
:tags: orm feature
:tickets: 2976
as components in SQL expressions.
"""
+from __future__ import absolute_import
import inspect
from .. import exc, util, event, inspection
import collections
import sqlalchemy
from . import ddl
+import types
RETAIN_SCHEMA = util.symbol('retain_schema')
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__
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):
o2 = pickle.loads(pk_o)
pk_o2 = pickle.dumps(o2)
- # so... pickle is creating a new 'mt2' string after a roundtrip here,
- # so we'll brute-force set it to be id-equal to the original string
- if False:
- o_mt2_str = [ k for k in o.__dict__ if k == 'mt2'][0]
- o2_mt2_str = [ k for k in o2.__dict__ if k == 'mt2'][0]
- self.assert_(o_mt2_str == o2_mt2_str)
- self.assert_(o_mt2_str is not o2_mt2_str)
- # change the id of o2.__dict__['mt2']
- former = o2.__dict__['mt2']
- del o2.__dict__['mt2']
- o2.__dict__[o_mt2_str] = former
-
- # Relies on dict ordering
- if not jython:
- self.assert_(pk_o == pk_o2)
# the above is kind of distrurbing, so let's do it again a little
# differently. the string-id in serialization thing is just an
o3 = pickle.loads(pk_o2)
pk_o3 = pickle.dumps(o3)
o4 = pickle.loads(pk_o3)
- pk_o4 = pickle.dumps(o4)
-
- # Relies on dict ordering
- if not jython:
- self.assert_(pk_o3 == pk_o4)
# and lastly make sure we still have our data after all that.
# identical serialzation is great, *if* it's complete :)