Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
Prev Previous commit
Next Next commit
MNT: further simplify handling the both old and new code paths
obj is only `None` in the <3.13 code path if the weakref is dead.  Handle and
return early to simplify later code.
  • Loading branch information
tacaswell committed Jan 30, 2026
commit 6a069108dcb3ec766a72b2b920efe0be7ec6f025
35 changes: 19 additions & 16 deletions src/share.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,31 +271,34 @@ share_cleanup_and_count_live_easies(CurlShareObject *self)
// in either case, mark as removable and
// move to the next reference
if (rc < 1 || obj == NULL) {
Comment thread
tacaswell marked this conversation as resolved.
Outdated
PyList_Append(to_remove, wr);
Py_DECREF(wr);
continue;
PyList_Append(to_remove, wr);
Py_DECREF(wr);
continue;
}

#else
// will borrowed reference, None if object dead
obj = PyWeakref_GetObject(wr);
// Either way we need to INCREF to keep it around
Py_INCREF(obj);
#endif
if (obj != Py_None) {
Comment thread
tacaswell marked this conversation as resolved.
CurlObject *easy = (CurlObject *)obj;
// If not None, real object, INCREF and carry on
Py_INCREF(obj);
} else {
// otherwise mark for removal and move to the next ref
PyList_Append(to_remove, wr);
Py_DECREF(wr);
continue;
}
#endif
CurlObject *easy = (CurlObject *)obj;

if (easy && easy->share == self) {
if (self->detach_on_close) {
curl_easy_setopt(easy->handle, CURLOPT_SHARE, NULL);
easy->share = NULL;
if (easy && easy->share == self) {
if (self->detach_on_close) {
curl_easy_setopt(easy->handle, CURLOPT_SHARE, NULL);
easy->share = NULL;

PyList_Append(to_remove, wr);
} else {
has_live += 1;
}
} else {
PyList_Append(to_remove, wr);
} else {
has_live += 1;
}
} else {
PyList_Append(to_remove, wr);
Expand Down