[New-bugs-announce] [issue9873] Allow bytes in some APIs that use string literals internally

Nick Coghlan report at bugs.python.org
Thu Sep 16 15:25:12 CEST 2010

New submission from Nick Coghlan <ncoghlan at gmail.com>:

As per python-dev discussion in June, many Py3k APIs currently gratuitously prevent the use of bytes and bytearray objects as arguments due to their use of string literals internally.

(and plenty of other examples in urllib.parse)

While a strict reading of the relevant RFCs suggests that strings are the more appropriate type for these APIs, as a practical matter, protocol developers want to be able to operate on ASCII supersets as raw bytes.

The proposal is to modify the implementation of these functions such that string literals are used only with string arguments, and bytes literals otherwise. If a function accepts multiple values and a mixture of strings and bytes is passed in then the operation will still fail (as it should).

assignee: ncoghlan
components: Library (Lib)
messages: 116543
nosy: ncoghlan
priority: high
severity: normal
stage: needs patch
status: open
title: Allow bytes in some APIs that use string literals internally
type: behavior
versions: Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list