p.terminate()
p.join()
+ def test_sre_template_invalid_group_index(self):
+ # see gh-106524
+ import _sre
+ with self.assertRaises(TypeError) as cm:
+ _sre.template("", ["", -1, ""])
+ self.assertIn("invalid template", str(cm.exception))
+ with self.assertRaises(TypeError) as cm:
+ _sre.template("", ["", (), ""])
+ self.assertIn("an integer is required", str(cm.exception))
+
def get_debug_out(pat):
with captured_stdout() as out:
for (Py_ssize_t i = 0; i < n; i++) {
Py_ssize_t index = PyLong_AsSsize_t(PyList_GET_ITEM(template, 2*i+1));
if (index == -1 && PyErr_Occurred()) {
+ Py_SET_SIZE(self, i);
Py_DECREF(self);
return NULL;
}
if (index < 0) {
+ Py_SET_SIZE(self, i);
goto bad_template;
}
self->items[i].index = index;