This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Using new 'bool' format character
Type: enhancement Stage: patch review
Components: Extension Modules, Interpreter Core Versions: Python 3.4
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Rosuav, larry, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2012-09-21 15:47 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
use_bool_parsing.diff serhiy.storchaka, 2012-09-21 15:47 review
bool_cleanup.patch serhiy.storchaka, 2015-10-18 16:22 review
accept_bool.patch serhiy.storchaka, 2015-10-18 16:22 review
Pull Requests
URL Status Linked Edit
PR 15609 open serhiy.storchaka, 2019-08-30 07:55
PR 15610 merged serhiy.storchaka, 2019-08-30 08:05
PR 15621 merged serhiy.storchaka, 2019-08-30 21:03
PR 15622 merged serhiy.storchaka, 2019-08-30 21:04
Messages (7)
msg170897 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-09-21 15:47
Issue14705 added 'bool' format character to PyArg_ParseTuple for using it for parsing multiple boolean arguments in os module. The proposed patch uses this format character for other boolean arguments. This makes the sources simpler, clearer and more reliable, improves error messages, gets rid of a few rare errors.
msg170898 - (view) Author: Larry Hastings (larry) * (Python committer) Date: 2012-09-21 15:59
Patch looks fine in principle, though I'd want someone to go over the individual cases to make sure they make sense.

Also, I have something up my sleeve regarding argument parsing for 3.4, and if it gets accepted we might be touching all this code anyway.  I mention this just to say--you may want to hold off on more patches like this for now.
msg252765 - (view) Author: Chris Angelico (Rosuav) * Date: 2015-10-11 05:38
Has this been entirely superseded by Argument Clinic?
msg253154 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-10-18 16:22
No, it is orthogonal to Argument Clinic. Usually converting to Argument Clinic didn't change semantic. However these changes conflicted with proposed patch.

Rebased patch is splitted on two patches.

bool_cleanup.patch. It almost doesn't change the behavior. It uses the "p" format unit instead of manually called PyObject_IsTrue(), passes boolean value instead 0/1 integers to functions that needs boolean, and made some arguments ("flush" in print(), "strict", "sort_keys" and "skipkeys" in json module) to be converted to boolean only once.

accept_bool.patch. It makes a number of functions to accept arbitrary objects in boolean context, not just False/True and ints representable as C int. But I prefer first to commit the patch for issue24037.
msg350940 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-09-01 09:11
New changeset eb8974616bc58f44b2a3c3e4ca2326894ae42c8f by Serhiy Storchaka in branch 'master':
bpo-15999: Always pass bool instead of int to the expat parser. (GH-15622)
https://github.com/python/cpython/commit/eb8974616bc58f44b2a3c3e4ca2326894ae42c8f
msg350941 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-09-01 09:12
New changeset 5eca7f3f3836cc734dfe8dc5ec669f3b4e9333fe by Serhiy Storchaka in branch 'master':
bpo-15999: Always pass bool instead of int to socket.setblocking(). (GH-15621)
https://github.com/python/cpython/commit/5eca7f3f3836cc734dfe8dc5ec669f3b4e9333fe
msg350942 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-09-01 09:16
New changeset 1f21eaa15e8a0d2b0f78d0e3f2b9e5b458eb0a70 by Serhiy Storchaka in branch 'master':
bpo-15999: Clean up of handling boolean arguments. (GH-15610)
https://github.com/python/cpython/commit/1f21eaa15e8a0d2b0f78d0e3f2b9e5b458eb0a70
History
Date User Action Args
2022-04-11 14:57:36adminsetgithub: 60203
2019-09-01 09:16:53serhiy.storchakasetmessages: + msg350942
2019-09-01 09:12:54serhiy.storchakasetmessages: + msg350941
2019-09-01 09:11:46serhiy.storchakasetmessages: + msg350940
2019-08-30 21:04:15serhiy.storchakasetpull_requests: + pull_request15290
2019-08-30 21:03:11serhiy.storchakasetpull_requests: + pull_request15289
2019-08-30 08:05:50serhiy.storchakasetpull_requests: + pull_request15284
2019-08-30 07:55:27serhiy.storchakasetpull_requests: + pull_request15283
2015-10-18 16:22:33serhiy.storchakasetfiles: + accept_bool.patch
2015-10-18 16:22:14serhiy.storchakasetfiles: + bool_cleanup.patch

messages: + msg253154
2015-10-11 05:38:43Rosuavsetnosy: + Rosuav
messages: + msg252765
2012-12-29 22:17:44serhiy.storchakasetassignee: serhiy.storchaka
2012-10-24 09:38:56serhiy.storchakasetstage: patch review
2012-09-21 15:59:35larrysetmessages: + msg170898
2012-09-21 15:47:09serhiy.storchakacreate