8000 gh-132070: Use _PyObject_IsUniquelyReferenced in unicodeobject by corona10 · Pull Request #133039 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-132070: Use _PyObject_IsUniquelyReferenced in unicodeobject #133039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 29, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
use unique ref
  • Loading branch information
kumaraditya303 authored and corona10 committed Apr 27, 2025
commit f7acd60b07a032fdf3d5c1d5d854ed7ed9da4f02
4 changes: 2 additions & 2 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,7 +1816,7 @@ static int
unicode_modifiable(PyObject *unicode)
{
assert(_PyUnicode_CHECK(unicode));
if (Py_REFCNT(unicode) != 1)
if (!_PyObject_IsUniquelyReferenced(unicode))
return 0;
if (PyUnicode_HASH(unicode) != -1)
return 0;
Expand Down Expand Up @@ -14738,7 +14738,7 @@ _PyUnicode_FormatLong(PyObject *val, int alt, int prec, int type)
assert(PyUnicode_IS_ASCII(result));

/* To modify the string in-place, there can only be one reference. */
if (Py_REFCNT(result) != 1) {
if (!_PyObject_IsUniquelyReferenced(result)) {
Py_DECREF(result);
PyErr_BadInternalCall();
return NULL;
Expand Down
Loading
0