Whole file

wbond/asn1crypto

The author described this change as Fix type checking in pem.armor(). It counts as a record because the check below fails on the code as it stood at 7f587d56f and passes on b7256ed36, with nothing else changed between the two runs.

Fix saved2017-11-28
Sharing licenceMIT · LICENSE
Change size+4 4

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

Fix type checking in pem.armor()

The change

1616 import sys
1717
1818 from ._errors import unwrap
19-from ._types import type_name, str_cls, byte_cls
19+from ._types import type_name as _type_name, str_cls, byte_cls
2020
2121 if sys.version_info < (3,):
2222 from cStringIO import StringIO as BytesIO
4141 '''
4242 byte_string must be a byte string, not %s
4343 ''',
44- type_name(byte_string)
44+ _type_name(byte_string)
4545 ))
4646
4747 return byte_string.find(b'-----BEGIN') != -1 or byte_string.find(b'---- BEGIN') != -1
7171 raise TypeError(unwrap(
7272 '''
7373 der_bytes must be a byte string, not %s
74- ''' % type_name(der_bytes)
74+ ''' % _type_name(der_bytes)
7575 ))
7676
7777 if not isinstance(type_name, str_cls):
7979 '''
8080 type_name must be a unicode string, not %s
8181 ''',
82- type_name(type_name)
82+ _type_name(type_name)
8383 ))
8484
8585 type_name = type_name.upper().encode('ascii')

The check that tells the two apart

failpass·tests/test_pem.py::PEMTests::test_armor_wrong_type

Check file tests/test_pem.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 it7f587d56f2b5c4815bfed835cfc10abd9c49cdb2
Broken version dated2017-11-22
Moduleasn1crypto.pem
Units changedarmor, detect
Fingerprint5778095368b2c436
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 wbond/asn1crypto