Modify

Opened 5 years ago

Closed 5 years ago

Last modified 2 years ago

#5586 closed defect (fixed)

TypeError: 'NoneType' object is not callable

Reported by: olemis Owned by: osimons
Priority: normal Component: XmlRpcPlugin
Severity: critical Keywords: WikiFormatting, oneliner
Cc: Trac Release: 0.11

Description

How to Reproduce

While doing a GET operation on /xmlrpc, Trac issued an internal error.

It seems to be related to the way descriptive texts are rendered (i.e. WikiFormatting). The full report suggested me that it is about rendering TracLinks pointing to missing (or non-existing) wiki pages.

User Agent was: Opera/9.63 (X11; Linux i686; U; en) Presto/2.1.1

System Information

Trac 0.11.1
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)]
setuptools 0.6c8
SQLite 3.4.2
pysqlite 2.4.0
Genshi 0.5.1
Pygments 0.9
RPC 1.0.6
jQuery: 1.2.6

Python Traceback

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py", line 423, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py", line 197, in dispatch
    resp = chosen_handler.process_request(req)
  File "build/bdist.linux-i686/egg/tracrpc/web_ui.py", line 138, in process_request
    'description' : wiki_to_oneliner(method.namespace_description, self.env),
  File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 1128, in wiki_to_oneliner
    OneLinerFormatter(env, context).format(wikitext, out, shorten)
  File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 954, in format
    result = re.sub(self.wikiparser.rules, self.replace, result)
  File "/usr/lib/python2.5/re.py", line 150, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 807, in replace
    replacement = self.handle_match(fullmatch)
  File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 800, in handle_match
    return external_handler(self, match, fullmatch)
  File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/api.py", line 277, in wikipagename_link
    self.ignore_missing_pages)
  File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/api.py", line 311, in _format_link
    if 'WIKI_VIEW' in formatter.perm('wiki', pagename, version):
TypeError: 'NoneType' object is not callable


Full details

Most recent call last:
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py", line 423, in _dispatch_request

    Code fragment:

    1. try:
    2. if not env and env_error:
    3. raise HTTPInternalError(env_error)
    4. try:
    5. dispatcher = RequestDispatcher(env)
    6. dispatcher.dispatch(req)
    7. except RequestDone:
    8. pass
    9. resp = req._response or []
    10.  
    11. except HTTPException, e:

    Local variables:

    NameValue
    after [u' except RequestDone:', u' pass', u' resp = ...
    before [u' try:', u' if not env and env_error:', u' raise ...
    dispatcher <trac.web.main.RequestDispatcher object at 0x8cad04c>
    e TypeError("'NoneType' object is not callable",)
    env <trac.env.Environment object at 0x8919fcc>
    env_error None
    exc_info (<type 'exceptions.TypeError'>, TypeError("'NoneType' object is not ...
    filename '/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py'
    frames [{'function': '_dispatch_request', 'lines_before': [u' try:', u' ...
    has_admin True
    line u' dispatcher.dispatch(req)'
    lineno 422
    message u"TypeError: 'NoneType' object is not callable"
    req <Request "GET u'/xmlrpc'">
    resp []
    tb <traceback object at 0x8c4dc34>
    tb_hide None
    traceback 'Traceback (most recent call last):\n File ...
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py", line 197, in dispatch

    Code fragment:

    1. req.args.get('__FORM_TOKEN') != req.form_token:
    2. raise HTTPBadRequest('Missing or invalid form token. '
    3. 'Do you have cookies enabled?')
    4.  
    5. # Process the request and render the template
    6. resp = chosen_handler.process_request(req)
    7. if resp:
    8. if len(resp) == 2: # Clearsilver
    9. chrome.populate_hdf(req)
    10. template, content_type = \
    11. self._post_process_request(req, *resp)

    Local variables:

    NameValue
    chosen_handler <tracrpc.web_ui.XMLRPCWeb object at 0x8cad74c>
    chrome <trac.web.chrome.Chrome object at 0x8cad4cc>
    err (<type 'exceptions.TypeError'>, TypeError("'NoneType' object is not ...
    handler <tracrpc.web_ui.XMLRPCWeb object at 0x8cad74c>
    req <Request "GET u'/xmlrpc'">
    self <trac.web.main.RequestDispatcher object at 0x8cad04c>
  • File "build/bdist.linux-i686/egg/tracrpc/web_ui.py", line 138, in

Local variables:

NameValue
content_type 'text/html'
method <tracrpc.api.Method object at 0x8be22cc>
namespace 'source'
namespaces {'wiki': {'namespace': 'wiki', 'description': <Markup u'Superset of ...
req <Request "GET u'/xmlrpc'">
self <tracrpc.web_ui.XMLRPCWeb object at 0x8cad74c>
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 1128, in wiki_to_oneliner

    Code fragment:

    1. if not wikitext:
    2. return Markup()
    3. abs_ref, href = (req or env).abs_href, (req or env).href
    4. context = Context.from_request(req, absurls=absurls)
    5. out = StringIO()
    6. OneLinerFormatter(env, context).format(wikitext, out, shorten)
    7. return Markup(out.getvalue())
    8.  
    9. def wiki_to_outline(wikitext, env, db=None,
    10. absurls=False, max_depth=None, min_depth=None):
    11. if not wikitext:

    Local variables:

    NameValue
    abs_ref <trac.web.href.Href object at 0x86af28c>
    absurls False
    context <Context >
    db None
    env <trac.env.Environment object at 0x8919fcc>
    href <trac.web.href.Href object at 0x8b1592c>
    out <StringIO.StringIO instance at 0x8b955ac>
    req None
    shorten False
    wikitext "An interface to Trac's Repository and RepositoryManager.\n "
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 954, in format

    Code fragment:

    1. result = buf.getvalue()[:-len(os.linesep)]
    2.  
    3. if shorten:
    4. result = shorten_line(result)
    5.  
    6. result = re.sub(self.wikiparser.rules, self.replace, result)
    7. result = result.replace('[...]', u'[\u2026]')
    8. if result.endswith('...'):
    9. result = result[:-3] + u'\u2026'
    10.  
    11. # Close all open 'one line'-tags

    Local variables:

    NameValue
    buf <StringIO.StringIO instance at 0x8b0ae8c>
    in_code_block 0
    line "An interface to Trac's Repository and RepositoryManager."
    out <StringIO.StringIO instance at 0x8b955ac>
    processor None
    result "An interface to Trac's Repository and RepositoryManager."
    self <trac.wiki.formatter.OneLinerFormatter object at 0x8c38e6c>
    shorten False
    text "An interface to Trac's Repository and RepositoryManager.\n "
  • File "/usr/lib/python2.5/re.py", line 150, in sub

    Code fragment:

    1. """Return the string obtained by replacing the leftmost
    2. non-overlapping occurrences of the pattern in string by the
    3. replacement repl. repl can be either a string or a callable;
    4. if a callable, it's passed the match object and must return
    5. a replacement string to be used."""
    6. return _compile(pattern, 0).sub(repl, string, count)
    7.  
    8. def subn(pattern, repl, string, count=0):
    9. """Return a 2-tuple containing (new_string, number).
    10. new_string is the string obtained by replacing the leftmost
    11. non-overlapping occurrences of the pattern in the source

    Local variables:

    NameValue
    count 0
    pattern <_sre.SRE_Pattern object at 0x8b48338>
    repl <bound method OneLinerFormatter.replace of ...
    string "An interface to Trac's Repository and RepositoryManager."
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 807, in replace

    Code fragment:

    1. internal_handler = getattr(self, '_%s_formatter' % itype)
    2. return internal_handler(match, fullmatch)
    3.  
    4. def replace(self, fullmatch):
    5. """Replace one match with its corresponding expansion"""
    6. replacement = self.handle_match(fullmatch)
    7. if replacement:
    8. return _markup_to_unicode(replacement)
    9.  
    10. def reset(self, source, out=None):
    11. self.source = source

    Local variables:

    NameValue
    fullmatch <_sre.SRE_Match object at 0x8c1b868>
    self <trac.wiki.formatter.OneLinerFormatter object at 0x8c38e6c>
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 800, in handle_match

    Code fragment:

    1. # Check for preceding escape character '!'
    2. if match[0] == '!':
    3. return escape(match[1:])
    4. if itype in self.wikiparser.external_handlers:
    5. external_handler = self.wikiparser.external_handlers[itype]
    6. return external_handler(self, match, fullmatch)
    7. else:
    8. internal_handler = getattr(self, '_%s_formatter' % itype)
    9. return internal_handler(match, fullmatch)
    10.  
    11. def replace(self, fullmatch):

    Local variables:

    NameValue
    external_handler <function wikipagename_link at 0x8924bc4>
    fullmatch <_sre.SRE_Match object at 0x8c1b868>
    itype 'i0'
    match 'RepositoryManager'
    self <trac.wiki.formatter.OneLinerFormatter object at 0x8c38e6c>
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/api.py", line 277, in wikipagename_link

    Code fragment:

    1. def wikipagename_link(formatter, match, fullmatch):
    2. if not _check_unicode_camelcase(match):
    3. return match
    4. return self._format_link(formatter, 'wiki', match,
    5. self.format_page_name(match),
    6. self.ignore_missing_pages)
    7. yield (r"!?(?<!/)\b" + # start at a word boundary but not after '/'
    8. wiki_page_name, wikipagename_link)
    9.  
    10. # [WikiPageNames with label]

    Local variables:

    NameValue
    formatter <trac.wiki.formatter.OneLinerFormatter object at 0x8c38e6c>
    fullmatch <_sre.SRE_Match object at 0x8c1b868>
    match 'RepositoryManager'
    self <trac.wiki.api.WikiSystem object at 0x8cad28c>
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/api.py", line 311, in _format_link

    Code fragment:

    1. if '@' in pagename:
    2. pagename, version = pagename.split('@', 1)
    3. if version and query:
    4. query = '&' + query[1:]
    5. pagename = pagename.rstrip('/')
    6. if 'WIKI_VIEW' in formatter.perm('wiki', pagename, version):
    7. href = formatter.href.wiki(pagename, version=version) + query \
    8. + fragment
    9. if self.has_page(pagename):
    10. return tag.a(label, href=href, class_='wiki')
    11. else:

    Local variables:

    NameValue
    formatter <trac.wiki.formatter.OneLinerFormatter object at 0x8c38e6c>
    fragment ''
    ignore_missing False
    label 'RepositoryManager'
    ns 'wiki'
    pagename 'RepositoryManager'
    query ''
    self <trac.wiki.api.WikiSystem object at 0x8cad28c>
    version None
  • File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py", line 423, in _dispatch_request
      dispatcher.dispatch(req)
    File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/web/main.py", line 197, in dispatch
      resp = chosen_handler.process_request(req)
    File "build/bdist.linux-i686/egg/tracrpc/web_ui.py", line 138, in process_requestFile "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 1128, in wiki_to_oneliner
      OneLinerFormatter(env, context).format(wikitext, out, shorten)
    File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 954, in format
      result = re.sub(self.wikiparser.rules, self.replace, result)
    File "/usr/lib/python2.5/re.py", line 150, in sub
      return _compile(pattern, 0).sub(repl, string, count)
    File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 807, in replace
      replacement = self.handle_match(fullmatch)
    File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/formatter.py", line 800, in handle_match
      return external_handler(self, match, fullmatch)
    File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/api.py", line 277, in wikipagename_link
      self.ignore_missing_pages)
    File "/usr/lib/python2.5/site-packages/Trac-0.11.1-py2.5.egg/trac/wiki/api.py", line 311, in _format_link
      if 'WIKI_VIEW' in formatter.perm('wiki', pagename, version):
    

    Attachments (0)

    Change History (4)

    comment:1 Changed 5 years ago by olemis

    A workaround this may be to enclose CamelCase expressions in backquotes, but IMO a better solution would be to render those links just like they are shown in wiki pages.

    comment:2 Changed 5 years ago by osimons

    Hmm. Looks like it isn't getting the permissions. Looking at call, deep down in the formatter it may also need perm as found on req.

    Could you try this patch?

    • trunk/tracrpc/web_ui.py

       
      135135                namespace = method.namespace.replace('.', '_') 
      136136                if namespace not in namespaces: 
      137137                    namespaces[namespace] = { 
      138                         'description' : wiki_to_oneliner(method.namespace_description, self.env), 
       138                        'description' : wiki_to_oneliner( 
       139                                            method.namespace_description, 
       140                                            self.env, req=req), 
      139141                        'methods' : [], 
      140142                        'namespace' : method.namespace, 
      141143                        } 

    comment:3 Changed 5 years ago by osimons

    I was right, but patch not complete. Seems there is another use of wiki_to_onliner() that I overlooked. I'll commit fix shortly.

    comment:4 Changed 5 years ago by osimons

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

    (In [6404]) XmlRpcPlugin: Fix for wiki formatting in methods and namespaces when rendering the API overview page. Closes #5586.

    Add Comment

    Modify Ticket

    Action
    as closed .
    as The resolution will be set. Next status will be 'closed'.
    to The owner will be changed from osimons. Next status will be 'closed'.
    The resolution will be deleted. Next status will be 'reopened'.
    Author


    E-mail address and user name can be saved in the Preferences.

     
    Note: See TracTickets for help on using tickets.