Author: thomas.heller
Date: Thu Jul 12 20:53:22 2007
New Revision: 56324
Modified:
python/branches/py3k-struni/Modules/_ctypes/_ctypes.c
Log:
Change the StgDictObject's proto member to a PyUnicode_Object (was a
PyStringObject before).
Modified: python/branches/py3k-struni/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/py3k-struni/Modules/_ctypes/_ctypes.c (original)
+++ python/branches/py3k-struni/Modules/_ctypes/_ctypes.c Thu Jul 12
20:53:22 2007
@@ -414,6 +414,7 @@
return -1;
if (value && PyUnicode_Check(key) &&
+ /* XXX struni PyUnicode_AsString can fail (also in other places)! */
0 == strcmp(PyUnicode_AsString(key), "_fields_"))
return StructUnionType_update_stgdict(self, value, 1);
return 0;
@@ -1339,10 +1340,10 @@
}
/* c_char_p, c_wchar_p */
stgd = PyObject_stgdict(value);
- if (stgd && CDataObject_Check(value) && stgd->proto &&
PyString_Check(stgd->proto)) {
+ if (stgd && CDataObject_Check(value) && stgd->proto &&
PyUnicode_Check(stgd->proto)) {
PyCArgObject *parg;
- switch (PyString_AS_STRING(stgd->proto)[0]) {
+ switch (PyUnicode_AsString(stgd->proto)[0]) {
case 'z': /* c_char_p */
case 'Z': /* c_wchar_p */
parg = new_CArgObject();
@@ -1511,16 +1512,7 @@
goto error;
proto_str = PyString_AS_STRING(v);
proto_len = PyString_GET_SIZE(v);
- }
- else if (PyString_Check(proto)) {
- proto_str = PyString_AS_STRING(proto);
- proto_len = PyString_GET_SIZE(proto);
- }
- else if (PyBytes_Check(proto)) {
- proto_str = PyBytes_AS_STRING(proto);
- proto_len = PyBytes_GET_SIZE(proto);
- }
- else {
+ } else {
PyErr_SetString(PyExc_TypeError,
"class must define a '_type_' string attribute");
goto error;
@@ -2681,9 +2673,9 @@
dict = PyType_stgdict(arg);
if (dict
/* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
- && PyString_Check(dict->proto)
+ && PyUnicode_Check(dict->proto)
/* We only allow c_void_p, c_char_p and c_wchar_p as a simple output parameter
type */
- && (strchr("PzZ", PyString_AS_STRING(dict->proto)[0]))) {
+ && (strchr("PzZ", PyUnicode_AsString(dict->proto)[0]))) {
return 1;
}
@@ -3183,7 +3175,7 @@
"NULL stgdict unexpected");
goto error;
}
- if (PyString_Check(dict->proto)) {
+ if (PyUnicode_Check(dict->proto)) {
PyErr_Format(
PyExc_TypeError,
"%s 'out' parameter must be passed as
default value",
@@ -4594,8 +4586,8 @@
return 1;
dict = PyType_stgdict(arg);
if (dict) {
- if (PyString_Check(dict->proto)
- && (strchr("sPzUZXO", PyString_AS_STRING(dict->proto)[0])))
{
+ if (PyUnicode_Check(dict->proto)
+ && (strchr("sPzUZXO", PyUnicode_AsString(dict->proto)[0])))
{
/* simple pointer types, c_void_p, c_wchar_p, BSTR, ...
*/
return 1;
}
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins