Commits

jason kirtland committed b063446

Centralized some `try: import foo except: import other as foo` imports in util

  • Participants
  • Parent commits 28327e4

Comments (0)

Files changed (4)

File lib/sqlalchemy/orm/collections.py

 from sqlalchemy.orm import mapper
 
 try:
-    from threading import Lock
-except:
-    from dummy_threading import Lock
-try:
     from operator import attrgetter
 except:
     def attrgetter(attribute):
         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.
 

File lib/sqlalchemy/pool.py

 """
 
 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 = {}
 

File lib/sqlalchemy/types.py

 
 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):

File lib/sqlalchemy/util.py

 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: