Edgewall Software
Modify

Opened 19 years ago

Closed 19 years ago

#1011 closed defect (fixed)

global name 'hdf' is not defined

Reported by: ax Owned by: Christopher Lenz
Priority: normal Milestone: 0.8.1
Component: wiki system Version: 0.8
Severity: normal Keywords:
Cc: trac@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

i get the following error trying to access /trac/wiki/WikiRestructuredText on my installation:

global name 'hdf' is not defined

Traceback (most recent call last):
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 525, in cgi_start
    real_cgi_start()
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 520, in real_cgi_start
    dispatch_request(path_info, args, req, env)
  File "/usr/lib/python2.1/site-packages/trac/core.py", line 435, in dispatch_request
    module.run()
  File "/usr/lib/python2.1/site-packages/trac/Module.py", line 44, in run
    self.render()
  File "/usr/lib/python2.1/site-packages/trac/Wiki.py", line 339, in render
    Formatter(self.req.hdf, self.env,self.db).format(self.page.text, out)
  File "/usr/lib/python2.1/site-packages/trac/WikiFormatter.py", line 549, in format
    self.handle_code_block(line)
  File "/usr/lib/python2.1/site-packages/trac/WikiFormatter.py", line 505, in handle_code_block
    self.out.write(self.code_processor(self.hdf, self.code_text, self.env))
  File "/usr/lib/python2.1/site-packages/trac/wikimacros/rst.py", line 209, in execute
    settings_overrides = {'halt_level':6})
  File "/usr/lib/python2.1/site-packages/docutils/core.py", line 371, in publish_string
    enable_exit_status=enable_exit_status)
  File "/usr/lib/python2.1/site-packages/docutils/core.py", line 513, in publish_programmatically
    output = pub.publish(enable_exit_status=enable_exit_status)
  File "/usr/lib/python2.1/site-packages/docutils/core.py", line 194, in publish
    self.settings)
  File "/usr/lib/python2.1/site-packages/docutils/readers/__init__.py", line 66, in read
    self.parse()
  File "/usr/lib/python2.1/site-packages/docutils/readers/__init__.py", line 72, in parse
    self.parser.parse(self.input, document)
  File "/usr/lib/python2.1/site-packages/docutils/parsers/rst/__init__.py", line 139, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "/usr/lib/python2.1/site-packages/docutils/parsers/rst/states.py", line 171, in run
    input_source=document['source'])
  File "/usr/lib/python2.1/site-packages/docutils/statemachine.py", line 232, in run
    context, next_state, result = self.check_line(
  File "/usr/lib/python2.1/site-packages/docutils/statemachine.py", line 421, in check_line
    return method(match, context, next_state)
  File "/usr/lib/python2.1/site-packages/docutils/parsers/rst/states.py", line 2149, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "/usr/lib/python2.1/site-packages/docutils/parsers/rst/states.py", line 2161, in explicit_construct
    return method(self, expmatch)
  File "/usr/lib/python2.1/site-packages/docutils/parsers/rst/states.py", line 1923, in directive
    return self.run_directive(
  File "/usr/lib/python2.1/site-packages/docutils/parsers/rst/states.py", line 1968, in run_directive
    self.state_machine)
  File "/usr/lib/python2.1/site-packages/trac/wikimacros/rst.py", line 183, in code_block
    html = code_processor(hdf, '\n'.join(content), env)
NameError: global name 'hdf' is not defined

Python 2.1.3, trac/branches/0.8-stable rev 1096, all of docutils 0.3.3, 0.3.5, cvs

any help greatly appreciated!

Attachments (1)

rst.diff (1.7 KB ) - added by ax 19 years ago.
makes trac/wikimacros/rst.py work w/ python2.1

Download all attachments as: .zip

Change History (6)

comment:1 by cboos@…, 19 years ago

This is a Python-2.1 lexical scope issue, it works for me (Python-2.3).

However, as 2.1 must be supported, try that fix: The hdf argument must be propagated to the local def code_block(...). Simply add a new hdf argument to that def, and pass the hdf value from the enclosing scope.

The reStructuredText support could be even better if the #801 patch by tonib was applied… (after having done a quick check, it seems the patch also suffers from 2.1 compatibility issues)

by ax, 19 years ago

Attachment: rst.diff added

makes trac/wikimacros/rst.py work w/ python2.1

comment:2 by ax, 19 years ago

thanks for the heads-up. with your help, i managed to get both WikiRestructuredText and WikiRestructuredTextLinks as well as some rst of my own to render without errors on python2.1. patch attached. there were some more instances of python2.1-incompatibilities (global name "env" not defined, True/False not defined, …). there might be some more, so it would be nice if someone could double-check this.

are there any guidelines for writing python2.1-compatible trac code?

comment:3 by Christopher Lenz, 19 years ago

Milestone: 0.8.1

comment:4 by Christopher Lenz, 19 years ago

Owner: changed from Jonas Borgström to Christopher Lenz
Status: newassigned

comment:5 by Christopher Lenz, 19 years ago

Component: generalwiki
Resolution: fixed
Status: assignedclosed

Should be fixed in [1113] (and [1114] for 0.8-stable).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christopher Lenz.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christopher Lenz to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.