[Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.198.2.1,2.198.2.2

Guido van Rossum gvanrossum@users.sourceforge.net
Mon, 11 Jun 2001 14:06:05 -0700


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

Modified Files:
      Tag: descr-branch
	bltinmodule.c 
Log Message:
Another one bites the dust: built-in 'int' is now the integer type.
(Still not subtypable though.)


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.198.2.1
retrieving revision 2.198.2.2
diff -C2 -r2.198.2.1 -r2.198.2.2
*** bltinmodule.c	2001/06/06 17:43:42	2.198.2.1
--- bltinmodule.c	2001/06/11 21:06:03	2.198.2.2
***************
*** 1228,1264 ****
  
  static PyObject *
- builtin_int(PyObject *self, PyObject *args)
- {
- 	PyObject *v;
- 	int base = -909;		     /* unlikely! */
- 
- 	if (!PyArg_ParseTuple(args, "O|i:int", &v, &base))
- 		return NULL;
- 	if (base == -909)
- 		return PyNumber_Int(v);
- 	else if (PyString_Check(v))
- 		return PyInt_FromString(PyString_AS_STRING(v), NULL, base);
- 	else if (PyUnicode_Check(v))
- 		return PyInt_FromUnicode(PyUnicode_AS_UNICODE(v),
- 					 PyUnicode_GET_SIZE(v),
- 					 base);
- 	else {
- 		PyErr_SetString(PyExc_TypeError,
- 				"int() can't convert non-string with explicit base");
- 		return NULL;
- 	}
- }
- 
- static char int_doc[] =
- "int(x[, base]) -> integer\n\
- \n\
- Convert a string or number to an integer, if possible.  A floating point\n\
- argument will be truncated towards zero (this does not include a string\n\
- representation of a floating point number!)  When converting a string, use\n\
- the optional base.  It is an error to supply a base when converting a\n\
- non-string.";
- 
- 
- static PyObject *
  builtin_long(PyObject *self, PyObject *args)
  {
--- 1228,1231 ----
***************
*** 2138,2142 ****
  	{"input",	builtin_input, 1, input_doc},
  	{"intern",	builtin_intern, 1, intern_doc},
- 	{"int",		builtin_int, 1, int_doc},
  	{"isinstance",  builtin_isinstance, 1, isinstance_doc},
  	{"issubclass",  builtin_issubclass, 1, issubclass_doc},
--- 2105,2108 ----
***************
*** 2196,2199 ****
--- 2162,2167 ----
  		return NULL;
  	if (PyDict_SetItemString(dict, "list", (PyObject *) &PyList_Type) < 0)
+ 		return NULL;
+ 	if (PyDict_SetItemString(dict, "int", (PyObject *) &PyInt_Type) < 0)
  		return NULL;
  	if (PyDict_SetItemString(dict, "object",