[Python-checkins] python/dist/src/Modules timemodule.c,2.129,2.130

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Fri, 19 Jul 2002 10:06:49 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv3342

Modified Files:
	timemodule.c 
Log Message:
Patch to call the Pure python strptime implementation if there's no
C implementation.  See SF patch 474274, by Brett Cannon.

(As an experiment, I'm adding a line that #undefs HAVE_STRPTIME,
so that you'll always get the Python version.  This is so that it
gets some good exercise.  We should eventually delete that line.)


Index: timemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v
retrieving revision 2.129
retrieving revision 2.130
diff -C2 -d -r2.129 -r2.130
*** timemodule.c	16 Jul 2002 01:29:19 -0000	2.129
--- timemodule.c	19 Jul 2002 17:06:47 -0000	2.130
***************
*** 413,416 ****
--- 413,417 ----
  #endif /* HAVE_STRFTIME */
  
+ #undef HAVE_STRPTIME
  #ifdef HAVE_STRPTIME
  
***************
*** 446,449 ****
--- 447,466 ----
  }
  
+ #endif /* HAVE_STRPTIME */
+ 
+ #ifndef HAVE_STRPTIME
+ 
+ static PyObject *
+ time_strptime(PyObject *self, PyObject *args)
+ {
+     PyObject *strptime_module = PyImport_ImportModule("_strptime");
+ 
+     if (!strptime_module) 
+         return NULL;
+     return PyObject_CallMethod(strptime_module, "strptime", "O", args);
+ }
+ 
+ #endif /* !HAVE_STRPTIME */
+ 
  PyDoc_STRVAR(strptime_doc,
  "strptime(string, format) -> tuple\n\
***************
*** 451,455 ****
  Parse a string to a time tuple according to a format specification.\n\
  See the library reference manual for formatting codes (same as strftime()).");
! #endif /* HAVE_STRPTIME */
  
  static PyObject *
--- 468,472 ----
  Parse a string to a time tuple according to a format specification.\n\
  See the library reference manual for formatting codes (same as strftime()).");
! 
  
  static PyObject *
***************
*** 554,560 ****
  	{"strftime",	time_strftime, METH_VARARGS, strftime_doc},
  #endif
- #ifdef HAVE_STRPTIME
  	{"strptime",	time_strptime, METH_VARARGS, strptime_doc},
- #endif
  	{NULL,		NULL}		/* sentinel */
  };
--- 571,575 ----