Skip to content

Commit b56f3c5

Browse files
committed
Regen and simplify
1 parent 596af7f commit b56f3c5

File tree

5 files changed

+78
-60
lines changed

5 files changed

+78
-60
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,11 @@ struct _Py_global_strings {
376376
STRUCT_FOR_ID(co_varnames)
377377
STRUCT_FOR_ID(code)
378378
STRUCT_FOR_ID(col_offset)
379+
STRUCT_FOR_ID(collector)
379380
STRUCT_FOR_ID(command)
380381
STRUCT_FOR_ID(comment_factory)
381382
STRUCT_FOR_ID(compile_mode)
383+
STRUCT_FOR_ID(compression)
382384
STRUCT_FOR_ID(config)
383385
STRUCT_FOR_ID(consts)
384386
STRUCT_FOR_ID(context)
@@ -441,7 +443,9 @@ struct _Py_global_strings {
441443
STRUCT_FOR_ID(event)
442444
STRUCT_FOR_ID(eventmask)
443445
STRUCT_FOR_ID(exc)
446+
STRUCT_FOR_ID(exc_tb)
444447
STRUCT_FOR_ID(exc_type)
448+
STRUCT_FOR_ID(exc_val)
445449
STRUCT_FOR_ID(exc_value)
446450
STRUCT_FOR_ID(excepthook)
447451
STRUCT_FOR_ID(exception)
@@ -697,6 +701,7 @@ struct _Py_global_strings {
697701
STRUCT_FOR_ID(print_file_and_line)
698702
STRUCT_FOR_ID(priority)
699703
STRUCT_FOR_ID(progress)
704+
STRUCT_FOR_ID(progress_callback)
700705
STRUCT_FOR_ID(progress_routine)
701706
STRUCT_FOR_ID(proto)
702707
STRUCT_FOR_ID(protocol)
@@ -736,6 +741,7 @@ struct _Py_global_strings {
736741
STRUCT_FOR_ID(reversed)
737742
STRUCT_FOR_ID(rounding)
738743
STRUCT_FOR_ID(salt)
744+
STRUCT_FOR_ID(sample_interval_us)
739745
STRUCT_FOR_ID(sched_priority)
740746
STRUCT_FOR_ID(scheduler)
741747
STRUCT_FOR_ID(script)
@@ -775,8 +781,10 @@ struct _Py_global_strings {
775781
STRUCT_FOR_ID(spam)
776782
STRUCT_FOR_ID(src)
777783
STRUCT_FOR_ID(src_dir_fd)
784+
STRUCT_FOR_ID(stack_frames)
778785
STRUCT_FOR_ID(stacklevel)
779786
STRUCT_FOR_ID(start)
787+
STRUCT_FOR_ID(start_time_us)
780788
STRUCT_FOR_ID(statement)
781789
STRUCT_FOR_ID(stats)
782790
STRUCT_FOR_ID(status)
@@ -817,6 +825,7 @@ struct _Py_global_strings {
817825
STRUCT_FOR_ID(times)
818826
STRUCT_FOR_ID(timespec)
819827
STRUCT_FOR_ID(timestamp)
828+
STRUCT_FOR_ID(timestamp_us)
820829
STRUCT_FOR_ID(timetuple)
821830
STRUCT_FOR_ID(timeunit)
822831
STRUCT_FOR_ID(top)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_remote_debugging/binary_io.h

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,11 @@ encode_varint_i32(uint8_t *buf, int32_t value)
320320
return encode_varint_u32(buf, zigzag);
321321
}
322322

323-
/* Decode unsigned 64-bit varint. Updates offset only on success. Returns value.
323+
/* Decode unsigned 64-bit varint (LEB128). Updates offset only on success.
324324
* On error (overflow or incomplete), offset is NOT updated, allowing callers
325-
* to detect errors via (offset == prev_offset) check.
326-
* On success, sets *error to 0 if error is non-NULL.
327-
* On error, sets *error to 1 if error is non-NULL. */
325+
* to detect errors via (offset == prev_offset) check. Sets PyErr on error. */
328326
static inline uint64_t
329-
decode_varint_u64_ex(const uint8_t *data, size_t *offset, size_t max_size, int *error)
327+
decode_varint_u64(const uint8_t *data, size_t *offset, size_t max_size)
330328
{
331329
size_t pos = *offset;
332330
uint64_t result = 0;
@@ -335,7 +333,6 @@ decode_varint_u64_ex(const uint8_t *data, size_t *offset, size_t max_size, int *
335333
/* Fast path for single-byte varints (0-127) - most common case */
336334
if (LIKELY(pos < max_size && (data[pos] & 0x80) == 0)) {
337335
*offset = pos + 1;
338-
if (error) *error = 0;
339336
return data[pos];
340337
}
341338

@@ -344,87 +341,45 @@ decode_varint_u64_ex(const uint8_t *data, size_t *offset, size_t max_size, int *
344341
result |= (uint64_t)(byte & 0x7F) << shift;
345342
if ((byte & 0x80) == 0) {
346343
*offset = pos;
347-
if (error) *error = 0;
348344
return result;
349345
}
350346
shift += 7;
351347
if (UNLIKELY(shift >= 64)) {
352-
/* Overflow - do NOT update offset so caller can detect error */
353-
if (error) *error = 1;
348+
PyErr_SetString(PyExc_ValueError, "Invalid or incomplete varint in binary data");
354349
return 0;
355350
}
356351
}
357352

358-
/* Incomplete varint - do NOT update offset so caller can detect error */
359-
if (error) *error = 1;
353+
PyErr_SetString(PyExc_ValueError, "Invalid or incomplete varint in binary data");
360354
return 0;
361355
}
362356

363-
/* Backward-compatible wrapper that sets PyErr on error.
364-
* Callers should check PyErr_Occurred() after batch operations. */
365-
static inline uint64_t
366-
decode_varint_u64(const uint8_t *data, size_t *offset, size_t max_size)
367-
{
368-
int error = 0;
369-
uint64_t result = decode_varint_u64_ex(data, offset, max_size, &error);
370-
if (UNLIKELY(error)) {
371-
PyErr_SetString(PyExc_ValueError, "Invalid or incomplete varint in binary data");
372-
}
373-
return result;
374-
}
375-
376-
/* Decode unsigned 32-bit varint with explicit error handling.
377-
* If value exceeds UINT32_MAX, treats as error: offset is NOT updated,
378-
* *error is set to 1, allowing callers to detect via (offset == prev_offset). */
357+
/* Decode unsigned 32-bit varint. If value exceeds UINT32_MAX, treats as error. */
379358
static inline uint32_t
380-
decode_varint_u32_ex(const uint8_t *data, size_t *offset, size_t max_size, int *error)
359+
decode_varint_u32(const uint8_t *data, size_t *offset, size_t max_size)
381360
{
382361
size_t saved_offset = *offset;
383-
uint64_t value = decode_varint_u64_ex(data, offset, max_size, error);
384-
if (error && *error) {
385-
/* decode_varint_u64_ex already handled the error, offset unchanged */
362+
uint64_t value = decode_varint_u64(data, offset, max_size);
363+
if (PyErr_Occurred()) {
386364
return 0;
387365
}
388366
if (UNLIKELY(value > UINT32_MAX)) {
389-
/* Value overflow - restore offset so caller can detect error */
390367
*offset = saved_offset;
391-
if (error) *error = 1;
368+
PyErr_SetString(PyExc_ValueError, "Invalid or incomplete varint in binary data");
392369
return 0;
393370
}
394371
return (uint32_t)value;
395372
}
396373

397-
/* Backward-compatible wrapper that sets PyErr on error. */
398-
static inline uint32_t
399-
decode_varint_u32(const uint8_t *data, size_t *offset, size_t max_size)
400-
{
401-
int error = 0;
402-
uint32_t result = decode_varint_u32_ex(data, offset, max_size, &error);
403-
if (UNLIKELY(error)) {
404-
PyErr_SetString(PyExc_ValueError, "Invalid or incomplete varint in binary data");
405-
}
406-
return result;
407-
}
408-
409-
/* Decode signed 32-bit varint (zigzag) with explicit error handling. */
410-
static inline int32_t
411-
decode_varint_i32_ex(const uint8_t *data, size_t *offset, size_t max_size, int *error)
412-
{
413-
uint32_t zigzag = decode_varint_u32_ex(data, offset, max_size, error);
414-
/* Zigzag decode */
415-
return (int32_t)((zigzag >> 1) ^ -(int32_t)(zigzag & 1));
416-
}
417-
418-
/* Backward-compatible wrapper that sets PyErr on error. */
374+
/* Decode signed 32-bit varint (zigzag encoding). */
419375
static inline int32_t
420376
decode_varint_i32(const uint8_t *data, size_t *offset, size_t max_size)
421377
{
422-
int error = 0;
423-
int32_t result = decode_varint_i32_ex(data, offset, max_size, &error);
424-
if (UNLIKELY(error)) {
425-
PyErr_SetString(PyExc_ValueError, "Invalid or incomplete varint in binary data");
378+
uint32_t zigzag = decode_varint_u32(data, offset, max_size);
379+
if (PyErr_Occurred()) {
380+
return 0;
426381
}
427-
return result;
382+
return (int32_t)((zigzag >> 1) ^ -(int32_t)(zigzag & 1));
428383
}
429384

430385
/* ============================================================================

0 commit comments

Comments
 (0)