diff options
author | Bénédikt Tran <10796600+picnixz@users.noreply.github.com> | 2025-01-14 13:25:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-14 13:25:33 (GMT) |
commit | bbd3300ae82a71da483dbb0c345175ba090263c4 (patch) | |
tree | ab4507f6a5f49876f21b89b4b43b798439db15f8 /Lib/base64.py | |
parent | 859db49029b1021e24b5c99d4a9a0f57327d1b57 (diff) | |
download | cpython-bbd3300ae82a71da483dbb0c345175ba090263c4.zip cpython-bbd3300ae82a71da483dbb0c345175ba090263c4.tar.gz cpython-bbd3300ae82a71da483dbb0c345175ba090263c4.tar.bz2 |
gh-118761: substitute `re` import in `base64.b16decode` for a more efficient alternative (#128736)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Chris Markiewicz <effigies@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Diffstat (limited to 'Lib/base64.py')
-rw-r--r-- | Lib/base64.py | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/base64.py b/Lib/base64.py index 61be4fb..5d78cc0 100644 --- a/Lib/base64.py +++ b/Lib/base64.py @@ -4,7 +4,6 @@ # Modified 30-Dec-2003 by Barry Warsaw to add full RFC 3548 support # Modified 22-May-2007 by Guido van Rossum to use bytes everywhere -import re import struct import binascii @@ -284,7 +283,7 @@ def b16decode(s, casefold=False): s = _bytes_from_decode_data(s) if casefold: s = s.upper() - if re.search(b'[^0-9A-F]', s): + if s.translate(None, delete=b'0123456789ABCDEF'): raise binascii.Error('Non-base16 digit found') return binascii.unhexlify(s) |