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.
Projectwbond/asn1crypto
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
| 16 | 16 | import sys | |
| 17 | 17 | ||
| 18 | 18 | 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 | |
| 20 | 20 | ||
| 21 | 21 | if sys.version_info < (3,): | |
| 22 | 22 | from cStringIO import StringIO as BytesIO | |
| ⋯ | |||
| 41 | 41 | ''' | |
| 42 | 42 | byte_string must be a byte string, not %s | |
| 43 | 43 | ''', | |
| 44 | - | type_name(byte_string) | |
| 44 | + | _type_name(byte_string) | |
| 45 | 45 | )) | |
| 46 | 46 | ||
| 47 | 47 | return byte_string.find(b'-----BEGIN') != -1 or byte_string.find(b'---- BEGIN') != -1 | |
| ⋯ | |||
| 71 | 71 | raise TypeError(unwrap( | |
| 72 | 72 | ''' | |
| 73 | 73 | der_bytes must be a byte string, not %s | |
| 74 | - | ''' % type_name(der_bytes) | |
| 74 | + | ''' % _type_name(der_bytes) | |
| 75 | 75 | )) | |
| 76 | 76 | ||
| 77 | 77 | if not isinstance(type_name, str_cls): | |
| ⋯ | |||
| 79 | 79 | ''' | |
| 80 | 80 | type_name must be a unicode string, not %s | |
| 81 | 81 | ''', | |
| 82 | - | type_name(type_name) | |
| 82 | + | _type_name(type_name) | |
| 83 | 83 | )) | |
| 84 | 84 | ||
| 85 | 85 | type_name = type_name.upper().encode('ascii') | |
The check that tells the two apart
fail→pass·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
- 2021-12-05Fix Clearance type definition
- 2021-11-21Fix tagging for RoleSyntax and SecurityCategory
- 2021-08-14_parse
- 2019-09-23_dump_header
- 2017-02-07_parse
- 2016-03-29uri_to_iri