Style fixes, and switch %U to %S
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12573 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f2b0d2ef40
commit
99dc5893d8
2 changed files with 28 additions and 59 deletions
|
|
@ -279,7 +279,7 @@ SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *type) {
|
|||
if (descr->d_getset->get != NULL)
|
||||
return descr->d_getset->get(obj, descr->d_getset->closure);
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300U' of '%.100s' objects is not readable", descr->d_name, descr->d_type->tp_name);
|
||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", descr->d_name, descr->d_type->tp_name);
|
||||
#else
|
||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(descr->d_name), descr->d_type->tp_name);
|
||||
#endif
|
||||
|
|
@ -293,7 +293,7 @@ SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
|
|||
if (descr->d_getset->set != NULL)
|
||||
return descr->d_getset->set(obj, value, descr->d_getset->closure);
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300U' of '%.100s' objects is not writable", descr->d_name, descr->d_type->tp_name);
|
||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", descr->d_name, descr->d_type->tp_name);
|
||||
#else
|
||||
PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(descr->d_name), descr->d_type->tp_name);
|
||||
#endif
|
||||
|
|
@ -351,13 +351,13 @@ SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) {
|
|||
if (local_set != NULL)
|
||||
return local_set(attribute, (PyObject *)type, value);
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400U'", type->tp_name, name);
|
||||
PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400S'", type->tp_name, name);
|
||||
#else
|
||||
PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name));
|
||||
#endif
|
||||
} else {
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400U'", type->tp_name, name);
|
||||
PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400S'", type->tp_name, name);
|
||||
#else
|
||||
PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name));
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1448,32 +1448,6 @@ SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
|
|||
return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
|
||||
}
|
||||
|
||||
/*
|
||||
SWIGRUNTIME int
|
||||
SWIG_Python_NewBuiltinObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
|
||||
assert(self);
|
||||
SwigPyClientData *clientdata = (SwigPyClientData *)(type->clientdata);
|
||||
assert(clientdata);
|
||||
assert(clientdata->pytype);
|
||||
int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
|
||||
SwigPyObject *newobj = (SwigPyObject *)self;
|
||||
if (newobj->ptr) {
|
||||
PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
|
||||
while (newobj->next) newobj = (SwigPyObject *)newobj->next;
|
||||
newobj->next = next_self;
|
||||
newobj = (SwigPyObject *)next_self;
|
||||
}
|
||||
newobj->ptr = ptr;
|
||||
newobj->own = own;
|
||||
newobj->ty = type;
|
||||
newobj->next = 0;
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
newobj->dict = 0;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
/* -----------------------------------------------------------------------------*
|
||||
* Get type list
|
||||
* -----------------------------------------------------------------------------*/
|
||||
|
|
@ -1712,7 +1686,7 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
|
|||
PyTypeObject *tp = obj->ob_type;
|
||||
PyObject *descr;
|
||||
descrsetfunc f;
|
||||
int res = -1;
|
||||
int res;
|
||||
|
||||
#ifdef Py_USING_UNICODE
|
||||
if (PyString_Check(name)) {
|
||||
|
|
@ -1721,40 +1695,35 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
|
|||
return -1;
|
||||
} else if (!PyUnicode_Check(name)) {
|
||||
#else
|
||||
if (!PyString_Check(name)) {
|
||||
if (!PyString_Check(name)) {
|
||||
#endif
|
||||
PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name);
|
||||
return -1;
|
||||
} else {
|
||||
} else {
|
||||
Py_INCREF(name);
|
||||
}
|
||||
|
||||
if (!tp->tp_dict) {
|
||||
if (PyType_Ready(tp) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
||||
descr = _PyType_Lookup(tp, name);
|
||||
f = NULL;
|
||||
if (descr != NULL)
|
||||
f = descr->ob_type->tp_descr_set;
|
||||
if (!f) {
|
||||
PyErr_Format(PyExc_AttributeError,
|
||||
#ifdef Py_USING_UNICODE
|
||||
"'%.100s' object has no attribute '%.200U'",
|
||||
#else
|
||||
"'%.100s' object has no attribute '%.200S'",
|
||||
#endif
|
||||
tp->tp_name, name);
|
||||
} else {
|
||||
res = f(descr, obj, value);
|
||||
}
|
||||
|
||||
done:
|
||||
Py_DECREF(name);
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!tp->tp_dict) {
|
||||
if (PyType_Ready(tp) < 0)
|
||||
goto done;
|
||||
}
|
||||
|
||||
res = -1;
|
||||
descr = _PyType_Lookup(tp, name);
|
||||
f = NULL;
|
||||
if (descr != NULL)
|
||||
f = descr->ob_type->tp_descr_set;
|
||||
if (!f) {
|
||||
PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200S'", tp->tp_name, name);
|
||||
} else {
|
||||
res = f(descr, obj, value);
|
||||
}
|
||||
|
||||
done:
|
||||
Py_DECREF(name);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue