Converts a string containing hexadecimal encoding into a bytes-object. It works by encoding the given string h as ASCII, then interpreting each of its two-character ASCII tuples as bytes: - "00" to byte 0 - "ff" to byte 255 - "FF" also to byte 255 The strin
(h)
| 42 | DEFAULT_HTTP_TIMEOUT = 30 |
| 43 | |
| 44 | def unhexlify_str(h): |
| 45 | """ |
| 46 | Converts a string containing hexadecimal encoding into a bytes-object. |
| 47 | |
| 48 | It works by encoding the given string h as ASCII, then interpreting each of |
| 49 | its two-character ASCII tuples as bytes: |
| 50 | - "00" to byte 0 |
| 51 | - "ff" to byte 255 |
| 52 | - "FF" also to byte 255 |
| 53 | |
| 54 | The string must only contain characters in the ranges 0-9, a-f and A-F. |
| 55 | |
| 56 | If the string contains characters not in ASCII, |
| 57 | UnicodeEncodeError is raised. |
| 58 | If the string contains out-of-range ASCII characters, |
| 59 | binascii.Error is raised. |
| 60 | If number of encoded ASCII bytes is odd, |
| 61 | binascii.Error is raised. |
| 62 | """ |
| 63 | return binascii.unhexlify(h.encode('ascii')) |
| 64 | |
| 65 | def hexlify_str(b): |
| 66 | """ |
no outgoing calls
no test coverage detected