Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(88354)

Unified Diff: Modules/_sre.c

Issue 10076: Regex objects became uncopyable in 2.5
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Misc/NEWS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Modules/_sre.c
===================================================================
--- Modules/_sre.c (revision 85383)
+++ Modules/_sre.c (working copy)
@@ -2488,10 +2488,10 @@
return pattern_subx(self, ptemplate, string, count, 1);
}
+#ifdef USE_BUILTIN_COPY
static PyObject*
pattern_copy(PatternObject* self, PyObject *unused)
{
-#ifdef USE_BUILTIN_COPY
PatternObject* copy;
int offset;
@@ -2510,16 +2510,13 @@
copy->weakreflist = NULL;
return (PyObject*) copy;
-#else
- PyErr_SetString(PyExc_TypeError, "cannot copy this pattern object");
- return NULL;
-#endif
}
+#endif
+#ifdef USE_BUILTIN_COPY
static PyObject*
pattern_deepcopy(PatternObject* self, PyObject* memo)
{
-#ifdef USE_BUILTIN_COPY
PatternObject* copy;
copy = (PatternObject*) pattern_copy(self);
@@ -2532,12 +2529,8 @@
Py_DECREF(copy);
return NULL;
}
-
-#else
- PyErr_SetString(PyExc_TypeError, "cannot deepcopy this pattern object");
- return NULL;
-#endif
}
+#endif
PyDoc_STRVAR(pattern_match_doc,
"match(string[, pos[, endpos]]) --> match object or None.\n\
@@ -2593,8 +2586,10 @@
pattern_finditer_doc},
#endif
{"scanner", (PyCFunction) pattern_scanner, METH_VARARGS},
+#ifdef USE_BUILTIN_COPY
{"__copy__", (PyCFunction) pattern_copy, METH_NOARGS},
{"__deepcopy__", (PyCFunction) pattern_deepcopy, METH_O},
+#endif
{NULL, NULL}
};
« no previous file with comments | « Misc/NEWS ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+