Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2426 (closed defect: wontfix)

Opened 10 years ago

Last modified 9 years ago

Exception when importing turbogears with python -OO

Reported by: nickpholden Owned by:
Priority: low Milestone: 1.1.x bugfix
Component: TurboGears Version: 1.1
Severity: normal Keywords:
Cc:

Description

This isn't that serious as I can live without -OO but I thought you guy should know. I can't quite work out what is going on as one of the lines in question "# $Id$" isn't actually doing anything?! I tried deleting the .pyc and .pyo files but this did not help.

$ /sv/venv/svPortal2/bin/python -OO /sv/venv/svPortal2/bin/start-HTMLViewer.py
Traceback (most recent call last):
  File "/sv/venv/svPortal2/bin/start-HTMLViewer.py", line 5, in <module>
    pkg_resources.run_script('svHTMLViewer==1.0.0.0-r3', 'start-HTMLViewer.py')
  File "/sv/venv/svPortal2/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 448, in run_script
  File "/sv/venv/svPortal2/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg/pkg_resources.py", line 1166, in run_script
  File "/sv/venv/svPortal2/lib/python2.5/site-packages/svHTMLViewer-1.0.0.0_r3-py2.5.egg/EGG-INFO/scripts/start-HTMLViewer.py", line 6, in <module>
    import turbogears
  File "/sv/venv/svPortal2/lib/python2.5/site-packages/TurboGears-1.1-py2.5.egg/turbogears/__init__.py", line 6, in <module>
    from turbogears.controllers import (absolute_url, expose, flash, validate,
  File "/sv/venv/svPortal2/lib/python2.5/site-packages/TurboGears-1.1-py2.5.egg/turbogears/controllers.py", line 15, in <module>
    from peak.rules import abstract, always_overrides, Method, NoApplicableMethods
  File "/sv/venv/svPortal2/lib/python2.5/site-packages/PIL-1.1.7-py2.5-linux-x86_64.egg/__init__.py", line 3, in <module>
    # $Id$
  File "build/bdist.linux-x86_64/egg/peak/rules/core.py", line 247, in <module>
  File "build/bdist.linux-x86_64/egg/peak/rules/core.py", line 267, in RuleSet
  File "build/bdist.linux-x86_64/egg/peak/rules/core.py", line 267, in RuleSet
  File "/sv/venv/svPortal2/lib/python2.5/site-packages/DecoratorTools-1.7-py2.5.egg/peak/util/decorators.py", line 576, in tracer
  File "/sv/venv/svPortal2/lib/python2.5/site-packages/DecoratorTools-1.7-py2.5.egg/peak/util/decorators.py", line 302, in <lambda>
  File "/sv/venv/svPortal2/lib/python2.5/site-packages/DecoratorTools-1.7-py2.5.egg/peak/util/decorators.py", line 321, in synchronized
AttributeError: 'NoneType' object has no attribute 'replace'

Change History

comment:1 Changed 10 years ago by jorge.vargas

This is not a TG bug but a problem with a trick Peak pulls to build a docstring on the fly (which doesn't exists with -OO) hence the NoneType? error.

The offending coded is the second to last line of the follow snipped.

    def wrap(__func):
        '''
        try:
            lock = $self.__lock__
        except AttributeError:
            try:
                from threading import RLock
            except ImportError:
                from dummy_threading import RLock
            lock = $self.__dict__.setdefault('__lock__',RLock())
        lock.acquire()
        try:
            return __func($args)
        finally:
            lock.release()'''
    from inspect import getargspec
    first_arg = getargspec(func)[0][0]
    wrap.__doc__ = wrap.__doc__.replace('$self', first_arg)
    return apply_template(wrap, func)

Also note this will affect TG2.0 and earlier but not TG2.1 but I'm not sure what to do with it. I'm going to report it upstream and if pje decided to fix it then we can upgrade otherwise I guess we can't just run TG with -OO

comment:3 Changed 10 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to wontfix

Based on feedback from the ML I'm closing just don't use -OO with a TG version that depends on peak-rules

comment:4 Changed 9 years ago by chrisz

  • Milestone changed from __unclassified__ to 1.1.x bugfix
Note: See TracTickets for help on using tickets.