[Python-checkins] CVS: python/dist/src/Modules stropmodule.c,2.81,2.82
Guido van Rossum
gvanrossum@users.sourceforge.net
2001年5月14日 19:14:46 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv26415/Modules
Modified Files:
stropmodule.c
Log Message:
Add warnings to the strop module, for to those functions that really
*are* obsolete; three variables and the maketrans() function are not
(yet) obsolete.
Add a compensating warnings.filterwarnings() call to test_strop.py.
Add this to the NEWS.
Index: stropmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/stropmodule.c,v
retrieving revision 2.81
retrieving revision 2.82
diff -C2 -r2.81 -r2.82
*** stropmodule.c 2001年05月10日 01:23:39 2.81
--- stropmodule.c 2001年05月15日 02:14:44 2.82
***************
*** 13,16 ****
--- 13,20 ----
XXX are defined for all 8-bit characters! */
+ #define WARN if (PyErr_Warn(PyExc_DeprecationWarning, \
+ "strop functions are obsolete; use string methods")) \
+ return NULL
+
/* The lstrip(), rstrip() and strip() functions are implemented
in do_strip(), which uses an additional parameter to indicate what
***************
*** 96,99 ****
--- 100,104 ----
PyObject *list, *item;
+ WARN;
sub = NULL;
n = 0;
***************
*** 168,171 ****
--- 173,177 ----
intargfunc getitemfunc;
+ WARN;
if (!PyArg_ParseTuple(args, "O|t#:join", &seq, &sep, &seplen))
return NULL;
***************
*** 293,296 ****
--- 299,303 ----
int len, n, i = 0, last = INT_MAX;
+ WARN;
if (!PyArg_ParseTuple(args, "t#t#|ii:find", &s, &len, &sub, &n, &i, &last))
return NULL;
***************
*** 336,339 ****
--- 343,347 ----
int i = 0, last = INT_MAX;
+ WARN;
if (!PyArg_ParseTuple(args, "t#t#|ii:rfind", &s, &len, &sub, &n, &i, &last))
return NULL;
***************
*** 405,408 ****
--- 413,417 ----
strop_strip(PyObject *self, PyObject *args)
{
+ WARN;
return do_strip(args, BOTHSTRIP);
}
***************
*** 417,420 ****
--- 426,430 ----
strop_lstrip(PyObject *self, PyObject *args)
{
+ WARN;
return do_strip(args, LEFTSTRIP);
}
***************
*** 429,432 ****
--- 439,443 ----
strop_rstrip(PyObject *self, PyObject *args)
{
+ WARN;
return do_strip(args, RIGHTSTRIP);
}
***************
*** 446,449 ****
--- 457,461 ----
int changed;
+ WARN;
if (!PyArg_Parse(args, "t#", &s, &n))
return NULL;
***************
*** 484,487 ****
--- 496,500 ----
int changed;
+ WARN;
if (!PyArg_Parse(args, "t#", &s, &n))
return NULL;
***************
*** 523,526 ****
--- 536,540 ----
int changed;
+ WARN;
if (!PyArg_Parse(args, "t#", &s, &n))
return NULL;
***************
*** 578,581 ****
--- 592,596 ----
int tabsize = 8;
+ WARN;
/* Get arguments */
if (!PyArg_ParseTuple(args, "s#|i:expandtabs", &string, &stringlen, &tabsize))
***************
*** 643,646 ****
--- 658,662 ----
int m, r;
+ WARN;
if (!PyArg_ParseTuple(args, "t#t#|ii:count", &s, &len, &sub, &n, &i, &last))
return NULL;
***************
*** 686,689 ****
--- 702,706 ----
int changed;
+ WARN;
if (!PyArg_Parse(args, "t#", &s, &n))
return NULL;
***************
*** 734,737 ****
--- 751,755 ----
char buffer[256]; /* For errors */
+ WARN;
if (!PyArg_ParseTuple(args, "s|i:atoi", &s, &base))
return NULL;
***************
*** 787,790 ****
--- 805,809 ----
char buffer[256]; /* For errors */
+ WARN;
if (!PyArg_ParseTuple(args, "s|i:atol", &s, &base))
return NULL;
***************
*** 831,834 ****
--- 850,854 ----
char buffer[256]; /* For errors */
+ WARN;
if (!PyArg_ParseTuple(args, "s:atof", &s))
return NULL;
***************
*** 914,917 ****
--- 934,938 ----
int trans_table[256];
+ WARN;
if (!PyArg_ParseTuple(args, "St#|t#:translate", &input_obj,
&table1, &tablen, &del_table, &dellen))
***************
*** 1125,1128 ****
--- 1146,1150 ----
PyObject *new;
+ WARN;
if (!PyArg_ParseTuple(args, "t#t#t#|i:replace",
&str, &len, &pat, &pat_len, &sub, &sub_len,