[Python-3000-checkins] r66038 - in python/branches/py3k: Doc/c-api/bytes.rst Doc/c-api/object.rst Include/bytesobject.h Include/object.h Lib/test/test_bytes.py Misc/NEWS Objects/bytesobject.c Objects/object.c
Neal Norwitz
nnorwitz at gmail.com
Wed Aug 27 02:04:36 CEST 2008
On Tue, Aug 26, 2008 at 5:02 PM, Benjamin Peterson
<musiccomposition at gmail.com> wrote:
> On Tue, Aug 26, 2008 at 6:53 PM, Neal Norwitz <nnorwitz at gmail.com> wrote:
>> On Tue, Aug 26, 2008 at 9:46 AM, benjamin.peterson
>> <python-3000-checkins at python.org> wrote:
>>> Modified: python/branches/py3k/Objects/bytesobject.c
>>> ==============================================================================
>>> --- python/branches/py3k/Objects/bytesobject.c (original)
>>> +++ python/branches/py3k/Objects/bytesobject.c Tue Aug 26 18:46:47 2008
>>> @@ -2924,6 +2923,14 @@
>>> "encoding or errors without a string argument");
>>> return NULL;
>>> }
>>> + return PyObject_Bytes(x);
>>> +}
>>> +
>>> +PyObject *
>>> +PyBytes_FromObject(PyObject *x)
>>> +{
>>> + PyObject *new, *it;
>>> + Py_ssize_t i, size;
>>>
>>> /* Is it an int? */
>>> size = PyNumber_AsSsize_t(x, PyExc_ValueError);
>>
>> What happens if x (the object passed in) is NULL?
>
> It segfaults, but this is ok because PyObject_Bytes checks for NULL.
Since this is now a public API, anyone can pass NULL here. In general
we check for NULLs from most public APIs (I think). Though IIRC we
are pretty inconsistent.
n
More information about the Python-3000-checkins
mailing list