[Python-checkins] CVS: python/dist/src/Python sysmodule.c,2.62,2.63

Fred Drake python-dev@python.org
Tue, 9 May 2000 15:57:03 -0400


Update of /projects/cvsroot/python/dist/src/Python
In directory seahag.cnri.reston.va.us:/home/fdrake/projects/python/Python

Modified Files:
	sysmodule.c 
Log Message:

M.-A. Lemburg <mal@lemburg.com>:
Added APIs to allow setting and querying the system's
current string encoding: sys.set_string_encoding()
and sys.get_string_encoding().


Index: sysmodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/sysmodule.c,v
retrieving revision 2.62
retrieving revision 2.63
diff -C2 -r2.62 -r2.63
*** sysmodule.c	2000/04/13 20:03:20	2.62
--- sysmodule.c	2000/05/09 19:57:01	2.63
***************
*** 144,147 ****
--- 144,182 ----
  
  static PyObject *
+ sys_get_string_encoding(self, args)
+ 	PyObject *self;
+ 	PyObject *args;
+ {
+ 	if (!PyArg_ParseTuple(args, ":get_string_encoding"))
+ 		return NULL;
+ 	return PyString_FromString(PyUnicode_GetDefaultEncoding());
+ }
+ 
+ static char get_string_encoding_doc[] =
+ "get_string_encoding() -> string\n\
+ \n\
+ Return the current default string encoding used by the Unicode \n\
+ implementation.";
+ 
+ static PyObject *
+ sys_set_string_encoding(self, args)
+ 	PyObject *self;
+ 	PyObject *args;
+ {
+ 	char *encoding;
+ 	if (!PyArg_ParseTuple(args, "s:set_string_encoding", &encoding))
+ 		return NULL;
+ 	if (PyUnicode_SetDefaultEncoding(encoding))
+ 	    	return NULL;
+ 	Py_INCREF(Py_None);
+ 	return Py_None;
+ }
+ 
+ static char set_string_encoding_doc[] =
+ "set_string_encoding(encoding)\n\
+ \n\
+ Set the current default string encoding used by the Unicode implementation.";
+ 
+ static PyObject *
  sys_settrace(self, args)
  	PyObject *self;
***************
*** 267,270 ****
--- 302,306 ----
  	{"exc_info",	sys_exc_info, 1, exc_info_doc},
  	{"exit",	sys_exit, 0, exit_doc},
+ 	{"get_string_encoding", sys_get_string_encoding, 1, get_string_encoding_doc},
  #ifdef COUNT_ALLOCS
  	{"getcounts",	sys_getcounts, 1},
***************
*** 280,283 ****
--- 316,320 ----
  	{"mdebug",	sys_mdebug, 1},
  #endif
+ 	{"set_string_encoding", sys_set_string_encoding, 1, set_string_encoding_doc},
  	{"setcheckinterval",	sys_setcheckinterval, 1, setcheckinterval_doc},
  	{"setprofile",	sys_setprofile, 0, setprofile_doc},