diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index b0735612e..9b21b80f5 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -88,8 +88,6 @@ class ReTests(unittest.TestCase): int_value = int(matchobj.group(0)) return str(int_value + 1) - # TODO: RUSTPYTHON - # @unittest.expectedFailure def test_basic_re_sub(self): self.assertTypedEqual(re.sub('y', 'a', 'xyz'), 'xaz') self.assertTypedEqual(re.sub('y', S('a'), S('xyz')), 'xaz') @@ -1661,8 +1659,6 @@ class ReTests(unittest.TestCase): self.checkPatternError(r'(?i+', 'missing -, : or )', 3) self.checkPatternError(r'(?iz', 'unknown flag', 3) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_bug_6509(self): # Replacement strings of both types must parse properly. # all strings diff --git a/extra_tests/snippets/stdlib_re.py b/extra_tests/snippets/stdlib_re.py index 21fe656d3..e04de39f2 100644 --- a/extra_tests/snippets/stdlib_re.py +++ b/extra_tests/snippets/stdlib_re.py @@ -59,4 +59,6 @@ assert re.compile('(a)(bc)').match('abc')[1] == 'a' assert re.compile('a(b)(?Pc)d').match('abcd').groupdict() == {'a': 'c'} # test op branch -assert re.compile(r'((?=\d|\.\d)(?P\d*)|a)', re.DEBUG).match('123.2132').group() == '123' +assert re.compile(r'((?=\d|\.\d)(?P\d*)|a)').match('123.2132').group() == '123' + +assert re.sub(r'^\s*', 'X', 'test') == 'Xtest' \ No newline at end of file diff --git a/vm/src/stdlib/sre/interp.rs b/vm/src/stdlib/sre/interp.rs index 5fa7ca8c0..11010c715 100644 --- a/vm/src/stdlib/sre/interp.rs +++ b/vm/src/stdlib/sre/interp.rs @@ -274,7 +274,8 @@ trait MatchContextDrive { self.state().pattern_codes.len() - self.ctx().code_position } fn at_beginning(&self) -> bool { - self.ctx().string_position == self.state().start + // self.ctx().string_position == self.state().start + self.ctx().string_position == 0 } fn at_end(&self) -> bool { self.ctx().string_position == self.state().end