From: Jason Kirtland Date: Mon, 13 Aug 2007 06:35:32 +0000 (+0000) Subject: Centralized some `try: import foo except: import other as foo` imports in util X-Git-Tag: rel_0_4beta2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a19fa666ba3842fa84cfc59da06055f472a6f5a6;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Centralized some `try: import foo except: import other as foo` imports in util --- diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py index 194cf09388..a8fd912cb1 100644 --- a/lib/sqlalchemy/orm/collections.py +++ b/lib/sqlalchemy/orm/collections.py @@ -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. diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 526abe81c5..5dbee89930 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -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 = {} diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py index 56bd5a777e..fe05910df4 100644 --- a/lib/sqlalchemy/types.py +++ b/lib/sqlalchemy/types.py @@ -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): diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index d2a202e50f..1d23c387f8 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -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: