mirror of
https://github.com/python/cpython.git
synced 2025-11-28 22:18:54 +00:00
Return PyString, not PyBytes, for a bytes array.
Clean up trailing whitespace.
This commit is contained in:
parent
b0efee2669
commit
82c0dfa3bd
1 changed files with 25 additions and 25 deletions
|
|
@ -83,8 +83,8 @@ Copyright (C) 1994 Steen Lumholt.
|
||||||
/* Unicode conversion assumes that Tcl_UniChar is two bytes.
|
/* Unicode conversion assumes that Tcl_UniChar is two bytes.
|
||||||
We cannot test this directly, so we test UTF-8 size instead,
|
We cannot test this directly, so we test UTF-8 size instead,
|
||||||
expecting that TCL_UTF_MAX is changed if Tcl ever supports
|
expecting that TCL_UTF_MAX is changed if Tcl ever supports
|
||||||
either UTF-16 or UCS-4.
|
either UTF-16 or UCS-4.
|
||||||
Redhat 8 sets TCL_UTF_MAX to 6, and uses wchar_t for
|
Redhat 8 sets TCL_UTF_MAX to 6, and uses wchar_t for
|
||||||
Tcl_Unichar. This is also ok as long as Python uses UCS-4,
|
Tcl_Unichar. This is also ok as long as Python uses UCS-4,
|
||||||
as well.
|
as well.
|
||||||
*/
|
*/
|
||||||
|
|
@ -749,7 +749,7 @@ PyTclObject_TclString(PyObject *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Like _str, but create Unicode if necessary. */
|
/* Like _str, but create Unicode if necessary. */
|
||||||
PyDoc_STRVAR(PyTclObject_string__doc__,
|
PyDoc_STRVAR(PyTclObject_string__doc__,
|
||||||
"the string representation of this object, either as str8 or str");
|
"the string representation of this object, either as str8 or str");
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
@ -810,7 +810,7 @@ get_typename(PyTclObject* obj, void* ignored)
|
||||||
|
|
||||||
static PyGetSetDef PyTclObject_getsetlist[] = {
|
static PyGetSetDef PyTclObject_getsetlist[] = {
|
||||||
{"typename", (getter)get_typename, NULL, get_typename__doc__},
|
{"typename", (getter)get_typename, NULL, get_typename__doc__},
|
||||||
{"string", (getter)PyTclObject_string, NULL,
|
{"string", (getter)PyTclObject_string, NULL,
|
||||||
PyTclObject_string__doc__},
|
PyTclObject_string__doc__},
|
||||||
{0},
|
{0},
|
||||||
};
|
};
|
||||||
|
|
@ -921,7 +921,7 @@ AsObj(PyObject *value)
|
||||||
Tcl_Obj *v = ((PyTclObject*)value)->value;
|
Tcl_Obj *v = ((PyTclObject*)value)->value;
|
||||||
Tcl_IncrRefCount(v);
|
Tcl_IncrRefCount(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyObject *v = PyObject_Str(value);
|
PyObject *v = PyObject_Str(value);
|
||||||
if (!v)
|
if (!v)
|
||||||
|
|
@ -939,7 +939,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||||
TkappObject *app = (TkappObject*)tkapp;
|
TkappObject *app = (TkappObject*)tkapp;
|
||||||
|
|
||||||
if (value->typePtr == NULL) {
|
if (value->typePtr == NULL) {
|
||||||
return PyUnicode_FromStringAndSize(value->bytes,
|
return PyUnicode_FromStringAndSize(value->bytes,
|
||||||
value->length);
|
value->length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -952,7 +952,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
|
||||||
if (value->typePtr == app->ByteArrayType) {
|
if (value->typePtr == app->ByteArrayType) {
|
||||||
int size;
|
int size;
|
||||||
char *data = (char*)Tcl_GetByteArrayFromObj(value, &size);
|
char *data = (char*)Tcl_GetByteArrayFromObj(value, &size);
|
||||||
return PyBytes_FromStringAndSize(data, size);
|
return PyString_FromStringAndSize(data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value->typePtr == app->DoubleType) {
|
if (value->typePtr == app->DoubleType) {
|
||||||
|
|
@ -1219,7 +1219,7 @@ Tkapp_Call(PyObject *selfptr, PyObject *args)
|
||||||
PyErr_SetObject(Tkinter_TclError, exc_value);
|
PyErr_SetObject(Tkinter_TclError, exc_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -1424,7 +1424,7 @@ varname_converter(PyObject *in, void *_out)
|
||||||
}
|
}
|
||||||
/* XXX: Should give diagnostics. */
|
/* XXX: Should give diagnostics. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
var_perform(VarEvent *ev)
|
var_perform(VarEvent *ev)
|
||||||
|
|
@ -1438,7 +1438,7 @@ var_perform(VarEvent *ev)
|
||||||
*(ev->exc_val) = val;
|
*(ev->exc_val) = val;
|
||||||
Py_DECREF(tb);
|
Py_DECREF(tb);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -1462,7 +1462,7 @@ var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
|
||||||
TkappObject *self = (TkappObject*)selfptr;
|
TkappObject *self = (TkappObject*)selfptr;
|
||||||
VarEvent *ev;
|
VarEvent *ev;
|
||||||
PyObject *res, *exc_type, *exc_val;
|
PyObject *res, *exc_type, *exc_val;
|
||||||
|
|
||||||
/* The current thread is not the interpreter thread. Marshal
|
/* The current thread is not the interpreter thread. Marshal
|
||||||
the call to the interpreter thread, then wait for
|
the call to the interpreter thread, then wait for
|
||||||
completion. */
|
completion. */
|
||||||
|
|
@ -1502,14 +1502,14 @@ SetVar(PyObject *self, PyObject *args, int flags)
|
||||||
PyObject *res = NULL;
|
PyObject *res = NULL;
|
||||||
Tcl_Obj *newval, *ok;
|
Tcl_Obj *newval, *ok;
|
||||||
|
|
||||||
if (PyArg_ParseTuple(args, "O&O:setvar",
|
if (PyArg_ParseTuple(args, "O&O:setvar",
|
||||||
varname_converter, &name1, &newValue)) {
|
varname_converter, &name1, &newValue)) {
|
||||||
/* XXX Acquire tcl lock??? */
|
/* XXX Acquire tcl lock??? */
|
||||||
newval = AsObj(newValue);
|
newval = AsObj(newValue);
|
||||||
if (newval == NULL)
|
if (newval == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
ENTER_TCL
|
ENTER_TCL
|
||||||
ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, NULL,
|
ok = Tcl_SetVar2Ex(Tkapp_Interp(self), name1, NULL,
|
||||||
newval, flags);
|
newval, flags);
|
||||||
ENTER_OVERLAP
|
ENTER_OVERLAP
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
|
@ -1565,7 +1565,7 @@ GetVar(PyObject *self, PyObject *args, int flags)
|
||||||
PyObject *res = NULL;
|
PyObject *res = NULL;
|
||||||
Tcl_Obj *tres;
|
Tcl_Obj *tres;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O&|s:getvar",
|
if (!PyArg_ParseTuple(args, "O&|s:getvar",
|
||||||
varname_converter, &name1, &name2))
|
varname_converter, &name1, &name2))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -1708,7 +1708,7 @@ Tkapp_ExprString(PyObject *self, PyObject *args)
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s:exprstring", &s))
|
if (!PyArg_ParseTuple(args, "s:exprstring", &s))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
CHECK_TCL_APPARTMENT;
|
CHECK_TCL_APPARTMENT;
|
||||||
|
|
||||||
ENTER_TCL
|
ENTER_TCL
|
||||||
|
|
@ -1813,7 +1813,7 @@ Tkapp_SplitList(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list))
|
if (!PyArg_ParseTuple(args, "et:splitlist", "utf-8", &list))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (Tcl_SplitList(Tkapp_Interp(self), list,
|
if (Tcl_SplitList(Tkapp_Interp(self), list,
|
||||||
&argc, &argv) == TCL_ERROR) {
|
&argc, &argv) == TCL_ERROR) {
|
||||||
PyMem_Free(list);
|
PyMem_Free(list);
|
||||||
return Tkinter_Error(self);
|
return Tkinter_Error(self);
|
||||||
|
|
@ -2020,7 +2020,7 @@ Tkapp_CreateCommand(PyObject *selfptr, PyObject *args)
|
||||||
Py_INCREF(func);
|
Py_INCREF(func);
|
||||||
data->self = selfptr;
|
data->self = selfptr;
|
||||||
data->func = func;
|
data->func = func;
|
||||||
|
|
||||||
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
|
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
|
||||||
CommandEvent *ev = (CommandEvent*)ckalloc(sizeof(CommandEvent));
|
CommandEvent *ev = (CommandEvent*)ckalloc(sizeof(CommandEvent));
|
||||||
ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
|
ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
|
||||||
|
|
@ -2069,7 +2069,7 @@ Tkapp_DeleteCommand(PyObject *selfptr, PyObject *args)
|
||||||
ev->name = cmdName;
|
ev->name = cmdName;
|
||||||
ev->status = &err;
|
ev->status = &err;
|
||||||
ev->done = NULL;
|
ev->done = NULL;
|
||||||
Tkapp_ThreadSend(self, (Tcl_Event*)ev, &ev->done,
|
Tkapp_ThreadSend(self, (Tcl_Event*)ev, &ev->done,
|
||||||
&command_mutex);
|
&command_mutex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -2282,7 +2282,7 @@ static TkttObject *
|
||||||
Tktt_New(PyObject *func)
|
Tktt_New(PyObject *func)
|
||||||
{
|
{
|
||||||
TkttObject *v;
|
TkttObject *v;
|
||||||
|
|
||||||
v = PyObject_New(TkttObject, &Tktt_Type);
|
v = PyObject_New(TkttObject, &Tktt_Type);
|
||||||
if (v == NULL)
|
if (v == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -2545,11 +2545,11 @@ Tkapp_TkInit(PyObject *self, PyObject *args)
|
||||||
To avoid the deadlock, we just refuse the second call through
|
To avoid the deadlock, we just refuse the second call through
|
||||||
a static variable. */
|
a static variable. */
|
||||||
if (has_failed) {
|
if (has_failed) {
|
||||||
PyErr_SetString(Tkinter_TclError,
|
PyErr_SetString(Tkinter_TclError,
|
||||||
"Calling Tk_Init again after a previous call failed might deadlock");
|
"Calling Tk_Init again after a previous call failed might deadlock");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We want to guard against calling Tk_Init() multiple times */
|
/* We want to guard against calling Tk_Init() multiple times */
|
||||||
CHECK_TCL_APPARTMENT;
|
CHECK_TCL_APPARTMENT;
|
||||||
ENTER_TCL
|
ENTER_TCL
|
||||||
|
|
@ -2783,11 +2783,11 @@ Tkinter_Flatten(PyObject* self, PyObject* args)
|
||||||
context.maxsize = PySequence_Size(item);
|
context.maxsize = PySequence_Size(item);
|
||||||
if (context.maxsize <= 0)
|
if (context.maxsize <= 0)
|
||||||
return PyTuple_New(0);
|
return PyTuple_New(0);
|
||||||
|
|
||||||
context.tuple = PyTuple_New(context.maxsize);
|
context.tuple = PyTuple_New(context.maxsize);
|
||||||
if (!context.tuple)
|
if (!context.tuple)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
context.size = 0;
|
context.size = 0;
|
||||||
|
|
||||||
if (!_flatten1(&context, item,0))
|
if (!_flatten1(&context, item,0))
|
||||||
|
|
@ -2817,14 +2817,14 @@ Tkinter_Create(PyObject *self, PyObject *args)
|
||||||
else
|
else
|
||||||
baseName = Py_GetProgramName();
|
baseName = Py_GetProgramName();
|
||||||
className = "Tk";
|
className = "Tk";
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|zssiiiiz:create",
|
if (!PyArg_ParseTuple(args, "|zssiiiiz:create",
|
||||||
&screenName, &baseName, &className,
|
&screenName, &baseName, &className,
|
||||||
&interactive, &wantobjects, &wantTk,
|
&interactive, &wantobjects, &wantTk,
|
||||||
&sync, &use))
|
&sync, &use))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (PyObject *) Tkapp_New(screenName, baseName, className,
|
return (PyObject *) Tkapp_New(screenName, baseName, className,
|
||||||
interactive, wantobjects, wantTk,
|
interactive, wantobjects, wantTk,
|
||||||
sync, use);
|
sync, use);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue