jamadden / mrab-regex-hg

Automatically exported from code.google.com/p/mrab-regex-hg
0 stars 2 forks source link

Escape characters throws an exception #80

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
digits = regex.compile('\p{Number}')
w = u"ho-ra-cio\\"
print digits.sub(w, u'#')

What is the expected output? What do you see instead?
"ho-ra-cio\\"

I get an exception

/usr/local/lib/python2.7/dist-packages/regex.pyc in 
_compile_replacement_helper(pattern, template)
    598             # or a string literal. It returns items (plural) in order to handle
    599             # a 2-character literal (an invalid escape sequence).
--> 600             is_group, items = _compile_replacement(source, pattern, 
is_unicode)
    601             if is_group:
    602                 # It's a group, so first flush the literal.

/usr/local/lib/python2.7/dist-packages/_regex_core.pyc in 
_compile_replacement(source, pattern, is_unicode)
   1553 
   1554     # An escaped non-backslash is a backslash followed by the literal.
-> 1555     return False, [ord("\\"), ord(ch)]
   1556 
   1557 def parse_repl_hex_escape(source, expected_len):

TypeError: ord() expected a character, but string of length 0 found

What version of the product are you using? On what operating system?
regex 0.1.20121008

Original issue reported on code.google.com by rmyeid on 16 Oct 2012 at 8:39

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ignore this bug report, it was a mistake on my side.

Original comment by rmyeid on 16 Oct 2012 at 8:59

GoogleCodeExporter commented 9 years ago
Actually, it does show a bug. It shouldn't have raised TypeError, but instead 
regex.error saying "bad escape".

It'll be fixed in the next release.

Original comment by re...@mrabarnett.plus.com on 16 Oct 2012 at 10:16

GoogleCodeExporter commented 9 years ago
Fixed in regex 0.1.20121017.

Original comment by re...@mrabarnett.plus.com on 17 Oct 2012 at 2:29