summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util/langhelpers.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-03-09 17:26:16 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-03-09 17:26:16 -0500
commitc8a80e21301791fd4e1caf29ed8cadd40f617765 (patch)
treebcd5a91a5b841501a1d237e95595f2177cf5c2b8 /lib/sqlalchemy/util/langhelpers.py
parent8ef3ed1032e0354cffa786f25bac2c54a3bcd54d (diff)
downloadsqlalchemy-c8a80e21301791fd4e1caf29ed8cadd40f617765.tar.gz
- remove all compat items that are pre-2.5 (hooray)
- other cleanup - don't need compat.decimal, that approach never panned out. hopefully outside libs aren't pulling it in, they shouldn't be
Diffstat (limited to 'lib/sqlalchemy/util/langhelpers.py')
-rw-r--r--lib/sqlalchemy/util/langhelpers.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py
index a9b791234..e3aed24d8 100644
--- a/lib/sqlalchemy/util/langhelpers.py
+++ b/lib/sqlalchemy/util/langhelpers.py
@@ -15,10 +15,31 @@ import re
import sys
import types
import warnings
-from .compat import update_wrapper, set_types, threading, \
+from .compat import set_types, threading, \
callable, inspect_getfullargspec
+from functools import update_wrapper
from .. import exc
+import hashlib
+def md5_hex(x):
+ # Py3K
+ #x = x.encode('utf-8')
+ m = hashlib.md5()
+ m.update(x)
+ return m.hexdigest()
+
+def decode_slice(slc):
+ """decode a slice object as sent to __getitem__.
+
+ takes into account the 2.5 __index__() method, basically.
+
+ """
+ ret = []
+ for x in slc.start, slc.stop, slc.step:
+ if hasattr(x, '__index__'):
+ x = x.__index__()
+ ret.append(x)
+ return tuple(ret)
def _unique_symbols(used, *bases):
used = set(used)
@@ -123,7 +144,7 @@ def get_cls_kwargs(cls):
ctr = class_.__dict__.get('__init__', False)
if (not ctr or
not isinstance(ctr, types.FunctionType) or
- not isinstance(ctr.func_code, types.CodeType)):
+ not isinstance(ctr.func_code, types.CodeType)):
stack.update(class_.__bases__)
continue
@@ -256,7 +277,6 @@ def format_argspec_init(method, grouped=True):
try:
return format_argspec_plus(method, grouped=grouped)
except TypeError:
- self_arg = 'self'
if method is object.__init__:
args = grouped and '(self)' or 'self'
else:
@@ -784,7 +804,7 @@ def duck_type_collection(specimen, default=None):
if hasattr(specimen, '__emulates__'):
# canonicalize set vs sets.Set to a standard: the builtin set
if (specimen.__emulates__ is not None and
- issubclass(specimen.__emulates__, set_types)):
+ issubclass(specimen.__emulates__, set_types)):
return set
else:
return specimen.__emulates__