@@ -101,20 +101,19 @@ static bool parser_progress_callback(TSParseState *state) {
101
101
PyObject * parser_parse (Parser * self , PyObject * args , PyObject * kwargs ) {
102
102
ModuleState * state = GET_MODULE_STATE (self );
103
103
PyObject * source_or_callback ;
104
- PyObject * old_tree_obj = NULL ;
105
- PyObject * encoding_obj = NULL ;
106
- PyObject * progress_callback_obj = NULL ;
107
- bool keep_text = true;
104
+ PyObject * old_tree_obj = NULL , * encoding_obj = NULL , * progress_callback_obj = NULL ;
108
105
char * keywords [] = {"" , "old_tree" , "encoding" , "progress_callback" , NULL };
109
106
if (!PyArg_ParseTupleAndKeywords (args , kwargs , "O|O!OO:parse" , keywords , & source_or_callback ,
110
107
state -> tree_type , & old_tree_obj , & encoding_obj ,
111
108
& progress_callback_obj )) {
112
109
return NULL ;
113
110
}
111
+ PyErr_WarnFormat (PyExc_RuntimeWarning , 1 , "After PyArg_ParseTupleAndKeywords (%d)\n" , __LINE__ );
114
112
115
113
const TSTree * old_tree = old_tree_obj ? ((Tree * )old_tree_obj )-> tree : NULL ;
116
114
TSInputEncoding input_encoding = TSInputEncodingUTF8 ;
117
115
if (encoding_obj != NULL ) {
116
+ PyErr_WarnFormat (PyExc_RuntimeWarning , 1 , "Inside encoding_obj (%d)\n" , __LINE__ );
118
117
if (!PyUnicode_CheckExact (encoding_obj )) {
119
118
PyErr_Format (PyExc_TypeError , "encoding must be str, not %s" ,
120
119
encoding_obj -> ob_type -> tp_name );
@@ -140,6 +139,7 @@ PyObject *parser_parse(Parser *self, PyObject *args, PyObject *kwargs) {
140
139
TSTree * new_tree = NULL ;
141
140
Py_buffer source_view ;
142
141
if (PyObject_GetBuffer (source_or_callback , & source_view , PyBUF_SIMPLE ) > -1 ) {
142
+ PyErr_WarnFormat (PyExc_RuntimeWarning , 1 , "Inside PyObject_GetBuffer (%d)\n" , __LINE__ );
143
143
if (progress_callback_obj != NULL ) {
144
144
const char * warning = "The progress_callback is ignored when parsing a bytestring" ;
145
145
if (PyErr_WarnEx (PyExc_UserWarning , warning , 1 ) < 0 ) {
@@ -149,9 +149,16 @@ PyObject *parser_parse(Parser *self, PyObject *args, PyObject *kwargs) {
149
149
// parse a buffer
150
150
const char * source_bytes = (const char * )source_view .buf ;
151
151
uint32_t length = (uint32_t )source_view .len ;
152
+ PyErr_WarnFormat (PyExc_RuntimeWarning , 1 , "Before ts_parser_parse_string_encoding (%d)\n" ,
153
+ __LINE__ );
154
+ PyErr_WarnFormat (PyExc_RuntimeWarning , 1 , "Parameters: %p, %p, %s, %u, %d\n" , self -> parser ,
155
+ old_tree , source_bytes , length , input_encoding );
152
156
new_tree = ts_parser_parse_string_encoding (self -> parser , old_tree , source_bytes , length ,
153
157
input_encoding );
158
+ PyErr_WarnFormat (PyExc_RuntimeWarning , 1 , "After ts_parser_parse_string_encoding (%d)\n" ,
159
+ __LINE__ );
154
160
PyBuffer_Release (& source_view );
161
+ PyErr_WarnFormat (PyExc_RuntimeWarning , 1 , "After PyBuffer_Release (%d)\n" , __LINE__ );
155
162
} else if (PyCallable_Check (source_or_callback )) {
156
163
// clear the GetBuffer error
157
164
PyErr_Clear ();
@@ -199,16 +206,18 @@ PyObject *parser_parse(Parser *self, PyObject *args, PyObject *kwargs) {
199
206
PyErr_SetString (PyExc_ValueError , "Parsing failed" );
200
207
return NULL ;
201
208
}
209
+ PyErr_WarnFormat (PyExc_RuntimeWarning , 1 , "After PyErr_Occurred (%d)\n" , __LINE__ );
202
210
203
211
Tree * tree = PyObject_New (Tree , state -> tree_type );
204
212
if (tree == NULL ) {
205
213
return NULL ;
206
214
}
207
215
tree -> tree = new_tree ;
208
216
tree -> language = self -> language ;
209
- tree -> source = keep_text ? source_or_callback : Py_None ;
217
+ tree -> source = source_or_callback ;
210
218
Py_INCREF (tree -> source );
211
219
Py_INCREF (tree -> language );
220
+ PyErr_WarnFormat (PyExc_RuntimeWarning , 1 , "Before PyObject_Init (%d)\n" , __LINE__ );
212
221
return PyObject_Init ((PyObject * )tree , state -> tree_type );
213
222
}
214
223
0 commit comments