@@ -12,6 +12,10 @@ static char strop_module__doc__[] =
1212/* XXX This file assumes that the <ctype.h> is*() functions
1313 XXX are defined for all 8-bit characters! */
1414
15+ #define WARN if (PyErr_Warn(PyExc_DeprecationWarning, \
16+ "strop functions are obsolete; use string methods")) \
17+ return NULL
18+
1519/* The lstrip(), rstrip() and strip() functions are implemented
1620 in do_strip(), which uses an additional parameter to indicate what
1721 type of strip should occur. */
@@ -95,6 +99,7 @@ strop_splitfields(PyObject *self, PyObject *args)
9599 char * s , * sub ;
96100 PyObject * list , * item ;
97101
102+ WARN ;
98103 sub = NULL ;
99104 n = 0 ;
100105 splitcount = 0 ;
@@ -167,6 +172,7 @@ strop_joinfields(PyObject *self, PyObject *args)
167172 char * p = NULL ;
168173 intargfunc getitemfunc ;
169174
175+ WARN ;
170176 if (!PyArg_ParseTuple (args , "O|t#:join" , & seq , & sep , & seplen ))
171177 return NULL ;
172178 if (sep == NULL ) {
@@ -292,6 +298,7 @@ strop_find(PyObject *self, PyObject *args)
292298 char * s , * sub ;
293299 int len , n , i = 0 , last = INT_MAX ;
294300
301+ WARN ;
295302 if (!PyArg_ParseTuple (args , "t#t#|ii:find" , & s , & len , & sub , & n , & i , & last ))
296303 return NULL ;
297304
@@ -335,6 +342,7 @@ strop_rfind(PyObject *self, PyObject *args)
335342 int len , n , j ;
336343 int i = 0 , last = INT_MAX ;
337344
345+ WARN ;
338346 if (!PyArg_ParseTuple (args , "t#t#|ii:rfind" , & s , & len , & sub , & n , & i , & last ))
339347 return NULL ;
340348
@@ -404,6 +412,7 @@ static char strip__doc__[] =
404412static PyObject *
405413strop_strip (PyObject * self , PyObject * args )
406414{
415+ WARN ;
407416 return do_strip (args , BOTHSTRIP );
408417}
409418
@@ -416,6 +425,7 @@ static char lstrip__doc__[] =
416425static PyObject *
417426strop_lstrip (PyObject * self , PyObject * args )
418427{
428+ WARN ;
419429 return do_strip (args , LEFTSTRIP );
420430}
421431
@@ -428,6 +438,7 @@ static char rstrip__doc__[] =
428438static PyObject *
429439strop_rstrip (PyObject * self , PyObject * args )
430440{
441+ WARN ;
431442 return do_strip (args , RIGHTSTRIP );
432443}
433444
@@ -445,6 +456,7 @@ strop_lower(PyObject *self, PyObject *args)
445456 PyObject * new ;
446457 int changed ;
447458
459+ WARN ;
448460 if (!PyArg_Parse (args , "t#" , & s , & n ))
449461 return NULL ;
450462 new = PyString_FromStringAndSize (NULL , n );
@@ -483,6 +495,7 @@ strop_upper(PyObject *self, PyObject *args)
483495 PyObject * new ;
484496 int changed ;
485497
498+ WARN ;
486499 if (!PyArg_Parse (args , "t#" , & s , & n ))
487500 return NULL ;
488501 new = PyString_FromStringAndSize (NULL , n );
@@ -522,6 +535,7 @@ strop_capitalize(PyObject *self, PyObject *args)
522535 PyObject * new ;
523536 int changed ;
524537
538+ WARN ;
525539 if (!PyArg_Parse (args , "t#" , & s , & n ))
526540 return NULL ;
527541 new = PyString_FromStringAndSize (NULL , n );
@@ -577,6 +591,7 @@ strop_expandtabs(PyObject *self, PyObject *args)
577591 int stringlen ;
578592 int tabsize = 8 ;
579593
594+ WARN ;
580595 /* Get arguments */
581596 if (!PyArg_ParseTuple (args , "s#|i:expandtabs" , & string , & stringlen , & tabsize ))
582597 return NULL ;
@@ -642,6 +657,7 @@ strop_count(PyObject *self, PyObject *args)
642657 int i = 0 , last = INT_MAX ;
643658 int m , r ;
644659
660+ WARN ;
645661 if (!PyArg_ParseTuple (args , "t#t#|ii:count" , & s , & len , & sub , & n , & i , & last ))
646662 return NULL ;
647663 if (last > len )
@@ -685,6 +701,7 @@ strop_swapcase(PyObject *self, PyObject *args)
685701 PyObject * new ;
686702 int changed ;
687703
704+ WARN ;
688705 if (!PyArg_Parse (args , "t#" , & s , & n ))
689706 return NULL ;
690707 new = PyString_FromStringAndSize (NULL , n );
@@ -733,6 +750,7 @@ strop_atoi(PyObject *self, PyObject *args)
733750 long x ;
734751 char buffer [256 ]; /* For errors */
735752
753+ WARN ;
736754 if (!PyArg_ParseTuple (args , "s|i:atoi" , & s , & base ))
737755 return NULL ;
738756
@@ -786,6 +804,7 @@ strop_atol(PyObject *self, PyObject *args)
786804 PyObject * x ;
787805 char buffer [256 ]; /* For errors */
788806
807+ WARN ;
789808 if (!PyArg_ParseTuple (args , "s|i:atol" , & s , & base ))
790809 return NULL ;
791810
@@ -830,6 +849,7 @@ strop_atof(PyObject *self, PyObject *args)
830849 double x ;
831850 char buffer [256 ]; /* For errors */
832851
852+ WARN ;
833853 if (!PyArg_ParseTuple (args , "s:atof" , & s ))
834854 return NULL ;
835855 while (* s && isspace (Py_CHARMASK (* s )))
@@ -913,6 +933,7 @@ strop_translate(PyObject *self, PyObject *args)
913933 PyObject * result ;
914934 int trans_table [256 ];
915935
936+ WARN ;
916937 if (!PyArg_ParseTuple (args , "St#|t#:translate" , & input_obj ,
917938 & table1 , & tablen , & del_table , & dellen ))
918939 return NULL ;
@@ -1124,6 +1145,7 @@ strop_replace(PyObject *self, PyObject *args)
11241145 int count = -1 ;
11251146 PyObject * new ;
11261147
1148+ WARN ;
11271149 if (!PyArg_ParseTuple (args , "t#t#t#|i:replace" ,
11281150 & str , & len , & pat , & pat_len , & sub , & sub_len ,
11291151 & count ))
0 commit comments