One function
default_namedtuple_deserializer in ramonhagenaars/jsons
The author described this change as “Fixed bug with loading empty tuple.”. It counts as a record because the check below fails on the code as it stood at f55527208 and passes on f56035a06, with nothing else changed between the two runs.
Projectramonhagenaars/jsons
Fix saved2019-03-15
Sharing licenceMIT · LICENSE
Change size+3 −2
What the code was meant to do, written into the code itself as a docstring
Deserialize a (JSON) list into a named tuple by deserializing all items of that list. :param obj: the tuple that needs deserializing. :param cls: the NamedTuple. :param kwargs: any keyword arguments. :return: a deserialized named tuple (i.e. an instance of a class).
The change
| 13 | 13 | field = obj[index] | |
| 14 | 14 | else: | |
| 15 | 15 | field = cls._field_defaults.get(field_name, None) | |
| 16 | - | if not field: | |
| 16 | + | if field is None: | |
| 17 | 17 | msg = ('No value present in {} for argument "{}"' | |
| 18 | 18 | .format(obj, field_name)) | |
| 19 | 19 | raise UnfulfilledArgumentError(msg, field_name, obj, cls) | |
| 20 | - | cls_ = cls._field_types.get(field_name, None) | |
| 20 | + | field_types = getattr(cls, '_field_types', None) | |
| 21 | + | cls_ = field_types.get(field_name) if field_types else None | |
| 21 | 22 | loaded_field = load(field, cls_, **kwargs) | |
| 22 | 23 | args.append(loaded_field) | |
| 23 | 24 | inst = cls(*args) |
The check that tells the two apart
fail→pass·tests/test_tuple.py::TestTuple::test_load_namedtuple_with_empty
Check file tests/test_tuple.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itf5552720826916676a1339812b3301e5e8ab1213
Broken version dated2019-03-14
Modulejsons.deserializers.default_tuple
Units changeddefault_namedtuple_deserializer
Fingerprint2e5268b52aef86f0
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in ramonhagenaars/jsons
- 2019-07-13Solved bug reported in Issue#64.