[Python-checkins] python/dist/src/Objects unicodeobject.c,2.174,2.175
nascheme@projects.sourceforge.net
nascheme@projects.sourceforge.net
Mon, 18 Nov 2002 08:10:30 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv23207/Objects
Modified Files:
unicodeobject.c
Log Message:
Add nb_remainder (i.e. __mod__) slot to unicode type. Fixes SF bug #615506.
Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.174
retrieving revision 2.175
diff -C2 -d -r2.174 -r2.175
*** unicodeobject.c 12 Nov 2002 23:01:11 -0000 2.174
--- unicodeobject.c 18 Nov 2002 16:10:18 -0000 2.175
***************
*** 5800,5803 ****
--- 5800,5821 ----
};
+ static PyObject *
+ unicode_mod(PyObject *v, PyObject *w)
+ {
+ if (!PyUnicode_Check(v)) {
+ Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
+ }
+ return PyUnicode_Format(v, w);
+ }
+
+ static PyNumberMethods unicode_as_number = {
+ 0, /*nb_add*/
+ 0, /*nb_subtract*/
+ 0, /*nb_multiply*/
+ 0, /*nb_divide*/
+ unicode_mod, /*nb_remainder*/
+ };
+
static PySequenceMethods unicode_as_sequence = {
(inquiry) unicode_length, /* sq_length */
***************
*** 6648,6652 ****
(cmpfunc) unicode_compare, /* tp_compare */
(reprfunc) unicode_repr, /* tp_repr */
! 0, /* tp_as_number */
&unicode_as_sequence, /* tp_as_sequence */
&unicode_as_mapping, /* tp_as_mapping */
--- 6666,6670 ----
(cmpfunc) unicode_compare, /* tp_compare */
(reprfunc) unicode_repr, /* tp_repr */
! &unicode_as_number, /* tp_as_number */
&unicode_as_sequence, /* tp_as_sequence */
&unicode_as_mapping, /* tp_as_mapping */
***************
*** 6657,6661 ****
0, /* tp_setattro */
&unicode_as_buffer, /* tp_as_buffer */
! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
unicode_doc, /* tp_doc */
0, /* tp_traverse */
--- 6675,6680 ----
0, /* tp_setattro */
&unicode_as_buffer, /* tp_as_buffer */
! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES |
! Py_TPFLAGS_BASETYPE, /* tp_flags */
unicode_doc, /* tp_doc */
0, /* tp_traverse */