Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82c0dfa

Browse files
committed
Return PyString, not PyBytes, for a bytes array.
Clean up trailing whitespace.
1 parent b0efee2 commit 82c0dfa

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

Modules/_tkinter.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ Copyright (C) 1994 Steen Lumholt.
8383
/* Unicode conversion assumes that Tcl_UniChar is two bytes.
8484
We cannot test this directly, so we test UTF-8 size instead,
8585
expecting that TCL_UTF_MAX is changed if Tcl ever supports
86-
either UTF-16 or UCS-4.
87-
Redhat 8 sets TCL_UTF_MAX to 6, and uses wchar_t for
86+
either UTF-16 or UCS-4.
87+
Redhat 8 sets TCL_UTF_MAX to 6, and uses wchar_t for
8888
Tcl_Unichar. This is also ok as long as Python uses UCS-4,
8989
as well.
9090
*/
@@ -749,7 +749,7 @@ PyTclObject_TclString(PyObject *self)
749749
}
750750

751751
/* Like _str, but create Unicode if necessary. */
752-
PyDoc_STRVAR(PyTclObject_string__doc__,
752+
PyDoc_STRVAR(PyTclObject_string__doc__,
753753
"the string representation of this object, either as str8 or str");
754754

755755
static PyObject *
@@ -810,7 +810,7 @@ get_typename(PyTclObject* obj, void* ignored)
810810

811811
static PyGetSetDef PyTclObject_getsetlist[] = {
812812
{"typename", (getter)get_typename, NULL, get_typename__doc__},
813-
{"string", (getter)PyTclObject_string, NULL,
813+
{"string", (getter)PyTclObject_string, NULL,
814814
PyTclObject_string__doc__},
815815
{0},
816816
};
@@ -921,7 +921,7 @@ AsObj(PyObject *value)
921921
Tcl_Obj *v = ((PyTclObject*)value)->value;
922922
Tcl_IncrRefCount(v);
923923
return v;
924-
}
924+
}
925925
else {
926926
PyObject *v = PyObject_Str(value);
927927
if (!v)
@@ -939,7 +939,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
939939
TkappObject *app = (TkappObject*)tkapp;
940940

941941
if (value->typePtr == NULL) {
942-
return PyUnicode_FromStringAndSize(value->bytes,
942+
return PyUnicode_FromStringAndSize(value->bytes,
943943
value->length);
944944
}
945945

@@ -952,7 +952,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
952952
if (value->typePtr == app->ByteArrayType) {
953953
int size;
954954
char *data = (char*)Tcl_GetByteArrayFromObj(value, &size);
955-
return PyBytes_FromStringAndSize(data, size);
955+
return PyString_FromStringAndSize(data, size);
956956
}
957957

958958
if (value->typePtr == app->DoubleType) {
@@ -1219,7 +1219,7 @@ Tkapp_Call(PyObject *selfptr, PyObject *args)
12191219
PyErr_SetObject(Tkinter_TclError, exc_value);
12201220
}
12211221
}
1222-
else
1222+
else
12231223
#endif
12241224
{
12251225

@@ -1424,7 +1424,7 @@ varname_converter(PyObject *in, void *_out)
14241424
}
14251425
/* XXX: Should give diagnostics. */
14261426
return 0;
1427-
}
1427+
}
14281428

14291429
void
14301430
var_perform(VarEvent *ev)
@@ -1438,7 +1438,7 @@ var_perform(VarEvent *ev)
14381438
*(ev->exc_val) = val;
14391439
Py_DECREF(tb);
14401440
}
1441-
1441+
14421442
}
14431443

14441444
static int
@@ -1462,7 +1462,7 @@ var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
14621462
TkappObject *self = (TkappObject*)selfptr;
14631463
VarEvent *ev;
14641464
PyObject *res, *exc_type, *exc_val;
1465-
1465+
14661466
/* The current thread is not the interpreter thread. Marshal
14671467
the call to the interpreter thread, then wait for
14681468
completion. */
@@ -1502,14 +1502,14 @@ SetVar(PyObject *self, PyObject *args, int flags)
15021502
PyObject *res = NULL;
15031503
Tcl_Obj *newval, *ok;
15041504

1505-
if (PyArg_ParseTuple(args, "O&O:setvar",
1505+
if (PyArg_ParseTuple(args, "O&O:setvar",
15061506
varname_converter, &name1, &newValue)) {
15071507
/* XXX Acquire tcl lock??? */
15081508
newval = AsObj(newValue);
15091509
if (newval == NULL)
15101510
return NULL;
15111511
ENTER_TCL
1512-
ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, NULL,
1512+
ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, NULL,
15131513
newval, flags);
15141514
ENTER_OVERLAP
15151515
if (!ok)
@@ -1565,7 +1565,7 @@ GetVar(PyObject *self, PyObject *args, int flags)
15651565
PyObject *res = NULL;
15661566
Tcl_Obj *tres;
15671567

1568-
if (!PyArg_ParseTuple(args, "O&|s:getvar",
1568+
if (!PyArg_ParseTuple(args, "O&|s:getvar",
15691569
varname_converter, &name1, &name2))
15701570
return NULL;
15711571

@@ -1708,7 +1708,7 @@ Tkapp_ExprString(PyObject *self, PyObject *args)
17081708

17091709
if (!PyArg_ParseTuple(args, "s:exprstring", &s))
17101710
return NULL;
1711-
1711+
17121712
CHECK_TCL_APPARTMENT;
17131713

17141714
ENTER_TCL
@@ -1813,7 +1813,7 @@ Tkapp_SplitList(PyObject *self, PyObject *args)
18131813
if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list))
18141814
return NULL;
18151815

1816-
if (Tcl_SplitList(Tkapp_Interp(self), list,
1816+
if (Tcl_SplitList(Tkapp_Interp(self), list,
18171817
&argc, &argv) == TCL_ERROR) {
18181818
PyMem_Free(list);
18191819
return Tkinter_Error(self);
@@ -2020,7 +2020,7 @@ Tkapp_CreateCommand(PyObject *selfptr, PyObject *args)
20202020
Py_INCREF(func);
20212021
data->self = selfptr;
20222022
data->func = func;
2023-
2023+
20242024
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
20252025
CommandEvent *ev = (CommandEvent*)ckalloc(sizeof(CommandEvent));
20262026
ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
@@ -2069,7 +2069,7 @@ Tkapp_DeleteCommand(PyObject *selfptr, PyObject *args)
20692069
ev->name = cmdName;
20702070
ev->status = &err;
20712071
ev->done = NULL;
2072-
Tkapp_ThreadSend(self, (Tcl_Event*)ev, &ev->done,
2072+
Tkapp_ThreadSend(self, (Tcl_Event*)ev, &ev->done,
20732073
&command_mutex);
20742074
}
20752075
else {
@@ -2282,7 +2282,7 @@ static TkttObject *
22822282
Tktt_New(PyObject *func)
22832283
{
22842284
TkttObject *v;
2285-
2285+
22862286
v = PyObject_New(TkttObject, &Tktt_Type);
22872287
if (v == NULL)
22882288
return NULL;
@@ -2545,11 +2545,11 @@ Tkapp_TkInit(PyObject *self, PyObject *args)
25452545
To avoid the deadlock, we just refuse the second call through
25462546
a static variable. */
25472547
if (has_failed) {
2548-
PyErr_SetString(Tkinter_TclError,
2548+
PyErr_SetString(Tkinter_TclError,
25492549
"Calling Tk_Init again after a previous call failed might deadlock");
25502550
return NULL;
25512551
}
2552-
2552+
25532553
/* We want to guard against calling Tk_Init() multiple times */
25542554
CHECK_TCL_APPARTMENT;
25552555
ENTER_TCL
@@ -2783,11 +2783,11 @@ Tkinter_Flatten(PyObject* self, PyObject* args)
27832783
context.maxsize = PySequence_Size(item);
27842784
if (context.maxsize <= 0)
27852785
return PyTuple_New(0);
2786-
2786+
27872787
context.tuple = PyTuple_New(context.maxsize);
27882788
if (!context.tuple)
27892789
return NULL;
2790-
2790+
27912791
context.size = 0;
27922792

27932793
if (!_flatten1(&context, item,0))
@@ -2817,14 +2817,14 @@ Tkinter_Create(PyObject *self, PyObject *args)
28172817
else
28182818
baseName = Py_GetProgramName();
28192819
className = "Tk";
2820-
2820+
28212821
if (!PyArg_ParseTuple(args, "|zssiiiiz:create",
28222822
&screenName, &baseName, &className,
28232823
&interactive, &wantobjects, &wantTk,
28242824
&sync, &use))
28252825
return NULL;
28262826

2827-
return (PyObject *) Tkapp_New(screenName, baseName, className,
2827+
return (PyObject *) Tkapp_New(screenName, baseName, className,
28282828
interactive, wantobjects, wantTk,
28292829
sync, use);
28302830
}

0 commit comments

Comments
 (0)