summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2021-11-16 20:30:47 (GMT)
committerGitHub <noreply@github.com>2021-11-16 20:30:47 (GMT)
commitda20d7401de97b425897d3069f71f77b039eb16f (patch)
tree33c3455515ed48151cb2521bbfa41e3d0277e090 /Modules/_testcapimodule.c
parentd7e210070f915d8df5fa863ecba8628304ee1ded (diff)
downloadcpython-da20d7401de97b425897d3069f71f77b039eb16f.zip
cpython-da20d7401de97b425897d3069f71f77b039eb16f.tar.gz
cpython-da20d7401de97b425897d3069f71f77b039eb16f.tar.bz2
bpo-45822: Respect PEP 263's coding cookies in the parser even if flags are not provided (GH-29582)
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 5e4c577..c9ba148 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -382,6 +382,19 @@ static PyTypeObject _HashInheritanceTester_Type = {
};
static PyObject*
+pycompilestring(PyObject* self, PyObject *obj) {
+ if (PyBytes_CheckExact(obj) == 0) {
+ PyErr_SetString(PyExc_ValueError, "Argument must be a bytes object");
+ return NULL;
+ }
+ const char *the_string = PyBytes_AsString(obj);
+ if (the_string == NULL) {
+ return NULL;
+ }
+ return Py_CompileString(the_string, "blech", Py_file_input);
+}
+
+static PyObject*
test_lazy_hash_inheritance(PyObject* self, PyObject *Py_UNUSED(ignored))
{
PyTypeObject *type;
@@ -6070,6 +6083,7 @@ static PyMethodDef TestMethods[] = {
{"return_null_without_error", return_null_without_error, METH_NOARGS},
{"return_result_with_error", return_result_with_error, METH_NOARGS},
{"getitem_with_error", getitem_with_error, METH_VARARGS},
+ {"Py_CompileString", pycompilestring, METH_O},
{"PyTime_FromSeconds", test_pytime_fromseconds, METH_VARARGS},
{"PyTime_FromSecondsObject", test_pytime_fromsecondsobject, METH_VARARGS},
{"PyTime_AsSecondsDouble", test_pytime_assecondsdouble, METH_VARARGS},