You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash when using docutils.core.publish_doctree #113
I'm trying to use docutils with IronPython. Installation succeeded with pip without problems and running a sample rst file through rst2html.py worked fine too. However, when I try to use publish_doctree programmatically, the whole IronPython process crashes with a dialog saying
IronPython console has stopped working.
and after closing it I got
Process is terminated due to StackOverflowException.
to console. I can reliably reproduce the crash with just this code:
classreprunicode(unicode):
""" A unicode sub-class that removes the initial u from unicode's repr. """def__repr__(self):
returnunicode.__repr__(self)[1:]
classText(reprunicode):
""" Instances are terminal nodes (leaves) containing text only; no child nodes or attributes. Initialize by passing a string to the constructor. Access the text itself with the `astext` method. """tagname='#text'def__new__(cls, data, rawsource=None):
"""Prevent the rawsource argument from propagating to str."""returnreprunicode.__new__(cls, data)
def__init__(self, data, rawsource=''):
self.rawsource=rawsource"""The raw text from which this element was constructed."""defshortrepr(self, maxlen=18):
data=selfiflen(data) >maxlen:
data=data[:maxlen-4] +' ...'return'<%s: %r>'% (self.tagname, reprunicode(data))
def__repr__(self):
returnself.shortrepr(maxlen=68)
def__str__(self):
returnunicode(self).encode('raw_unicode_escape')
defastext(self):
returnreprunicode(self)
x=Text(u'This is a test')
print'%r'%x
The __str__ method seems to be the issue on IronPython
Activity
slide commentedon Jun 15, 2018
Here is a reproduction case
The __str__ method seems to be the issue on IronPython