@@ -189,38 +189,9 @@ void CPy_TypeError(const char *expected, PyObject *value) {
189
189
}
190
190
}
191
191
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
-
192
+ // This function is basically exactly the same with _PyTraceback_Add
193
+ // which is available in all the versions we support.
194
+ // We're continuing to use this because we'll probably optimize this later.
224
195
void CPy_AddTraceback (const char * filename , const char * funcname , int line , PyObject * globals ) {
225
196
PyObject * exc , * val , * tb ;
226
197
PyThreadState * thread_state = PyThreadState_GET ();
@@ -233,7 +204,7 @@ void CPy_AddTraceback(const char *filename, const char *funcname, int line, PyOb
233
204
// FS encoding, which could have a decoder in Python. We don't do
234
205
// that so *that* doesn't apply to us.)
235
206
PyErr_Fetch (& exc , & val , & tb );
236
- PyCodeObject * code_obj = CPy_CreateCodeObject (filename , funcname , line );
207
+ PyCodeObject * code_obj = PyCode_NewEmpty (filename , funcname , line );
237
208
if (code_obj == NULL ) {
238
209
goto error ;
239
210
}
0 commit comments