Skip to content

Commit cfdb602

Browse files
committed
Add __copy__ and __deepcopy__ to _sre
1 parent 3c16e2c commit cfdb602

File tree

2 files changed

+13
-0
lines changed
  • graalpython

2 files changed

+13
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_re.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
*graalpython.lib-python.3.test.test_re.ReTests.test_character_set_errors
4242
*graalpython.lib-python.3.test.test_re.ReTests.test_compile
4343
*graalpython.lib-python.3.test.test_re.ReTests.test_constants
44+
*graalpython.lib-python.3.test.test_re.ReTests.test_copying
4445
*graalpython.lib-python.3.test.test_re.ReTests.test_debug_flag
4546
*graalpython.lib-python.3.test.test_re.ReTests.test_dollar_matches_twice
4647
*graalpython.lib-python.3.test.test_re.ReTests.test_empty_array

graalpython/lib-graalpython/_sre.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ def lastindex(self):
259259
def __repr__(self):
260260
return "<%s object; span=%r, match=%r>" % (type(self).__name__, self.span(), self.group())
261261

262+
def __copy__(self):
263+
return self
264+
265+
def __deepcopy__(self, memo):
266+
return self
267+
262268
def _append_end_assert(pattern):
263269
if isinstance(pattern, str):
264270
return pattern if pattern.endswith(r"\Z") else pattern + r"\Z"
@@ -356,6 +362,12 @@ def __eq__(self, other):
356362
def __hash__(self):
357363
return hash(self.pattern) * 31 ^ hash(self.flags)
358364

365+
def __copy__(self):
366+
return self
367+
368+
def __deepcopy__(self, memo):
369+
return self
370+
359371
def _search(self, pattern, string, pos, endpos, sticky=False):
360372
pattern = self.__tregex_compile(pattern, self.__flags_str + ("y" if sticky else ""))
361373
input_str = string

0 commit comments

Comments
 (0)