[issue9996] binascii should convert unicode strings
report at bugs.python.org
Thu Sep 30 14:03:28 CEST 2010
New submission from Arnon Yaari <wiggin15 at gmail.com>:
binascii is currently bytes-only, although the "a" in a2b\b2a should refer to unicode strings.
This patch fixes all a2b functions to take str type and all b2a functions to return str types.
This was discussed several times, for example:
As discussed, the required behavior in Python 3k is that a2b should convert str to bytes and vice versa, and this was implemented in this patch.
This patch breaks backward compatibility in several functions... It also required fixing several files under Lib (although most cases were simplified), and also to change the interface of the base64 and quopri modules (this was also requested, e.g. http://bugs.python.org/issue4769).
Note that there already was a small change in this behavior from 3.1 to 3.2 (http://bugs.python.org/issue4770) - b2a_hex and b2a_qp COULD receive strings as input in 3.1 and this was changed in 3.2, so technically, compatibility was already broken...
The patch includes updates to the standard library, the tests and documentation.
rlecode and rledecode were left untouched because they are not a2b\b2a functions per se - they work on the input and output of the hqx functions (maybe it's a good idea to add new a2b\b2a functions for rle_hqx).
Any thoughts are welcome.
components: Interpreter Core
title: binascii should convert unicode strings
versions: Python 3.2
Added file: http://bugs.python.org/file19067/binascii.diff
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list