Edgewall Software

Opened 2 years ago

Last modified 2 years ago

#13449 closed defect

Exception: 'NameError: name 'reload' is not defined' when using mod_python with Python 3.x — at Initial Version

Reported by: john.de.rooij@… Owned by:
Priority: normal Milestone: 1.5.4
Component: web frontend/mod_python Version: 1.5.3
Severity: blocker Keywords: patch
Cc: Branch: trunk
Release Notes:
API Changes:
Internal Changes:

Description

When Trac 1.5.3 is used in combination with mod_python on an Apache2 server, together in combination with Python 3.9, a 'NameError: name 'reload' is not defined' exception is raised.

The reload function which was a builtin function in Python 2.x has moved to the imp module or the importlib module depending on the actually used Python 3.x version. Because this problem in present in the modpython_frontend.py it will only be present when mod_python is used. A 'tracd' installation will not show this problem.

This is also the only reload call that is present in the complete trac sourcecode.

The relevant python backtrace is:

PythonHandler trac.web.modpython_frontend: NameError: name 'reload' is not defined
PythonHandler trac.web.modpython_frontend: Traceback (most recent call last):
PythonHandler trac.web.modpython_frontend:   File "/usr/lib/python3/dist-packages/mod_python/apache.py", line 398, in HandlerDispatch\n    result = obj(req)
PythonHandler trac.web.modpython_frontend:   File "/usr/local/lib/python3.9/dist-packages/trac/web/modpython_frontend.py", line 146, in handler\n    reload(sys.modules['trac.web'])

A diff patch to resolve this problem is also attached.

Change History (1)

by john.de.rooij@…, 2 years ago

Attachment: mod_python_reload.diff added

Patch: Use reload from the correct module depending on the running Python version

Note: See TracTickets for help on using tickets.