The C WeaselJsonCallbacks struct in include/weaseljson.h orders its function pointers as: on_begin_object, on_end_object, on_string_data, on_key_data, on_begin_array, on_end_array, on_number_data, on_true_literal, on_false_literal, on_null_literal.
weaseljson.py defines WeaselJsonCallbacks._fields_ (lines 13-30) with only nine entries and places on_begin_array where on_key_data should be, completely omitting the key callback. This misaligns the ctypes struct with the C layout, so any JSON document containing object keys reads an incorrect function pointer and/or routes key data to the wrong Python callback.
Additional gaps:
WeaselJsonCallbacksBase (lines 33-58) has no on_key_data method.
The module-level c_callbacks object built from the global callback wrappers (around line 150) does not include an on_key_data wrapper.
Consequences:
Python users cannot implement key handling.
Parsing objects is likely to crash or silently deliver key bytes through on_string_data.
Expected: WeaselJsonCallbacks should contain on_key_data in the correct position, WeaselJsonCallbacksBase should expose on_key_data(self, data, done), and a corresponding ctypes wrapper should be added to c_callbacks.
The C `WeaselJsonCallbacks` struct in `include/weaseljson.h` orders its function pointers as:
`on_begin_object`, `on_end_object`, `on_string_data`, `on_key_data`, `on_begin_array`, `on_end_array`, `on_number_data`, `on_true_literal`, `on_false_literal`, `on_null_literal`.
`weaseljson.py` defines `WeaselJsonCallbacks._fields_` (lines 13-30) with only nine entries and places `on_begin_array` where `on_key_data` should be, completely omitting the key callback. This misaligns the ctypes struct with the C layout, so any JSON document containing object keys reads an incorrect function pointer and/or routes key data to the wrong Python callback.
Additional gaps:
- `WeaselJsonCallbacksBase` (lines 33-58) has no `on_key_data` method.
- The module-level `c_callbacks` object built from the global callback wrappers (around line 150) does not include an `on_key_data` wrapper.
Consequences:
- Python users cannot implement key handling.
- Parsing objects is likely to crash or silently deliver key bytes through `on_string_data`.
Expected: `WeaselJsonCallbacks` should contain `on_key_data` in the correct position, `WeaselJsonCallbacksBase` should expose `on_key_data(self, data, done)`, and a corresponding ctypes wrapper should be added to `c_callbacks`.
weaselbot
was assigned by andrew2026-06-18 14:05:37 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
The C
WeaselJsonCallbacksstruct ininclude/weaseljson.horders its function pointers as:on_begin_object,on_end_object,on_string_data,on_key_data,on_begin_array,on_end_array,on_number_data,on_true_literal,on_false_literal,on_null_literal.weaseljson.pydefinesWeaselJsonCallbacks._fields_(lines 13-30) with only nine entries and placeson_begin_arraywhereon_key_datashould be, completely omitting the key callback. This misaligns the ctypes struct with the C layout, so any JSON document containing object keys reads an incorrect function pointer and/or routes key data to the wrong Python callback.Additional gaps:
WeaselJsonCallbacksBase(lines 33-58) has noon_key_datamethod.c_callbacksobject built from the global callback wrappers (around line 150) does not include anon_key_datawrapper.Consequences:
on_string_data.Expected:
WeaselJsonCallbacksshould containon_key_datain the correct position,WeaselJsonCallbacksBaseshould exposeon_key_data(self, data, done), and a corresponding ctypes wrapper should be added toc_callbacks.