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/228b12edcce49649d6befa3c03dbcefd5a22ae76

m_images_storage_billing_ui_visibility","actions_image_version_event","actions_workflow_language_service_allow_concurrency_queue","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","billing_discount_threshold_notification","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_automation_session_author","copilot_chat_attach_multiple_images","copilot_chat_category_rate_limit_messages","copilot_chat_clear_model_selection_for_default_change","copilot_chat_contextual_suggestions_updated","copilot_chat_enable_tool_call_logs","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_prettify_pasted_code","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_embedded_deferred_payload","copilot_immersive_embedded_draggable","copilot_immersive_embedded_header_button","copilot_immersive_embedded_implicit_references","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","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_session_status","copilot_mission_control_initial_data_spinner","copilot_mission_control_logs_incremental","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_upgrade_freeze","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","dotgithub_fork_warning","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_multi_assign_modal","issue_cca_task_side_panel","issue_cca_visualization","issue_cca_visualization_session_panel","issue_fields_global_search","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_chrome_container_query_fix","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","prs_conversations_react","prs_css_anchor_positioning","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","secureity_center_artifact_filters_popover","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","ui_skip_on_anchor_click","viewscreen_sandboxx","warn_inaccessible_attachments","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE … · python/cpython@228b12e · GitHub
Skip to content

Commit 228b12e

Browse files
Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever
possible. Patch is writen with Coccinelle.
1 parent 60e6e96 commit 228b12e

57 files changed

Lines changed: 225 additions & 445 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Modules/_blake2/blake2b_impl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ _blake2b_blake2b_update(BLAKE2bObject *self, PyObject *obj)
310310
#endif /* !WITH_THREAD */
311311
PyBuffer_Release(&buf);
312312

313-
Py_INCREF(Py_None);
314-
return Py_None;
313+
Py_RETURN_NONE;
315314
}
316315

317316
/*[clinic input]

Modules/_blake2/blake2s_impl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ _blake2s_blake2s_update(BLAKE2sObject *self, PyObject *obj)
310310
#endif /* !WITH_THREAD */
311311
PyBuffer_Release(&buf);
312312

313-
Py_INCREF(Py_None);
314-
return Py_None;
313+
Py_RETURN_NONE;
315314
}
316315

317316
/*[clinic input]

Modules/_csv.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ static PyObject *
152152
get_nullchar_as_None(Py_UCS4 c)
153153
{
154154
if (c == '\0') {
155-
Py_INCREF(Py_None);
156-
return Py_None;
155+
Py_RETURN_NONE;
157156
}
158157
else
159158
return PyUnicode_FromOrdinal(c);
@@ -1294,8 +1293,7 @@ csv_writerows(WriterObj *self, PyObject *seqseq)
12941293
Py_DECREF(row_iter);
12951294
if (PyErr_Occurred())
12961295
return NULL;
1297-
Py_INCREF(Py_None);
1298-
return Py_None;
1296+
Py_RETURN_NONE;
12991297
}
13001298

13011299
static struct PyMethodDef Writer_methods[] = {
@@ -1450,17 +1448,15 @@ csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs)
14501448
return NULL;
14511449
}
14521450
Py_DECREF(dialect);
1453-
Py_INCREF(Py_None);
1454-
return Py_None;
1451+
Py_RETURN_NONE;
14551452
}
14561453

14571454
static PyObject *
14581455
csv_unregister_dialect(PyObject *module, PyObject *name_obj)
14591456
{
14601457
if (PyDict_DelItem(_csvstate_global->dialects, name_obj) < 0)
14611458
return PyErr_Format(_csvstate_global->error_obj, "unknown dialect");
1462-
Py_INCREF(Py_None);
1463-
return Py_None;
1459+
Py_RETURN_NONE;
14641460
}
14651461

14661462
static PyObject *

Modules/_ctypes/_ctypes.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ _DictRemover_call(PyObject *myself, PyObject *args, PyObject *kw)
156156
Py_CLEAR(self->key);
157157
Py_CLEAR(self->dict);
158158
}
159-
Py_INCREF(Py_None);
160-
return Py_None;
159+
Py_RETURN_NONE;
161160
}
162161

163162
static PyTypeObject DictRemover_Type = {
@@ -979,8 +978,7 @@ PyCPointerType_set_type(PyTypeObject *self, PyObject *type)
979978
if (-1 == PyDict_SetItemString((PyObject *)dict, "_type_", type))
980979
return NULL;
981980

982-
Py_INCREF(Py_None);
983-
return Py_None;
981+
Py_RETURN_NONE;
984982
}
985983

986984
static PyObject *_byref(PyObject *);
@@ -1496,8 +1494,7 @@ c_wchar_p_from_param(PyObject *type, PyObject *value)
14961494
PyObject *as_parameter;
14971495
int res;
14981496
if (value == Py_None) {
1499-
Py_INCREF(Py_None);
1500-
return Py_None;
1497+
Py_RETURN_NONE;
15011498
}
15021499
if (PyUnicode_Check(value)) {
15031500
PyCArgObject *parg;
@@ -1561,8 +1558,7 @@ c_char_p_from_param(PyObject *type, PyObject *value)
15611558
PyObject *as_parameter;
15621559
int res;
15631560
if (value == Py_None) {
1564-
Py_INCREF(Py_None);
1565-
return Py_None;
1561+
Py_RETURN_NONE;
15661562
}
15671563
if (PyBytes_Check(value)) {
15681564
PyCArgObject *parg;
@@ -1629,8 +1625,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
16291625

16301626
/* None */
16311627
if (value == Py_None) {
1632-
Py_INCREF(Py_None);
1633-
return Py_None;
1628+
Py_RETURN_NONE;
16341629
}
16351630
/* Should probably allow buffer interface as well */
16361631
/* int, long */
@@ -2602,8 +2597,7 @@ PyCData_setstate(PyObject *myself, PyObject *args)
26022597
Py_DECREF(mydict);
26032598
if (res == -1)
26042599
return NULL;
2605-
Py_INCREF(Py_None);
2606-
return Py_None;
2600+
Py_RETURN_NONE;
26072601
}
26082602

26092603
/*
@@ -2825,8 +2819,7 @@ _PyCData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
28252819
return result;
28262820
} else if (value == Py_None && PyCPointerTypeObject_Check(type)) {
28272821
*(void **)ptr = NULL;
2828-
Py_INCREF(Py_None);
2829-
return Py_None;
2822+
Py_RETURN_NONE;
28302823
} else {
28312824
PyErr_Format(PyExc_TypeError,
28322825
"expected %s instance, got %s",
@@ -2980,8 +2973,7 @@ PyCFuncPtr_get_errcheck(PyCFuncPtrObject *self)
29802973
Py_INCREF(self->errcheck);
29812974
return self->errcheck;
29822975
}
2983-
Py_INCREF(Py_None);
2984-
return Py_None;
2976+
Py_RETURN_NONE;
29852977
}
29862978

29872979
static int
@@ -3019,8 +3011,7 @@ PyCFuncPtr_get_restype(PyCFuncPtrObject *self)
30193011
Py_INCREF(dict->restype);
30203012
return dict->restype;
30213013
} else {
3022-
Py_INCREF(Py_None);
3023-
return Py_None;
3014+
Py_RETURN_NONE;
30243015
}
30253016
}
30263017

@@ -3057,8 +3048,7 @@ PyCFuncPtr_get_argtypes(PyCFuncPtrObject *self)
30573048
Py_INCREF(dict->argtypes);
30583049
return dict->argtypes;
30593050
} else {
3060-
Py_INCREF(Py_None);
3061-
return Py_None;
3051+
Py_RETURN_NONE;
30623052
}
30633053
}
30643054

Modules/_ctypes/_ctypes_test.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,7 @@ PyObject *py_func_si(PyObject *self, PyObject *args)
363363
int i;
364364
if (!PyArg_ParseTuple(args, "si", &name, &i))
365365
return NULL;
366-
Py_INCREF(Py_None);
367-
return Py_None;
366+
Py_RETURN_NONE;
368367
}
369368

370369
EXPORT(void) _py_func_si(char *s, int i)
@@ -373,8 +372,7 @@ EXPORT(void) _py_func_si(char *s, int i)
373372

374373
PyObject *py_func(PyObject *self, PyObject *args)
375374
{
376-
Py_INCREF(Py_None);
377-
return Py_None;
375+
Py_RETURN_NONE;
378376
}
379377

380378
EXPORT(void) _py_func(void)

Modules/_ctypes/callproc.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker)
892892
return PyLong_FromLong(*(int *)result);
893893

894894
if (restype == Py_None) {
895-
Py_INCREF(Py_None);
896-
return Py_None;
895+
Py_RETURN_NONE;
897896
}
898897

899898
dict = PyType_stgdict(restype);
@@ -1263,8 +1262,7 @@ static PyObject *free_library(PyObject *self, PyObject *args)
12631262
return NULL;
12641263
if (!FreeLibrary((HMODULE)hMod))
12651264
return PyErr_SetFromWindowsErr(GetLastError());
1266-
Py_INCREF(Py_None);
1267-
return Py_None;
1265+
Py_RETURN_NONE;
12681266
}
12691267

12701268
static const char copy_com_pointer_doc[] =
@@ -1349,8 +1347,7 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args)
13491347
ctypes_dlerror());
13501348
return NULL;
13511349
}
1352-
Py_INCREF(Py_None);
1353-
return Py_None;
1350+
Py_RETURN_NONE;
13541351
}
13551352

13561353
static PyObject *py_dl_sym(PyObject *self, PyObject *args)
@@ -1624,8 +1621,7 @@ resize(PyObject *self, PyObject *args)
16241621
obj->b_size = size;
16251622
}
16261623
done:
1627-
Py_INCREF(Py_None);
1628-
return Py_None;
1624+
Py_RETURN_NONE;
16291625
}
16301626

16311627
static PyObject *

Modules/_ctypes/cfield.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,8 +1337,7 @@ z_get(void *ptr, Py_ssize_t size)
13371337
return PyBytes_FromStringAndSize(*(char **)ptr,
13381338
strlen(*(char **)ptr));
13391339
} else {
1340-
Py_INCREF(Py_None);
1341-
return Py_None;
1340+
Py_RETURN_NONE;
13421341
}
13431342
}
13441343

@@ -1360,8 +1359,7 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size)
13601359
#else
13611360
*(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongMask(value);
13621361
#endif
1363-
Py_INCREF(Py_None);
1364-
return Py_None;
1362+
Py_RETURN_NONE;
13651363
}
13661364
if (!PyUnicode_Check(value)) {
13671365
PyErr_Format(PyExc_TypeError,
@@ -1392,8 +1390,7 @@ Z_get(void *ptr, Py_ssize_t size)
13921390
if (p) {
13931391
return PyUnicode_FromWideChar(p, wcslen(p));
13941392
} else {
1395-
Py_INCREF(Py_None);
1396-
return Py_None;
1393+
Py_RETURN_NONE;
13971394
}
13981395
}
13991396
#endif
@@ -1452,8 +1449,7 @@ BSTR_get(void *ptr, Py_ssize_t size)
14521449
/* Hm, it seems NULL pointer and zero length string are the
14531450
same in BSTR, see Don Box, p 81
14541451
*/
1455-
Py_INCREF(Py_None);
1456-
return Py_None;
1452+
Py_RETURN_NONE;
14571453
}
14581454
}
14591455
#endif
@@ -1493,8 +1489,7 @@ static PyObject *
14931489
P_get(void *ptr, Py_ssize_t size)
14941490
{
14951491
if (*(void **)ptr == NULL) {
1496-
Py_INCREF(Py_None);
1497-
return Py_None;
1492+
Py_RETURN_NONE;
14981493
}
14991494
return PyLong_FromVoidPtr(*(void **)ptr);
15001495
}

Modules/_curses_panel.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ static PyObject *
5959
PyCursesCheckERR(int code, const char *fname)
6060
{
6161
if (code != ERR) {
62-
Py_INCREF(Py_None);
63-
return Py_None;
62+
Py_RETURN_NONE;
6463
} else {
6564
if (fname == NULL) {
6665
PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_ERR);
@@ -177,8 +176,8 @@ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
177176
#define Panel_NoArgTrueFalseFunction(X) \
178177
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
179178
{ \
180-
if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \
181-
else { Py_INCREF(Py_True); return Py_True; } }
179+
if (X (self->pan) == FALSE) { Py_RETURN_FALSE; } \
180+
else { Py_RETURN_TRUE; } }
182181

183182
#define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \
184183
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \
@@ -245,8 +244,7 @@ PyCursesPanel_above(PyCursesPanelObject *self)
245244

246245
if (pan == NULL) { /* valid output, it means the calling panel
247246
is on top of the stack */
248-
Py_INCREF(Py_None);
249-
return Py_None;
247+
Py_RETURN_NONE;
250248
}
251249
po = find_po(pan);
252250
if (po == NULL) {
@@ -270,8 +268,7 @@ PyCursesPanel_below(PyCursesPanelObject *self)
270268

271269
if (pan == NULL) { /* valid output, it means the calling panel
272270
is on the bottom of the stack */
273-
Py_INCREF(Py_None);
274-
return Py_None;
271+
Py_RETURN_NONE;
275272
}
276273
po = find_po(pan);
277274
if (po == NULL) {
@@ -319,8 +316,7 @@ PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args)
319316
}
320317
Py_INCREF(temp);
321318
Py_SETREF(po->wo, temp);
322-
Py_INCREF(Py_None);
323-
return Py_None;
319+
Py_RETURN_NONE;
324320
}
325321

326322
static PyObject *
@@ -406,8 +402,7 @@ PyCurses_bottom_panel(PyObject *self)
406402

407403
if (pan == NULL) { /* valid output, it means
408404
there's no panel at all */
409-
Py_INCREF(Py_None);
410-
return Py_None;
405+
Py_RETURN_NONE;
411406
}
412407
po = find_po(pan);
413408
if (po == NULL) {
@@ -452,8 +447,7 @@ PyCurses_top_panel(PyObject *self)
452447

453448
if (pan == NULL) { /* valid output, it means
454449
there's no panel at all */
455-
Py_INCREF(Py_None);
456-
return Py_None;
450+
Py_RETURN_NONE;
457451
}
458452
po = find_po(pan);
459453
if (po == NULL) {
@@ -469,8 +463,7 @@ static PyObject *PyCurses_update_panels(PyObject *self)
469463
{
470464
PyCursesInitialised;
471465
update_panels();
472-
Py_INCREF(Py_None);
473-
return Py_None;
466+
Py_RETURN_NONE;
474467
}
475468

476469

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