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/util/compat.py | |
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/util/compat.py')
-rw-r--r-- | lib/sqlalchemy/util/compat.py | 17 |
1 files changed, 16 insertions, 1 deletions
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: |