File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1366,6 +1366,11 @@ def __add__(self, other):
13661366 a = hexint (12345 )
13671367 verify (int (a ) == 12345 )
13681368 verify (int (a ).__class__ is int )
1369+ verify ((+ a ).__class__ is int )
1370+ verify ((a >> 0 ).__class__ is int )
1371+ verify ((a << 0 ).__class__ is int )
1372+ verify ((hexint (0 ) << 12 ).__class__ is int )
1373+ verify ((hexint (0 ) >> 12 ).__class__ is int )
13691374
13701375 class octlong (long ):
13711376 __slots__ = []
Original file line number Diff line number Diff line change @@ -681,8 +681,12 @@ int_neg(PyIntObject *v)
681681static PyObject *
682682int_pos (PyIntObject * v )
683683{
684- Py_INCREF (v );
685- return (PyObject * )v ;
684+ if (PyInt_CheckExact (v )) {
685+ Py_INCREF (v );
686+ return (PyObject * )v ;
687+ }
688+ else
689+ return PyInt_FromLong (v -> ob_ival );
686690}
687691
688692static PyObject *
@@ -716,10 +720,8 @@ int_lshift(PyIntObject *v, PyIntObject *w)
716720 PyErr_SetString (PyExc_ValueError , "negative shift count" );
717721 return NULL ;
718722 }
719- if (a == 0 || b == 0 ) {
720- Py_INCREF (v );
721- return (PyObject * ) v ;
722- }
723+ if (a == 0 || b == 0 )
724+ return int_pos (v );
723725 if (b >= LONG_BIT ) {
724726 return PyInt_FromLong (0L );
725727 }
@@ -737,10 +739,8 @@ int_rshift(PyIntObject *v, PyIntObject *w)
737739 PyErr_SetString (PyExc_ValueError , "negative shift count" );
738740 return NULL ;
739741 }
740- if (a == 0 || b == 0 ) {
741- Py_INCREF (v );
742- return (PyObject * ) v ;
743- }
742+ if (a == 0 || b == 0 )
743+ return int_pos (v );
744744 if (b >= LONG_BIT ) {
745745 if (a < 0 )
746746 a = -1 ;
You can’t perform that action at this time.
0 commit comments