]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Centralized some `try: import foo except: import other as foo` imports in util
authorJason Kirtland <jek@discorporate.us>
Mon, 13 Aug 2007 06:35:32 +0000 (06:35 +0000)
committerJason Kirtland <jek@discorporate.us>
Mon, 13 Aug 2007 06:35:32 +0000 (06:35 +0000)
lib/sqlalchemy/orm/collections.py
lib/sqlalchemy/pool.py
lib/sqlalchemy/types.py
lib/sqlalchemy/util.py

index 194cf0938885c91e68696d9f975bfeca859b74d8..a8fd912cb1b6ec2743c645cefe790dff81a89081 100644 (file)
@@ -100,10 +100,6 @@ import copy, inspect, sys, weakref
 from sqlalchemy import exceptions, schema, util as sautil
 from sqlalchemy.orm import mapper
 
-try:
-    from threading import Lock
-except:
-    from dummy_threading import Lock
 try:
     from operator import attrgetter
 except:
@@ -525,7 +521,7 @@ class CollectionAdapter(object):
         self._data = weakref.ref(d['data'])
 
 
-__instrumentation_mutex = Lock()
+__instrumentation_mutex = sautil.threading.Lock()
 def _prepare_instrumentation(factory):
     """Prepare a callable for future use as a collection class factory.
 
index 526abe81c54d4bc1b32e386b72de5e1c0842640a..5dbee89930010f6959baea0dc1b0a5000e5a0346 100644 (file)
@@ -14,19 +14,11 @@ calling regular DBAPI connect() methods.
 """
 
 import weakref, time
-try:
-    import cPickle as pickle
-except:
-    import pickle
 
 from sqlalchemy import exceptions, logging
 from sqlalchemy import queue as Queue
+from sqlalchemy.util import thread, threading, pickle
 
-try:
-    import thread, threading
-except:
-    import dummy_thread as thread
-    import dummy_threading as threading
 
 proxies = {}
 
index 56bd5a777e71ea68f6d713e82ec182aca14c961b..fe05910df40bd2cda52b597439b509683fa01c01 100644 (file)
@@ -13,13 +13,9 @@ __all__ = [ 'TypeEngine', 'TypeDecorator', 'NullTypeEngine',
 
 import inspect
 import datetime as dt
-try:
-    import cPickle as pickle
-except:
-    import pickle
 
 from sqlalchemy import exceptions
-from sqlalchemy.util import Decimal
+from sqlalchemy.util import Decimal, pickle
 
 class AbstractType(object):
     def __init__(self, *args, **kwargs):
index d2a202e50fbd69c591437135bf7424b5949b060c..1d23c387f892a1039c19ed4f07d86c2c10d23e3d 100644 (file)
@@ -18,13 +18,18 @@ except ImportError:
 try:
     Set = set
     set_types = set, sets.Set
-except:
+except NameError:
     Set = sets.Set
     set_types = sets.Set,
 
+try:
+    import cPickle as pickle
+except ImportError:
+    import pickle
+
 try:
     reversed = __builtin__.reversed
-except:
+except AttributeError:
     def reversed(seq):
         i = len(seq) -1
         while  i >= 0: