Skip to content

Commit 20a6ea5

Browse files
committed
bpo-45122: Remove PyCode_New from mypyc
1 parent 725a24a commit 20a6ea5

File tree

1 file changed

+1
-33
lines changed

1 file changed

+1
-33
lines changed

mypyc/lib-rt/exc_ops.c

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -189,38 +189,6 @@ void CPy_TypeError(const char *expected, PyObject *value) {
189189
}
190190
}
191191

192-
// These functions are basically exactly PyCode_NewEmpty and
193-
// _PyTraceback_Add which are available in all the versions we support.
194-
// We're continuing to use them because we'll probably optimize them later.
195-
static PyCodeObject *CPy_CreateCodeObject(const char *filename, const char *funcname, int line) {
196-
PyObject *filename_obj = PyUnicode_FromString(filename);
197-
PyObject *funcname_obj = PyUnicode_FromString(funcname);
198-
PyObject *empty_bytes = PyBytes_FromStringAndSize("", 0);
199-
PyObject *empty_tuple = PyTuple_New(0);
200-
PyCodeObject *code_obj = NULL;
201-
if (filename_obj == NULL || funcname_obj == NULL || empty_bytes == NULL
202-
|| empty_tuple == NULL) {
203-
goto Error;
204-
}
205-
code_obj = PyCode_New(0, 0, 0, 0, 0,
206-
empty_bytes,
207-
empty_tuple,
208-
empty_tuple,
209-
empty_tuple,
210-
empty_tuple,
211-
empty_tuple,
212-
filename_obj,
213-
funcname_obj,
214-
line,
215-
empty_bytes);
216-
Error:
217-
Py_XDECREF(empty_bytes);
218-
Py_XDECREF(empty_tuple);
219-
Py_XDECREF(filename_obj);
220-
Py_XDECREF(funcname_obj);
221-
return code_obj;
222-
}
223-
224192
void CPy_AddTraceback(const char *filename, const char *funcname, int line, PyObject *globals) {
225193
PyObject *exc, *val, *tb;
226194
PyThreadState *thread_state = PyThreadState_GET();
@@ -233,7 +201,7 @@ void CPy_AddTraceback(const char *filename, const char *funcname, int line, PyOb
233201
// FS encoding, which could have a decoder in Python. We don't do
234202
// that so *that* doesn't apply to us.)
235203
PyErr_Fetch(&exc, &val, &tb);
236-
PyCodeObject *code_obj = CPy_CreateCodeObject(filename, funcname, line);
204+
PyCodeObject *code_obj = PyCode_NewEmpty(filename, funcname, line);
237205
if (code_obj == NULL) {
238206
goto error;
239207
}

0 commit comments

Comments
 (0)