@@ -368,15 +368,20 @@ error_at_directive(PySTEntryObject *ste, PyObject *name)
368368 Py_ssize_t i ;
369369 PyObject * data ;
370370 assert (ste -> ste_directives );
371- for (i = 0 ; ; i ++ ) {
371+ for (i = 0 ; i < PyList_GET_SIZE ( ste -> ste_directives ) ; i ++ ) {
372372 data = PyList_GET_ITEM (ste -> ste_directives , i );
373373 assert (PyTuple_CheckExact (data ));
374- if (PyTuple_GET_ITEM (data , 0 ) == name )
375- break ;
374+ assert (PyUnicode_CheckExact (PyTuple_GET_ITEM (data , 0 )));
375+ if (PyUnicode_Compare (PyTuple_GET_ITEM (data , 0 ), name ) == 0 ) {
376+ PyErr_SyntaxLocationObject (ste -> ste_table -> st_filename ,
377+ PyLong_AsLong (PyTuple_GET_ITEM (data , 1 )),
378+ PyLong_AsLong (PyTuple_GET_ITEM (data , 2 )));
379+
380+ return 0 ;
381+ }
376382 }
377- PyErr_SyntaxLocationObject (ste -> ste_table -> st_filename ,
378- PyLong_AsLong (PyTuple_GET_ITEM (data , 1 )),
379- PyLong_AsLong (PyTuple_GET_ITEM (data , 2 )));
383+ PyErr_SetString (PyExc_RuntimeError ,
384+ "BUG: internal directive bookkeeping broken" );
380385 return 0 ;
381386}
382387
@@ -1115,14 +1120,17 @@ symtable_new_tmpname(struct symtable *st)
11151120static int
11161121symtable_record_directive (struct symtable * st , identifier name , stmt_ty s )
11171122{
1118- PyObject * data ;
1123+ PyObject * data , * mangled ;
11191124 int res ;
11201125 if (!st -> st_cur -> ste_directives ) {
11211126 st -> st_cur -> ste_directives = PyList_New (0 );
11221127 if (!st -> st_cur -> ste_directives )
11231128 return 0 ;
11241129 }
1125- data = Py_BuildValue ("(Oii)" , name , s -> lineno , s -> col_offset );
1130+ mangled = _Py_Mangle (st -> st_private , name );
1131+ if (!mangled )
1132+ return 0 ;
1133+ data = Py_BuildValue ("(Nii)" , mangled , s -> lineno , s -> col_offset );
11261134 if (!data )
11271135 return 0 ;
11281136 res = PyList_Append (st -> st_cur -> ste_directives , data );
0 commit comments