summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/changelog_09.rst10
-rw-r--r--lib/sqlalchemy/sql/base.py2
-rw-r--r--lib/sqlalchemy/util/__init__.py3
-rw-r--r--lib/sqlalchemy/util/compat.py7
-rw-r--r--test/sql/test_metadata.py13
5 files changed, 33 insertions, 2 deletions
diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst
index 6473da10b..8f6c7edc7 100644
--- a/doc/build/changelog/changelog_09.rst
+++ b/doc/build/changelog/changelog_09.rst
@@ -16,6 +16,16 @@
.. change::
:tags: bug, sql
+ :tickets: 3123
+ :versions: 1.0.0
+
+ Added a "str()" step to the dialect_kwargs iteration for
+ Python version < 2.6.5, working around the
+ "no unicode keyword arg" bug as these args are passed along as
+ keyword args within some reflection processes.
+
+ .. change::
+ :tags: bug, sql
:tickets: 3122
The :meth:`.TypeEngine.with_variant` method will now accept a
diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py
index f9a3db285..1e02b3fb0 100644
--- a/lib/sqlalchemy/sql/base.py
+++ b/lib/sqlalchemy/sql/base.py
@@ -90,7 +90,7 @@ class _DialectArgView(collections.MutableMapping):
def __iter__(self):
return (
- "%s_%s" % (dialect_name, value_name)
+ util.safe_kwarg("%s_%s" % (dialect_name, value_name))
for dialect_name in self.obj.dialect_options
for value_name in self.obj.dialect_options[dialect_name]._non_defaults
)
diff --git a/lib/sqlalchemy/util/__init__.py b/lib/sqlalchemy/util/__init__.py
index a2e755c38..a8b823208 100644
--- a/lib/sqlalchemy/util/__init__.py
+++ b/lib/sqlalchemy/util/__init__.py
@@ -8,7 +8,8 @@
from .compat import callable, cmp, reduce, \
threading, py3k, py33, py2k, jython, pypy, cpython, win32, \
pickle, dottedgetter, parse_qsl, namedtuple, next, reraise, \
- raise_from_cause, text_type, string_types, int_types, binary_type, \
+ raise_from_cause, text_type, safe_kwarg, string_types, int_types, \
+ binary_type, \
quote_plus, with_metaclass, print_, itertools_filterfalse, u, ue, b,\
unquote_plus, unquote, b64decode, b64encode, byte_buffer, itertools_filter,\
iterbytes, StringIO, inspect_getargspec, zip_longest
diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py
index 40f7b2922..35dca92ff 100644
--- a/lib/sqlalchemy/util/compat.py
+++ b/lib/sqlalchemy/util/compat.py
@@ -18,6 +18,7 @@ py33 = sys.version_info >= (3, 3)
py32 = sys.version_info >= (3, 2)
py3k = sys.version_info >= (3, 0)
py2k = sys.version_info < (3, 0)
+py265 = sys.version_info >= (2, 6, 5)
jython = sys.platform.startswith('java')
pypy = hasattr(sys, 'pypy_version_info')
win32 = sys.platform.startswith('win')
@@ -34,6 +35,12 @@ else:
except ImportError:
import pickle
+# work around http://bugs.python.org/issue2646
+if py265:
+ safe_kwarg = lambda arg: arg
+else:
+ safe_kwarg = str
+
ArgSpec = collections.namedtuple("ArgSpec",
["args", "varargs", "keywords", "defaults"])
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py
index 7711db816..9542711cb 100644
--- a/test/sql/test_metadata.py
+++ b/test/sql/test_metadata.py
@@ -2517,6 +2517,19 @@ class DialectKWArgTest(fixtures.TestBase):
'otherunknown_foo': 'bar'}
) # still populates
+ def test_runs_safekwarg(self):
+
+ with mock.patch("sqlalchemy.util.safe_kwarg",
+ lambda arg: "goofy_%s" % arg):
+ with self._fixture():
+ idx = Index('a', 'b')
+ idx.kwargs[u'participating_x'] = 7
+
+ eq_(
+ list(idx.dialect_kwargs),
+ ['goofy_participating_x']
+ )
+
def test_combined(self):
with self._fixture():
idx = Index('a', 'b', 'c', participating_x=7,