Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ce6ebc42
Commit
ce6ebc42
authored
Aug 13, 2007
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create Unicode objects.
parent
c9f35719
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
69 deletions
+20
-69
Modules/_tkinter.c
Modules/_tkinter.c
+20
-69
No files found.
Modules/_tkinter.c
View file @
ce6ebc42
...
...
@@ -460,13 +460,13 @@ Split(char *list)
* Could be a quoted string containing funnies, e.g. {"}.
* Return the string itself.
*/
return
Py
String
_FromString
(
list
);
return
Py
Unicode
_FromString
(
list
);
}
if
(
argc
==
0
)
v
=
Py
String
_FromString
(
""
);
v
=
Py
Unicode
_FromString
(
""
);
else
if
(
argc
==
1
)
v
=
Py
String
_FromString
(
argv
[
0
]);
v
=
Py
Unicode
_FromString
(
argv
[
0
]);
else
if
((
v
=
PyTuple_New
(
argc
))
!=
NULL
)
{
int
i
;
PyObject
*
w
;
...
...
@@ -756,22 +756,10 @@ static PyObject *
PyTclObject_string
(
PyTclObject
*
self
,
void
*
ignored
)
{
char
*
s
;
int
i
,
len
;
int
len
;
if
(
!
self
->
string
)
{
s
=
Tcl_GetStringFromObj
(
self
->
value
,
&
len
);
for
(
i
=
0
;
i
<
len
;
i
++
)
if
(
s
[
i
]
&
0x80
)
break
;
if
(
i
==
len
)
/* It is an ASCII string. */
self
->
string
=
PyString_FromStringAndSize
(
s
,
len
);
else
{
self
->
string
=
PyUnicode_DecodeUTF8
(
s
,
len
,
"strict"
);
if
(
!
self
->
string
)
{
PyErr_Clear
();
self
->
string
=
PyString_FromStringAndSize
(
s
,
len
);
}
}
self
->
string
=
PyUnicode_FromStringAndSize
(
s
,
len
);
if
(
!
self
->
string
)
return
NULL
;
}
...
...
@@ -816,7 +804,7 @@ PyDoc_STRVAR(get_typename__doc__, "name of the Tcl type");
static
PyObject
*
get_typename
(
PyTclObject
*
obj
,
void
*
ignored
)
{
return
Py
String
_FromString
(
obj
->
value
->
typePtr
->
name
);
return
Py
Unicode
_FromString
(
obj
->
value
->
typePtr
->
name
);
}
...
...
@@ -951,27 +939,8 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
TkappObject
*
app
=
(
TkappObject
*
)
tkapp
;
if
(
value
->
typePtr
==
NULL
)
{
/* If the result contains any bytes with the top bit set,
it's UTF-8 and we should decode it to Unicode */
int
i
;
char
*
s
=
value
->
bytes
;
int
len
=
value
->
length
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
value
->
bytes
[
i
]
&
0x80
)
break
;
}
if
(
i
==
value
->
length
)
result
=
PyString_FromStringAndSize
(
s
,
len
);
else
{
/* Convert UTF-8 to Unicode string */
result
=
PyUnicode_DecodeUTF8
(
s
,
len
,
"strict"
);
if
(
result
==
NULL
)
{
PyErr_Clear
();
result
=
PyString_FromStringAndSize
(
s
,
len
);
}
}
return
result
;
return
PyUnicode_FromStringAndSize
(
value
->
bytes
,
value
->
length
);
}
if
(
value
->
typePtr
==
app
->
BooleanType
)
{
...
...
@@ -983,7 +952,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
if
(
value
->
typePtr
==
app
->
ByteArrayType
)
{
int
size
;
char
*
data
=
(
char
*
)
Tcl_GetByteArrayFromObj
(
value
,
&
size
);
return
Py
String
_FromStringAndSize
(
data
,
size
);
return
Py
Bytes
_FromStringAndSize
(
data
,
size
);
}
if
(
value
->
typePtr
==
app
->
DoubleType
)
{
...
...
@@ -1147,25 +1116,7 @@ Tkapp_CallResult(TkappObject *self)
const
char
*
s
=
Tcl_GetStringResult
(
self
->
interp
);
const
char
*
p
=
s
;
/* If the result contains any bytes with the top bit set,
it's UTF-8 and we should decode it to Unicode */
while
(
*
p
!=
'\0'
)
{
if
(
*
p
&
0x80
)
break
;
p
++
;
}
if
(
*
p
==
'\0'
)
res
=
PyString_FromStringAndSize
(
s
,
(
int
)(
p
-
s
));
else
{
/* Convert UTF-8 to Unicode string */
p
=
strchr
(
p
,
'\0'
);
res
=
PyUnicode_DecodeUTF8
(
s
,
(
int
)(
p
-
s
),
"strict"
);
if
(
res
==
NULL
)
{
PyErr_Clear
();
res
=
PyString_FromStringAndSize
(
s
,
(
int
)(
p
-
s
));
}
}
res
=
PyUnicode_FromStringAndSize
(
s
,
(
int
)(
p
-
s
));
}
return
res
;
}
...
...
@@ -1318,7 +1269,7 @@ Tkapp_GlobalCall(PyObject *self, PyObject *args)
if
(
err
==
TCL_ERROR
)
res
=
Tkinter_Error
(
self
);
else
res
=
Py
String
_FromString
(
Tkapp_Result
(
self
));
res
=
Py
Unicode
_FromString
(
Tkapp_Result
(
self
));
LEAVE_OVERLAP_TCL
ckfree
(
cmd
);
}
...
...
@@ -1344,7 +1295,7 @@ Tkapp_Eval(PyObject *self, PyObject *args)
if
(
err
==
TCL_ERROR
)
res
=
Tkinter_Error
(
self
);
else
res
=
Py
String
_FromString
(
Tkapp_Result
(
self
));
res
=
Py
Unicode
_FromString
(
Tkapp_Result
(
self
));
LEAVE_OVERLAP_TCL
return
res
;
}
...
...
@@ -1367,7 +1318,7 @@ Tkapp_GlobalEval(PyObject *self, PyObject *args)
if
(
err
==
TCL_ERROR
)
res
=
Tkinter_Error
(
self
);
else
res
=
Py
String
_FromString
(
Tkapp_Result
(
self
));
res
=
Py
Unicode
_FromString
(
Tkapp_Result
(
self
));
LEAVE_OVERLAP_TCL
return
res
;
}
...
...
@@ -1391,7 +1342,7 @@ Tkapp_EvalFile(PyObject *self, PyObject *args)
res
=
Tkinter_Error
(
self
);
else
res
=
Py
String
_FromString
(
Tkapp_Result
(
self
));
res
=
Py
Unicode
_FromString
(
Tkapp_Result
(
self
));
LEAVE_OVERLAP_TCL
return
res
;
}
...
...
@@ -1414,7 +1365,7 @@ Tkapp_Record(PyObject *self, PyObject *args)
if
(
err
==
TCL_ERROR
)
res
=
Tkinter_Error
(
self
);
else
res
=
Py
String
_FromString
(
Tkapp_Result
(
self
));
res
=
Py
Unicode
_FromString
(
Tkapp_Result
(
self
));
LEAVE_OVERLAP_TCL
return
res
;
}
...
...
@@ -1628,7 +1579,7 @@ GetVar(PyObject *self, PyObject *args, int flags)
res
=
FromObj
(
self
,
tres
);
}
else
{
res
=
Py
String
_FromString
(
Tcl_GetString
(
tres
));
res
=
Py
Unicode
_FromString
(
Tcl_GetString
(
tres
));
}
}
LEAVE_OVERLAP_TCL
...
...
@@ -1872,7 +1823,7 @@ Tkapp_SplitList(PyObject *self, PyObject *args)
goto
finally
;
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
PyObject
*
s
=
Py
String
_FromString
(
argv
[
i
]);
PyObject
*
s
=
Py
Unicode
_FromString
(
argv
[
i
]);
if
(
!
s
||
PyTuple_SetItem
(
v
,
i
,
s
))
{
Py_DECREF
(
v
);
v
=
NULL
;
...
...
@@ -1913,7 +1864,7 @@ Tkapp_Merge(PyObject *self, PyObject *args)
PyObject
*
res
=
NULL
;
if
(
s
)
{
res
=
Py
String
_FromString
(
s
);
res
=
Py
Unicode
_FromString
(
s
);
ckfree
(
s
);
}
...
...
@@ -1963,7 +1914,7 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
return
PythonCmd_Error
(
interp
);
for
(
i
=
0
;
i
<
(
argc
-
1
);
i
++
)
{
PyObject
*
s
=
Py
String
_FromString
(
argv
[
i
+
1
]);
PyObject
*
s
=
Py
Unicode
_FromString
(
argv
[
i
+
1
]);
if
(
!
s
||
PyTuple_SetItem
(
arg
,
i
,
s
))
{
Py_DECREF
(
arg
);
return
PythonCmd_Error
(
interp
);
...
...
@@ -3039,7 +2990,7 @@ ins_long(PyObject *d, char *name, long val)
static
void
ins_string
(
PyObject
*
d
,
char
*
name
,
char
*
val
)
{
PyObject
*
v
=
Py
String
_FromString
(
val
);
PyObject
*
v
=
Py
Unicode
_FromString
(
val
);
if
(
v
)
{
PyDict_SetItemString
(
d
,
name
,
v
);
Py_DECREF
(
v
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment