[New-bugs-announce] [issue6687] Move the special-case for integer objects out of PyBytes_FromObject.

Alexandre Vassalotti report at bugs.python.org
Tue Aug 11 23:15:32 CEST 2009


New submission from Alexandre Vassalotti <alexandre at peadrop.com>:

The documentation for PyBytes_FromObject states:

.. cfunction:: PyObject* PyBytes_FromObject(PyObject *o)

   Return the bytes representation of object *o* that implements
   the buffer protocol.

However, there exists a special-case for integer object in
PyBytes_FromObject that makes the function return a null-initialized
bytes object. Currently, this is only used for handling `bytes(10)'.

I don't like changing APIs after a stable release, but I believe this
behaviour is error-prone and surprising (and darn right annoying even).
So, I believe the special-case should be made specific to the bytes
constructor.

Thus, here is the fine patch.

----------
components: Interpreter Core
files: move_int_special_case.diff
keywords: 26backport, patch
messages: 91483
nosy: alexandre.vassalotti
priority: normal
severity: normal
stage: patch review
status: open
title: Move the special-case for integer objects out of PyBytes_FromObject.
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file14693/move_int_special_case.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6687>
_______________________________________


More information about the New-bugs-announce mailing list