]> granicus.if.org Git - python/commitdiff
SRE didn't handle character category followed by hyphen inside a
authorFredrik Lundh <fredrik@pythonware.com>
Sat, 7 Oct 2000 10:16:19 +0000 (10:16 +0000)
committerFredrik Lundh <fredrik@pythonware.com>
Sat, 7 Oct 2000 10:16:19 +0000 (10:16 +0000)
character class.  Fix provided by Andrew Kuchling.  Closes bug
#116251.

Lib/sre_parse.py
Lib/test/re_tests.py

index fcf5bcc9fd0bc8cf1537202e9a81d160fff17e6b..9cbbc0254e8647db64699ade1a3b0513e93f5bda 100644 (file)
@@ -393,6 +393,8 @@ def _parse(source, state):
                     # potential range
                     this = source.get()
                     if this == "]":
+                        if code1[0] is IN:
+                            code1 = code1[1][0]
                         set.append(code1)
                         set.append((LITERAL, ord("-")))
                         break
index 86752244b789bb4e41b68e2818b993373761f530..7c541752f28fa42c5779a356885af45db4685f49 100755 (executable)
@@ -619,4 +619,6 @@ xyzabc
     (r' (?x)foo ', 'foo', SUCCEED, 'found', 'foo'),
     # bug 115618: negative lookahead
     (r'(?<!abc)(d.f)', 'abcdefdof', SUCCEED, 'found', 'dof'),
+    # bug 116251: character class bug
+    (r'[\w-]+', 'laser_beam', SUCCEED, 'found', 'laser_beam'),
 ]