FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-156939: Fix Modules/_testcapi/bytes.c: remove double Py_DECREF by vstinner · Pull Request #158400 · python/cpython · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 4 additions & 5 deletions Modules/_testcapi/bytes.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ static PyMethodDef writer_methods[] = {
{"get_size", _PyCFunction_CAST(writer_get_size), METH_NOARGS},
{"finish", _PyCFunction_CAST(writer_finish), METH_NOARGS},
{"finish_with_size", _PyCFunction_CAST(writer_finish_with_size), METH_VARARGS},
{"discard", _PyCFunction_CAST(writer_discard), METH_VARARGS},
{"discard", _PyCFunction_CAST(writer_discard), METH_NOARGS},
{NULL, NULL} /* sentinel */
};

Expand Down Expand Up @@ -470,7 +470,7 @@ test_byteswriter_ptr(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
memset(str, 'x', 100);
str += 100;

// make sure that the test switchs to a bytes object
// make sure that the test switches to a bytes object
assert((100 + 200) > pybyteswriter_small_buffer_size());
char *old_str = str;
str = PyBytesWriter_GrowAndUpdatePointer(writer, 200, str);
Expand All @@ -489,10 +489,10 @@ test_byteswriter_ptr(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
}
assert(PyBytes_GET_SIZE(result) == 300);
str = PyBytes_AS_STRING(result);
for (Py_ssize_t i=0; i < 100; i++) {
for (Py_ssize_t i = 0; i < 100; i++) {
assert(str[i] == 'x');
}
for (Py_ssize_t i=0; i < 200; i++) {
for (Py_ssize_t i = 0; i < 200; i++) {
assert(str[100 + i] == 'y');
}
Py_DECREF(result);
Expand Down Expand Up @@ -615,7 +615,6 @@ _PyTestCapi_Init_Bytes(PyObject *m)
// PyBytesWriter.obj is the second member, small_buffer is the first member
long size = (long)pybyteswriter_small_buffer_size();
if (PyModule_AddIntConstant(m, "PyBytesWriter_small_buffer", size) < 0) {
Py_DECREF(writer_type);
return -1;
}

Expand Down
Loading

Back | FazBrowse Home | New Git URL