[Python-checkins] CVS: python/dist/src/Objects intobject.c,2.73,2.74

Tim Peters tim_one@users.sourceforge.net
Tue, 11 Sep 2001 14:44:16 -0700


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

Modified Files:
	intobject.c 
Log Message:
More bug 460020.  When I is a subclass of int, disable the +I(whatever),
I(0) << whatever, I(0) >> whatever, I(whatever) << 0 and I(whatever) >> 0
optimizations.


Index: intobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v
retrieving revision 2.73
retrieving revision 2.74
diff -C2 -d -r2.73 -r2.74
*** intobject.c	2001/09/11 16:13:52	2.73
--- intobject.c	2001/09/11 21:44:14	2.74
***************
*** 682,687 ****
  int_pos(PyIntObject *v)
  {
! 	Py_INCREF(v);
! 	return (PyObject *)v;
  }
  
--- 682,691 ----
  int_pos(PyIntObject *v)
  {
! 	if (PyInt_CheckExact(v)) {
! 		Py_INCREF(v);
! 		return (PyObject *)v;
! 	}
! 	else
! 		return PyInt_FromLong(v->ob_ival);
  }
  
***************
*** 716,724 ****
  		PyErr_SetString(PyExc_ValueError, "negative shift count");
  		return NULL;
- 	}
- 	if (a == 0 || b == 0) {
- 		Py_INCREF(v);
- 		return (PyObject *) v;
  	}
  	if (b >= LONG_BIT) {
  		return PyInt_FromLong(0L);
--- 720,726 ----
  		PyErr_SetString(PyExc_ValueError, "negative shift count");
  		return NULL;
  	}
+ 	if (a == 0 || b == 0)
+ 		return int_pos(v);
  	if (b >= LONG_BIT) {
  		return PyInt_FromLong(0L);
***************
*** 737,745 ****
  		PyErr_SetString(PyExc_ValueError, "negative shift count");
  		return NULL;
- 	}
- 	if (a == 0 || b == 0) {
- 		Py_INCREF(v);
- 		return (PyObject *) v;
  	}
  	if (b >= LONG_BIT) {
  		if (a < 0)
--- 739,745 ----
  		PyErr_SetString(PyExc_ValueError, "negative shift count");
  		return NULL;
  	}
+ 	if (a == 0 || b == 0)
+ 		return int_pos(v);
  	if (b >= LONG_BIT) {
  		if (a < 0)