This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author taleinat
Recipients ezio.melotti, lemburg, loewis, taleinat, terry.reedy
Date 2014-07-15.21:26:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1405459615.88.0.0791300814637.issue21765@psf.upfronthosting.co.za>
In-reply-to
Content
I'm attaching a patch which really fixes this issue, along with additional tests for idlelib.HyperParser.

I did indeed have to fix PyParse as well. I got it working with re.subn() as Martin suggested, but the performance was much worse (between 100x and 1000x slower according to my timings). So I came up with the clever solution of passing a defaultdict to str.translate(), with the default value being ord('x'). That works as expected and is much faster than the regexp.

Finally, since the defaultdict is kept around as long as IDLE is running, I decided to avoid having it grow continually and consume memory unnecessarily. So I wrote a simple Mapping class, which wraps a normal dict and uses a custom default value instead of None, ord('x') in this case. Works like a charm :)

I haven't written tests for PyParse since it currently doesn't have any tests at all. But from the HyperParser tests and from some manual testing, it seems to be working as expected.
History
Date User Action Args
2014-07-15 21:26:56taleinatsetrecipients: + taleinat, lemburg, loewis, terry.reedy, ezio.melotti
2014-07-15 21:26:55taleinatsetmessageid: <1405459615.88.0.0791300814637.issue21765@psf.upfronthosting.co.za>
2014-07-15 21:26:55taleinatlinkissue21765 messages
2014-07-15 21:26:55taleinatcreate