@@ -456,15 +456,15 @@ code_getlnotab(PyCodeObject *code, void *closure)
456
456
}
457
457
_PyCode_InitAddressRange (code , & bounds );
458
458
while (PyLineTable_NextAddressRange (& bounds )) {
459
- if (bounds .ar_computed_line != line ) {
459
+ if (bounds .opaque . computed_line != line ) {
460
460
int bdelta = bounds .ar_start - code_offset ;
461
- int ldelta = bounds .ar_computed_line - line ;
461
+ int ldelta = bounds .opaque . computed_line - line ;
462
462
if (!emit_delta (& bytes , bdelta , ldelta , & table_offset )) {
463
463
Py_DECREF (bytes );
464
464
return NULL ;
465
465
}
466
466
code_offset = bounds .ar_start ;
467
- line = bounds .ar_computed_line ;
467
+ line = bounds .opaque . computed_line ;
468
468
}
469
469
}
470
470
_PyBytes_Resize (& bytes , table_offset );
@@ -1120,44 +1120,43 @@ code_linesiterator(PyCodeObject *code, PyObject *Py_UNUSED(args))
1120
1120
static void
1121
1121
retreat (PyCodeAddressRange * bounds )
1122
1122
{
1123
- int ldelta = ((signed char * )bounds -> lo_next )[-1 ];
1123
+ int ldelta = ((signed char * )bounds -> opaque . lo_next )[-1 ];
1124
1124
if (ldelta == -128 ) {
1125
1125
ldelta = 0 ;
1126
1126
}
1127
- bounds -> ar_computed_line -= ldelta ;
1128
- bounds -> lo_next -= 2 ;
1127
+ bounds -> opaque . computed_line -= ldelta ;
1128
+ bounds -> opaque . lo_next -= 2 ;
1129
1129
bounds -> ar_end = bounds -> ar_start ;
1130
- bounds -> ar_start -= ((unsigned char * )bounds -> lo_next )[-2 ];
1131
- ldelta = ((signed char * )bounds -> lo_next )[-1 ];
1130
+ bounds -> ar_start -= ((unsigned char * )bounds -> opaque . lo_next )[-2 ];
1131
+ ldelta = ((signed char * )bounds -> opaque . lo_next )[-1 ];
1132
1132
if (ldelta == -128 ) {
1133
1133
bounds -> ar_line = -1 ;
1134
1134
}
1135
1135
else {
1136
- bounds -> ar_line = bounds -> ar_computed_line ;
1136
+ bounds -> ar_line = bounds -> opaque . computed_line ;
1137
1137
}
1138
1138
}
1139
1139
1140
1140
static void
1141
1141
advance (PyCodeAddressRange * bounds )
1142
1142
{
1143
1143
bounds -> ar_start = bounds -> ar_end ;
1144
- int delta = ((unsigned char * )bounds -> lo_next )[0 ];
1145
- assert (delta < 255 );
1144
+ int delta = ((unsigned char * )bounds -> opaque .lo_next )[0 ];
1146
1145
bounds -> ar_end += delta ;
1147
- int ldelta = ((signed char * )bounds -> lo_next )[1 ];
1148
- bounds -> lo_next += 2 ;
1146
+ int ldelta = ((signed char * )bounds -> opaque . lo_next )[1 ];
1147
+ bounds -> opaque . lo_next += 2 ;
1149
1148
if (ldelta == -128 ) {
1150
1149
bounds -> ar_line = -1 ;
1151
1150
}
1152
1151
else {
1153
- bounds -> ar_computed_line += ldelta ;
1154
- bounds -> ar_line = bounds -> ar_computed_line ;
1152
+ bounds -> opaque . computed_line += ldelta ;
1153
+ bounds -> ar_line = bounds -> opaque . computed_line ;
1155
1154
}
1156
1155
}
1157
1156
1158
1157
static inline int
1159
1158
at_end (PyCodeAddressRange * bounds ) {
1160
- return (( unsigned char * ) bounds -> lo_next )[ 0 ] == 255 ;
1159
+ return bounds -> opaque . lo_next >= bounds -> opaque . limit ;
1161
1160
}
1162
1161
1163
1162
int
@@ -1256,20 +1255,22 @@ PyCode_Addr2Line(PyCodeObject *co, int addrq)
1256
1255
}
1257
1256
1258
1257
void
1259
- PyLineTable_InitAddressRange (char * linetable , int firstlineno , PyCodeAddressRange * range )
1258
+ PyLineTable_InitAddressRange (char * linetable , Py_ssize_t length , int firstlineno , PyCodeAddressRange * range )
1260
1259
{
1261
- range -> lo_next = linetable ;
1260
+ range -> opaque .lo_next = linetable ;
1261
+ range -> opaque .limit = range -> opaque .lo_next + length ;
1262
1262
range -> ar_start = -1 ;
1263
1263
range -> ar_end = 0 ;
1264
- range -> ar_computed_line = firstlineno ;
1264
+ range -> opaque . computed_line = firstlineno ;
1265
1265
range -> ar_line = -1 ;
1266
1266
}
1267
1267
1268
1268
int
1269
1269
_PyCode_InitAddressRange (PyCodeObject * co , PyCodeAddressRange * bounds )
1270
1270
{
1271
1271
char * linetable = PyBytes_AS_STRING (co -> co_linetable );
1272
- PyLineTable_InitAddressRange (linetable , co -> co_firstlineno , bounds );
1272
+ Py_ssize_t length = PyBytes_GET_SIZE (co -> co_linetable );
1273
+ PyLineTable_InitAddressRange (linetable , length , co -> co_firstlineno , bounds );
1273
1274
return bounds -> ar_line ;
1274
1275
}
1275
1276
0 commit comments