New submission from Jonathan Ballet <j...@multani.info>:

repoze.debug depends on the 'threadframe' module, available on Pypi, but, as the
original web page states, it is only useful for Python 2.2 to 2.4, since the
same functionality has been integrated into the Python 2.5's stdlib.

I provide a patch which make this dependency optional when installing
repoze.debug with Python >= 2.5

----------
files: optional-threadframe-deps.patch
messages: 444
nosy: multani
priority: feature
status: unread
title: [repoze.debug] Don't depend on 'threadframe'

__________________________________
Repoze Bugs <b...@bugs.repoze.org>
<http://bugs.repoze.org/issue162>
__________________________________
# HG changeset patch
# Parent c7d346a3286e5e76cd402760dcc256ee64426cd4
Don't require 'threadframe' module in Python >= 2.5

The same functionality has been merged into the stdlib in Python 2.5

diff -r c7d346a3286e repoze/debug/threads.py
--- a/repoze/debug/threads.py	Fri Mar 12 21:27:06 2010 +0000
+++ b/repoze/debug/threads.py	Mon Aug 30 15:27:00 2010 +0200
@@ -3,7 +3,14 @@
 import time
 from cStringIO import StringIO
 
-import threadframe
+try:
+    # Available from Python >= 2.5
+    from sys import _current_frames as threadframe
+except ImportError:
+    import threadframe as _threadframe
+    # Wrapper to provide the same interface as the one from Python >= 2.5
+    threadframe = lambda: _threadframe.dict()
+
 import webob
 
 def dump_threads():
@@ -12,7 +19,7 @@
     Returns a string with the tracebacks.
     """
 
-    frames = threadframe.dict()
+    frames = threadframe()
     this_thread_id = thread.get_ident()
     now = time.strftime("%Y-%m-%d %H:%M:%S")
     res = ["Threads traceback dump at %s\n" % now]
diff -r c7d346a3286e setup.py
--- a/setup.py	Fri Mar 12 21:27:06 2010 +0000
+++ b/setup.py	Mon Aug 30 15:27:00 2010 +0200
@@ -21,6 +21,15 @@
 
 from setuptools import setup, find_packages
 
+requires = []
+try:
+    # Available from Python >= 2.5
+    from sys import _current_frames
+except ImportError:
+    # Otherwise, depend on threadframe, which provide the same functionality as
+    # the function in Python >= 2.5
+    requires.append('threadframe')
+
 here = os.path.abspath(os.path.dirname(__file__))
 README = open(os.path.join(here, 'README.txt')).read()
 CHANGES = open(os.path.join(here, 'CHANGES.txt')).read()
@@ -54,8 +63,7 @@
       install_requires = [
                'Paste',
                'WebOb',
-               'threadframe',
-               ],
+               ] + requires,
       test_suite="repoze.debug.tests",
       entry_points = """\
         [paste.filter_app_factory]
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to