support kw-only arguments in py3k
Issue #2237
resolved
class Person(Root_Entity):
def __init__(self, session, *, first_name, last_name):
class Address(Root_Entity):
def __init__(self, session, *, street, building, unit=None,
zip=None, office=None, city="My City", region=None, country="My
Country"):
beginning of a patch to use the correct function, don't know if it works fully though:
diff -r 086ae95614b4848c486eeb7acf2bc1b03b2a6a37 lib/sqlalchemy/util/compat.py
--- a/lib/sqlalchemy/util/compat.py Thu Jul 28 11:53:18 2011 -0400
+++ b/lib/sqlalchemy/util/compat.py Fri Jul 29 10:35:23 2011 -0400
@@ -90,6 +90,11 @@
from urlparse import parse_qsl
if py3k:
+ from inspect import getfullargspec as inspect_getfullargspec
+else:
+ from inspect import getargspec as inspect_getfullargspec
+
+if py3k:
# they're bringing it back in 3.2. brilliant !
def callable(fn):
return hasattr(fn, '__call__')
diff -r 086ae95614b4848c486eeb7acf2bc1b03b2a6a37 lib/sqlalchemy/util/langhelpers.py
--- a/lib/sqlalchemy/util/langhelpers.py Thu Jul 28 11:53:18 2011 -0400
+++ b/lib/sqlalchemy/util/langhelpers.py Fri Jul 29 10:35:23 2011 -0400
@@ -15,7 +15,7 @@
import sys
import types
import warnings
-from compat import update_wrapper, set_types, threading
+from compat import update_wrapper, set_types, threading, inspect_getfullargspec
from sqlalchemy import exc
def _unique_symbols(used, *bases):
@@ -149,7 +149,7 @@
'apply_pos': '(self, a, b, c, **d)'}
"""
- spec = callable(fn) and inspect.getargspec(fn) or fn
+ spec = callable(fn) and inspect_getfullargspec(fn) or fn
args = inspect.formatargspec(*spec)
if spec[0](0):
self_arg = spec[0](0)[0](0)
Comments (3)
-
Account Deleted -
reporter - changed status to resolved
-
reporter - removed milestone
Removing milestone: 0.7.3 (automated comment)
- Log in to comment
I confirm, the patch is functional, the error is gone (0.7.0 on 3.2). Seems to be what i was looking for, thanks for prompt responses...