diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-05-26 13:08:24 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-05-26 13:08:24 -0400 |
| commit | 956c144c7feae68fa957eb62ede4b21cd818c737 (patch) | |
| tree | 9b0bee21259e44b0bc784f5aba9f91da085a44f7 /lib/sqlalchemy | |
| parent | e9b29802ba999628f9cc656e87347b6844026285 (diff) | |
| download | sqlalchemy-956c144c7feae68fa957eb62ede4b21cd818c737.tar.gz | |
fix serializer tests. something is wrong with non-C pickle but for some reason py3k's pickle seems to be OK? not sure why that is, as this
is all related to http://bugs.python.org/issue998998
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/ext/serializer.py | 21 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/__init__.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/util/compat.py | 17 |
3 files changed, 19 insertions, 21 deletions
diff --git a/lib/sqlalchemy/ext/serializer.py b/lib/sqlalchemy/ext/serializer.py index 759652014..8abd1fdf3 100644 --- a/lib/sqlalchemy/ext/serializer.py +++ b/lib/sqlalchemy/ext/serializer.py @@ -58,26 +58,9 @@ from ..orm.interfaces import MapperProperty from ..orm.attributes import QueryableAttribute from .. import Table, Column from ..engine import Engine -from ..util import pickle +from ..util import pickle, byte_buffer, b64encode, b64decode import re -import base64 -# start Py3K -from io import BytesIO as byte_buffer -# end Py3K -# start Py2K -#from cStringIO import StringIO as byte_buffer -# end Py2K - -# start Py3K -def b64encode(x): - return base64.b64encode(x).decode('ascii') -def b64decode(x): - return base64.b64decode(x.encode('ascii')) -# end Py3K -# start Py2K -#b64encode = base64.b64encode -#b64decode = base64.b64decode -# end Py2K + __all__ = ['Serializer', 'Deserializer', 'dumps', 'loads'] diff --git a/lib/sqlalchemy/util/__init__.py b/lib/sqlalchemy/util/__init__.py index b1f1a2db6..d1fc8e8e5 100644 --- a/lib/sqlalchemy/util/__init__.py +++ b/lib/sqlalchemy/util/__init__.py @@ -9,7 +9,7 @@ from .compat import callable, cmp, reduce, \ pickle, dottedgetter, parse_qsl, namedtuple, next, WeakSet, reraise, \ raise_from_cause, text_type, string_types, int_types, binary_type, \ quote_plus, with_metaclass, print_, itertools_filterfalse, u, ue, b,\ - unquote_plus + unquote_plus, b64decode, b64encode, byte_buffer from ._collections import KeyedTuple, ImmutableContainer, immutabledict, \ Properties, OrderedProperties, ImmutableProperties, OrderedDict, \ diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py index e8404c2df..ea97999cf 100644 --- a/lib/sqlalchemy/util/compat.py +++ b/lib/sqlalchemy/util/compat.py @@ -28,7 +28,7 @@ if py3k: import pickle else: try: - import pickle as pickle + import cPickle as pickle except ImportError: import pickle @@ -40,6 +40,9 @@ if py3k: import configparser from io import StringIO + from io import BytesIO as byte_buffer + + string_types = str, binary_type = bytes text_type = str @@ -73,12 +76,20 @@ if py3k: import itertools itertools_filterfalse = itertools.filterfalse itertools_imap = map + + import base64 + def b64encode(x): + return base64.b64encode(x).decode('ascii') + def b64decode(x): + return base64.b64decode(x.encode('ascii')) + else: from inspect import getargspec as inspect_getfullargspec from urllib import quote_plus, unquote_plus from urlparse import parse_qsl import ConfigParser as configparser from StringIO import StringIO + from cStringIO import StringIO as byte_buffer string_types = basestring, binary_type = str @@ -109,6 +120,10 @@ else: cmp = cmp reduce = reduce + import base64 + b64encode = base64.b64encode + b64decode = base64.b64decode + def print_(*args, **kwargs): fp = kwargs.pop("file", sys.stdout) if fp is None: |
