Whole file

andrivet/python-asn1

The author described this change as Fix #296. Do not assume Universal for values. Add and fix tests.. It counts as a record because the check below fails on the code as it stood at b11bec2b4 and passes on fb12598bd, with nothing else changed between the two runs.

Fix saved2026-05-15
Sharing licenceMIT · LICENSE
Change size+1 1

What the code was meant to do, written into the code itself as a save note

Fix #296. Do not assume Universal for values. Add and fix tests.

The change

561561
562562 def _encode_value(self, cls, nr, value): # type: (int, int, Any) -> bytes
563563 """Encode a value."""
564- if cls != Classes.Universal:
564+ if isinstance(value, bytes) and nr != Numbers.BitString: # Assume it is already encoded (raw value)
565565 return value
566566
567567 if nr in (Numbers.Integer, Numbers.Enumerated):

The check that tells the two apart

failpass·tests/test_asn1.py::TestEncoder::test_application_integer

Check file tests/test_asn1.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 itb11bec2b44505c56dd4a7e70de2aa3d98fd5b658
Broken version dated2026-05-13
Moduleasn1.core
Units changedEncoder
Fingerprintd3f01637c240dc8e
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.