summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gr?nholm <alex.gronholm@nextday.fi>2011-05-17 02:26:43 +0300
committerAlex Gr?nholm <alex.gronholm@nextday.fi>2011-05-17 02:26:43 +0300
commit8d0fa5407b29605f1b217fc0c9945b9404330970 (patch)
tree0667502c6f72b8ee3fc5c6b1759658165c0e966c
parentd66a3541af72d509c886259a81e2e21d62e03eda (diff)
downloadpastedeploy-8d0fa5407b29605f1b217fc0c9945b9404330970.tar.gz
The threadinglocal module is no longer necessary, so replaced the util package with a util module containing the code from fixtypeerror.py
-rw-r--r--paste/deploy/config.py3
-rw-r--r--paste/deploy/util.py (renamed from paste/deploy/util/fixtypeerror.py)11
-rw-r--r--paste/deploy/util/__init__.py3
-rw-r--r--paste/deploy/util/threadinglocal.py39
4 files changed, 5 insertions, 51 deletions
diff --git a/paste/deploy/config.py b/paste/deploy/config.py
index d690ff3..562a61f 100644
--- a/paste/deploy/config.py
+++ b/paste/deploy/config.py
@@ -14,8 +14,7 @@ def local_dict():
try:
return config_local.wsgi_dict
except NameError:
- from paste.deploy.util.threadinglocal import local
- config_local = local()
+ config_local = threading.local()
config_local.wsgi_dict = result = {}
return result
except AttributeError:
diff --git a/paste/deploy/util/fixtypeerror.py b/paste/deploy/util.py
index b1fa0ec..86c6972 100644
--- a/paste/deploy/util/fixtypeerror.py
+++ b/paste/deploy/util.py
@@ -1,12 +1,9 @@
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
-"""
-Fixes the vague error message that you get when calling a function
-with the wrong arguments.
-"""
import inspect
import sys
+
def fix_type_error(exc_info, callable, varargs, kwargs):
"""
Given an exception, this will test if the exception was due to a
@@ -28,7 +25,6 @@ def fix_type_error(exc_info, callable, varargs, kwargs):
or getattr(exc_info[1], '_type_error_fixed', False)):
return exc_info
exc_info[1]._type_error_fixed = True
- import inspect
argspec = inspect.formatargspec(*inspect.getargspec(callable))
args = ', '.join(map(_short_repr, varargs))
if kwargs and args:
@@ -42,16 +38,17 @@ def fix_type_error(exc_info, callable, varargs, kwargs):
exc_info[1].args = (msg,)
return exc_info
+
def _short_repr(v):
v = repr(v)
if len(v) > 12:
v = v[:8]+'...'+v[-4:]
return v
+
def fix_call(callable, *args, **kw):
"""
- Call ``callable(*args, **kw)`` fixing any type errors that come
- out.
+ Call ``callable(*args, **kw)`` fixing any type errors that come out.
"""
try:
val = callable(*args, **kw)
diff --git a/paste/deploy/util/__init__.py b/paste/deploy/util/__init__.py
deleted file mode 100644
index 56bf54c..0000000
--- a/paste/deploy/util/__init__.py
+++ /dev/null
@@ -1,3 +0,0 @@
-# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
-# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
-#
diff --git a/paste/deploy/util/threadinglocal.py b/paste/deploy/util/threadinglocal.py
deleted file mode 100644
index 57afa17..0000000
--- a/paste/deploy/util/threadinglocal.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
-# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
-
-try:
- import threading
-except ImportError:
- # No threads, so "thread local" means process-global
- class local(object):
- pass
-else:
- try:
- local = threading.local
- except AttributeError:
- # Added in 2.4, but now we'll have to define it ourselves
- import thread
- class local(object):
-
- def __init__(self):
- self.__dict__['__objs'] = {}
-
- def __getattr__(self, attr, g=thread.get_ident):
- try:
- return self.__dict__['__objs'][g()][attr]
- except KeyError:
- raise AttributeError(
- "No variable %s defined for the thread %s"
- % (attr, g()))
-
- def __setattr__(self, attr, value, g=thread.get_ident):
- self.__dict__['__objs'].setdefault(g(), {})[attr] = value
-
- def __delattr__(self, attr, g=thread.get_ident):
- try:
- del self.__dict__['__objs'][g()][attr]
- except KeyError:
- raise AttributeError(
- "No variable %s defined for thread %s"
- % (attr, g()))
-