erikrose/parsimonious — pull request #35 by 5p0ck (2013-09-26 14:49:40+00:00)
Title: Solve error in Grammar.__repr__ in Python3

This is an excerpt from the Python3-IDLE on Ubuntu 12.04 LTS
>>> from parsimonious.grammar import Grammar
>>> grammar = Grammar(
"""
bold_text = bold_open text bold_close
text = ~"[A-Z 0-9]*"i
bold_open = "(("
bold_close = "))"
""")
>>> grammar
Traceback (most recent call last):
File "", line 1, in
grammar
File "/usr/local/lib/python3.2/dist-packages/parsimonious-0.5-py3.2.egg/parsimonious/grammar.py", line 104, in __repr__
return "Grammar('%s')" % str(self).encode('string_escape')
LookupError: unknown encoding: string_escape
>>>

Replaced string_escape by unicode_escape.
Works also with Python2.