Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cfcde8c commit 88d146bCopy full SHA for 88d146b
1 file changed
Objects/bytesobject.c
@@ -3174,10 +3174,12 @@ PyBytes_FromObject(PyObject *x)
3174
returning a shared empty bytes string. This required because we
3175
want to call _PyBytes_Resize() the returned object, which we can
3176
only do on bytes objects with refcount == 1. */
3177
- size += 1;
+ if (size == 0)
3178
+ size = 1;
3179
new = PyBytes_FromStringAndSize(NULL, size);
3180
if (new == NULL)
3181
return NULL;
3182
+ assert(Py_REFCNT(new) == 1);
3183
3184
/* Get the iterator */
3185
it = PyObject_GetIter(x);
0 commit comments