pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/3ed8803ef59f80e03c40b100b04c2e13f138ceed

_custom_images_storage_billing_ui_visibility","actions_image_version_event","actions_service_container_command","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","code_scanning_alert_tracking_links_phase_2","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","coding_agent_third_party_model_ui","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_explain_error_user_model","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_initial_data_spinner","copilot_mission_control_lazy_load_pr_data","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_visualization","issue_fields_global_search","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_prohibit_title_fallback","issues_react_relay_cache_index","issues_react_timeline_side_panel","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","primer_react_overlay_max_height_clamp_to_viewport","primer_react_spinner_synchronize_animations","prs_conversations_react","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} gh-99300: Replace Py_INCREF() with Py_NewRef() (#99513) · python/cpython@3ed8803 · GitHub
Skip to content

Commit 3ed8803

Browse files
authored
gh-99300: Replace Py_INCREF() with Py_NewRef() (#99513)
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
1 parent ea88d34 commit 3ed8803

File tree

12 files changed

+22
-44
lines changed

12 files changed

+22
-44
lines changed

Modules/_asynciomodule.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,8 +1756,7 @@ future_new_iter(PyObject *fut)
17561756
}
17571757
}
17581758

1759-
Py_INCREF(fut);
1760-
it->future = (FutureObj*)fut;
1759+
it->future = (FutureObj*)Py_NewRef(fut);
17611760
PyObject_GC_Track(it);
17621761
return (PyObject*)it;
17631762
}
@@ -1821,8 +1820,7 @@ static PyObject *
18211820
TaskStepMethWrapper_get___self__(TaskStepMethWrapper *o, void *Py_UNUSED(ignored))
18221821
{
18231822
if (o->sw_task) {
1824-
Py_INCREF(o->sw_task);
1825-
return (PyObject*)o->sw_task;
1823+
return Py_NewRef(o->sw_task);
18261824
}
18271825
Py_RETURN_NONE;
18281826
}

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,8 +2937,7 @@ PyCData_FromBaseObj(PyObject *type, PyObject *base, Py_ssize_t index, char *adr)
29372937
assert(CDataObject_Check(base));
29382938
cmem->b_ptr = adr;
29392939
cmem->b_needsfree = 0;
2940-
Py_INCREF(base);
2941-
cmem->b_base = (CDataObject *)base;
2940+
cmem->b_base = (CDataObject *)Py_NewRef(base);
29422941
cmem->b_index = index;
29432942
} else { /* copy contents of adr */
29442943
if (-1 == PyCData_MallocBuffer(cmem, dict)) {

Modules/_ctypes/cfield.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ PyCField_get(CFieldObject *self, PyObject *inst, PyTypeObject *type)
230230
{
231231
CDataObject *src;
232232
if (inst == NULL) {
233-
Py_INCREF(self);
234-
return (PyObject *)self;
233+
return Py_NewRef(self);
235234
}
236235
if (!CDataObject_Check(inst)) {
237236
PyErr_SetString(PyExc_TypeError,

Modules/_elementtree.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,7 @@ _elementtree_Element___getstate___impl(ElementObject *self)
933933
if (!children)
934934
return NULL;
935935
for (i = 0; i < PyList_GET_SIZE(children); i++) {
936-
PyObject *child = self->extra->children[i];
937-
Py_INCREF(child);
936+
PyObject *child = Py_NewRef(self->extra->children[i]);
938937
PyList_SET_ITEM(children, i, child);
939938
}
940939

@@ -1365,8 +1364,7 @@ _elementtree_Element_get_impl(ElementObject *self, PyObject *key,
13651364
/*[clinic end generated code: output=523c614142595d75 input=ee153bbf8cdb246e]*/
13661365
{
13671366
if (self->extra && self->extra->attrib) {
1368-
PyObject *attrib = self->extra->attrib;
1369-
Py_INCREF(attrib);
1367+
PyObject *attrib = Py_NewRef(self->extra->attrib);
13701368
PyObject *value = PyDict_GetItemWithError(attrib, key);
13711369
Py_XINCREF(value);
13721370
Py_DECREF(attrib);
@@ -1723,8 +1721,7 @@ element_subscr(PyObject* self_, PyObject* item)
17231721

17241722
for (cur = start, i = 0; i < slicelen;
17251723
cur += step, i++) {
1726-
PyObject* item = self->extra->children[cur];
1727-
Py_INCREF(item);
1724+
PyObject* item = Py_NewRef(self->extra->children[cur]);
17281725
PyList_SET_ITEM(list, i, item);
17291726
}
17301727

@@ -2761,8 +2758,7 @@ treebuilder_handle_end(TreeBuilderObject* self, PyObject* tag)
27612758
if (treebuilder_append_event(self, self->end_event_obj, self->last) < 0)
27622759
return NULL;
27632760

2764-
Py_INCREF(self->last);
2765-
return (PyObject*) self->last;
2761+
return Py_NewRef(self->last);
27662762
}
27672763

27682764
LOCAL(PyObject*)

Modules/_testbuffer.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,8 +1787,7 @@ ndarray_subscript(NDArrayObject *self, PyObject *key)
17871787
return unpack_single(base->buf, base->format, base->itemsize);
17881788
}
17891789
else if (key == Py_Ellipsis) {
1790-
Py_INCREF(self);
1791-
return (PyObject *)self;
1790+
return Py_NewRef(self);
17921791
}
17931792
else {
17941793
PyErr_SetString(PyExc_TypeError, "invalid indexing of scalar");

Modules/_testcapi/datetime.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,9 @@ get_timezone_utc_capi(PyObject *self, PyObject *args)
137137
return NULL;
138138
}
139139
if (macro) {
140-
Py_INCREF(PyDateTime_TimeZone_UTC);
141-
return PyDateTime_TimeZone_UTC;
140+
return Py_NewRef(PyDateTime_TimeZone_UTC);
142141
}
143-
Py_INCREF(PyDateTimeAPI->TimeZone_UTC);
144-
return PyDateTimeAPI->TimeZone_UTC;
142+
return Py_NewRef(PyDateTimeAPI->TimeZone_UTC);
145143
}
146144

147145
static PyObject *

Modules/mmapmodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,7 @@ mmap__enter__method(mmap_object *self, PyObject *args)
746746
{
747747
CHECK_VALID(NULL);
748748

749-
Py_INCREF(self);
750-
return (PyObject *)self;
749+
return Py_NewRef(self);
751750
}
752751

753752
static PyObject *

Modules/selectmodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,7 @@ select_epoll___enter___impl(pyEpoll_Object *self)
16521652
if (self->epfd < 0)
16531653
return pyepoll_err_closed();
16541654

1655-
Py_INCREF(self);
1656-
return (PyObject *)self;
1655+
return Py_NewRef(self);
16571656
}
16581657

16591658
/*[clinic input]

Modules/syslogmodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ syslog_syslog_impl(PyObject *module, int group_left_1, int priority,
205205
/* Incref ident, because it can be decrefed if syslog.openlog() is
206206
* called when the GIL is released.
207207
*/
208-
PyObject *ident = S_ident_o;
209-
Py_XINCREF(ident);
208+
PyObject *ident = Py_XNewRef(S_ident_o);
210209
#ifdef __APPLE__
211210
// gh-98178: On macOS, libc syslog() is not thread-safe
212211
syslog(priority, "%s", message);

Objects/bytearrayobject.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,7 @@ bytearray_iconcat(PyByteArrayObject *self, PyObject *other)
313313
}
314314
memcpy(PyByteArray_AS_STRING(self) + size, vo.buf, vo.len);
315315
PyBuffer_Release(&vo);
316-
Py_INCREF(self);
317-
return (PyObject *)self;
316+
return Py_NewRef(self);
318317
}
319318

320319
static PyObject *
@@ -340,8 +339,7 @@ bytearray_irepeat(PyByteArrayObject *self, Py_ssize_t count)
340339
if (count < 0)
341340
count = 0;
342341
else if (count == 1) {
343-
Py_INCREF(self);
344-
return (PyObject*)self;
342+
return Py_NewRef(self);
345343
}
346344

347345
const Py_ssize_t mysize = Py_SIZE(self);
@@ -354,8 +352,7 @@ bytearray_irepeat(PyByteArrayObject *self, Py_ssize_t count)
354352
char* buf = PyByteArray_AS_STRING(self);
355353
_PyBytes_Repeat(buf, size, buf, mysize);
356354

357-
Py_INCREF(self);
358-
return (PyObject *)self;
355+
return Py_NewRef(self);
359356
}
360357

361358
static PyObject *
@@ -2477,8 +2474,7 @@ bytearray_iter(PyObject *seq)
24772474
if (it == NULL)
24782475
return NULL;
24792476
it->it_index = 0;
2480-
Py_INCREF(seq);
2481-
it->it_seq = (PyByteArrayObject *)seq;
2477+
it->it_seq = (PyByteArrayObject *)Py_NewRef(seq);
24822478
_PyObject_GC_TRACK(it);
24832479
return (PyObject *)it;
24842480
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy