[New-bugs-announce] [issue22575] bytearray documentation confuses string for unicode objects

Martijn Pieters report at bugs.python.org
Tue Oct 7 19:34:20 CEST 2014

New submission from Martijn Pieters:

The Python 2 version of the bytearray() documentation appears to be copied directly from its Python 3 counterpart and states that when passing in a string an encoding is required:

* If it is a string, you must also give the encoding (and optionally, errors) parameters; bytearray() then converts the string to bytes using str.encode().

(from https://docs.python.org/2/library/functions.html#bytearray).

This obviously doesn't apply to Python 2 str() objects, but would only apply to unicode() objects.

Can this be corrected? The current wording is confusing new users (see http://stackoverflow.com/questions/26230745/how-to-convert-python-str-to-bytearray).

assignee: docs at python
components: Documentation
messages: 228771
nosy: docs at python, mjpieters
priority: normal
severity: normal
status: open
title: bytearray documentation confuses string for unicode objects
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list