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.

Author ammar2
Recipients ammar2, mark.dickinson, seberg, serhiy.storchaka, tcaswell, terry.reedy, vstinner
Date 2019-08-30.03:26:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1567135613.82.0.617341735882.issue37980@roundup.psfhosted.org>
In-reply-to
Content
Thanks for the insight Terry.

I think the functions that accept ints as bools are kind of a red herring: Booleans were only formally introduced in Python 2.3 [1], thus any functions that existed before that accepted ints and continued to accept ints for backwards compatibility [2]. When transition to argument clinic, these functions use "bool(accept={int})" which restricts the inputs to either bools or ints [3]. 

print, int.to_bytes and int.from_bytes all use argument clinic's bool converter which accepts any truth-y objects. This is similar to PyArg_ParseTuple's 'p' parameter which also accepts any truthy objects as well as say the print function which manually does a PyObject_IsTrue [4].


[1] https://www.python.org/download/releases/2.3/highlights/

[2] list.sort (sorted) existed since the start of Python: https://github.com/python/cpython/blob/85a5fbbdfea617f6cc8fae82c9e8c2b5c424436d/Objects/listobject.c#L423

splitlines exists in Python 2.0: https://github.com/python/cpython/commit/4c08d554b9009899780a5e003d6bbeb5413906ee

[3] https://docs.python.org/3/howto/clinic.html#using-real-argument-clinic-converters-instead-of-legacy-converters

[4] https://github.com/python/cpython/blob/7fcc2088a50a4ecb80e5644cd195bee209c9f979/Python/bltinmodule.c#L1888
History
Date User Action Args
2019-08-30 03:26:53ammar2setrecipients: + ammar2, terry.reedy, mark.dickinson, vstinner, serhiy.storchaka, seberg, tcaswell
2019-08-30 03:26:53ammar2setmessageid: <1567135613.82.0.617341735882.issue37980@roundup.psfhosted.org>
2019-08-30 03:26:53ammar2linkissue37980 messages
2019-08-30 03:26:53ammar2create