bpo-15999: Accept arbitrary values for boolean parameters. (#15609)

builtins and extension module functions and methods that expect boolean values for parameters now accept any Python object rather than just a bool or int type. This is more consistent with how native Python code itself behaves.
This commit is contained in:
Serhiy Storchaka 2022-12-03 21:52:21 +02:00 committed by GitHub
parent c68573b339
commit a87c46eab3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 297 additions and 302 deletions

View file

@ -2832,7 +2832,7 @@ Tkapp_WantObjects(PyObject *self, PyObject *args)
{
int wantobjects = -1;
if (!PyArg_ParseTuple(args, "|i:wantobjects", &wantobjects))
if (!PyArg_ParseTuple(args, "|p:wantobjects", &wantobjects))
return NULL;
if (wantobjects == -1)
return PyBool_FromLong(((TkappObject*)self)->wantobjects);
@ -2978,11 +2978,11 @@ _tkinter.create
screenName: str(accept={str, NoneType}) = None
baseName: str = ""
className: str = "Tk"
interactive: bool(accept={int}) = False
wantobjects: bool(accept={int}) = False
wantTk: bool(accept={int}) = True
interactive: bool = False
wantobjects: bool = False
wantTk: bool = True
if false, then Tk_Init() doesn't get called
sync: bool(accept={int}) = False
sync: bool = False
if true, then pass -sync to wish
use: str(accept={str, NoneType}) = None
if not None, then pass -use to wish
@ -2995,7 +2995,7 @@ _tkinter_create_impl(PyObject *module, const char *screenName,
const char *baseName, const char *className,
int interactive, int wantobjects, int wantTk, int sync,
const char *use)
/*[clinic end generated code: output=e3315607648e6bb4 input=da9b17ee7358d862]*/
/*[clinic end generated code: output=e3315607648e6bb4 input=09afef9adea70a19]*/
{
/* XXX baseName is not used anymore;
* try getting rid of it. */