Opened 12 years ago
Closed 12 years ago
#11248 closed defect (fixed)
reST rendering can fail for TracStandalone
| Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
|---|---|---|---|
| Priority: | normal | Milestone: | 0.12.6 |
| Component: | wiki system | Version: | 0.12-stable |
| Severity: | normal | Keywords: | rest docutils restructuredtext |
| Cc: | Branch: | ||
| Release Notes: |
reST rendering could fail when running TracStandalone due to Docutils importing the Trac |
||
| API Changes: | |||
| Internal Changes: | |||
Description
Rendering WikiRestructuredText can fail with the following error in the log (comment:8:ticket:12245):
2013-07-17 17:30:05,613 Trac[api] WARNING: HTML preview using ReStructuredTextRenderer failed:
Traceback (most recent call last):
File "/home/user/Workspace/t11245-2.7/teo-rjollos2.git/trac/mimeview/api.py", line 773, in render
rendered_content, filename, url)
File "/home/user/Workspace/t11245-2.7/teo-rjollos2.git/trac/mimeview/rst.py", line 278, in render
'warning_stream': False})
File "/home/user/Workspace/t11245-2.7/local/lib/python2.7/site-packages/docutils-0.10-py2.7.egg/docutils/core.py", line 448, in publish_parts
enable_exit_status=enable_exit_status)
File "/home/user/Workspace/t11245-2.7/local/lib/python2.7/site-packages/docutils-0.10-py2.7.egg/docutils/core.py", line 657, in publish_programmatically
pub.set_components(reader_name, parser_name, writer_name)
File "/home/user/Workspace/t11245-2.7/local/lib/python2.7/site-packages/docutils-0.10-py2.7.egg/docutils/core.py", line 93, in set_components
self.set_reader(reader_name, self.parser, parser_name)
File "/home/user/Workspace/t11245-2.7/local/lib/python2.7/site-packages/docutils-0.10-py2.7.egg/docutils/core.py", line 82, in set_reader
reader_class = readers.get_reader_class(reader_name)
File "/home/user/Workspace/t11245-2.7/local/lib/python2.7/site-packages/docutils-0.10-py2.7.egg/docutils/readers/__init__.py", line 113, in get_reader_class
return module.Reader
AttributeError: 'module' object has no attribute 'Reader'
The problem is with line 110 in docutils/readers/__init__.py (DocUtils version 0.10):
module = __import__(reader_name, globals(), locals(), level=0)
Since by default the module name is specified as reader_name = 'standalone', this can result in the import of <module 'standalone' from './trac/web/standalone.pyc'>.
The issue can be resolved by explicitly specifying the default reader:
-
trac/mimeview/rst.py
diff --git a/trac/mimeview/rst.py b/trac/mimeview/rst.py index bce5cac..f7ce83b 100644
a b try: 29 29 from docutils import nodes 30 30 from docutils.core import publish_parts 31 31 from docutils.parsers import rst 32 from docutils.readers import standalone 32 33 from docutils import __version__ 33 34 has_docutils = True 34 35 except ImportError: … … class ReStructuredTextRenderer(Component): 270 271 inliner.trac = (self.env, context) 271 272 parser = rst.Parser(inliner=inliner) 272 273 content = content_to_unicode(self.env, content, mimetype) 274 # Explicitly specifying the default Reader is a workaround for #11248 273 275 parts = publish_parts(content, writer=writer, parser=parser, 276 reader=standalone.Reader(parser), 274 277 settings_overrides={'halt_level': 6, 275 278 'warning_stream': False, 276 279 'file_insertion_enabled': 0,
The lastest DocUtils version is 0.10, released in December 2012. The issue has been fixed in [7646], [7648] but the fix has not yet been incorporated into a formal release, and we'd need to support earlier versions of DocUtils anyway, so I propose to apply the workaround in 1.0-stable.
Attachments (0)
Change History (3)
comment:1 by , 12 years ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
comment:2 by , 12 years ago
comment:3 by , 12 years ago
| Keywords: | docutils restructuredtext added |
|---|---|
| Milestone: | 1.0.2 → 0.12.6 |
| Release Notes: | modified (diff) |
| Resolution: | → fixed |
| Status: | assigned → closed |
| Version: | 1.0dev → 0.12-stable |



Trac 0.12-stable with docutils 0.10 has the same issue except Python 2.4. I think we should apply in 0.12-stable.
After the patch, it works. I verified with