File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ What's New in Python 3.7.0 alpha 1
1010Core and Builtins
1111-----------------
1212
13+ - Issue #27222: Clean up redundant code in long_rshift function. Thanks
14+ Oren Milman.
15+
1316- Upgrade internal unicode databases to Unicode version 9.0.0.
1417
1518- Issue #28131: Fix a regression in zipimport's compile_source(). zipimport
Original file line number Diff line number Diff line change @@ -4296,22 +4296,22 @@ long_rshift(PyLongObject *a, PyLongObject *b)
42964296 PyLongObject * a1 , * a2 ;
42974297 a1 = (PyLongObject * ) long_invert (a );
42984298 if (a1 == NULL )
4299- goto rshift_error ;
4299+ return NULL ;
43004300 a2 = (PyLongObject * ) long_rshift (a1 , b );
43014301 Py_DECREF (a1 );
43024302 if (a2 == NULL )
4303- goto rshift_error ;
4303+ return NULL ;
43044304 z = (PyLongObject * ) long_invert (a2 );
43054305 Py_DECREF (a2 );
43064306 }
43074307 else {
43084308 shiftby = PyLong_AsSsize_t ((PyObject * )b );
43094309 if (shiftby == -1L && PyErr_Occurred ())
4310- goto rshift_error ;
4310+ return NULL ;
43114311 if (shiftby < 0 ) {
43124312 PyErr_SetString (PyExc_ValueError ,
43134313 "negative shift count" );
4314- goto rshift_error ;
4314+ return NULL ;
43154315 }
43164316 wordshift = shiftby / PyLong_SHIFT ;
43174317 newsize = Py_ABS (Py_SIZE (a )) - wordshift ;
@@ -4323,19 +4323,15 @@ long_rshift(PyLongObject *a, PyLongObject *b)
43234323 himask = PyLong_MASK ^ lomask ;
43244324 z = _PyLong_New (newsize );
43254325 if (z == NULL )
4326- goto rshift_error ;
4327- if (Py_SIZE (a ) < 0 )
4328- Py_SIZE (z ) = - (Py_SIZE (z ));
4326+ return NULL ;
43294327 for (i = 0 , j = wordshift ; i < newsize ; i ++ , j ++ ) {
43304328 z -> ob_digit [i ] = (a -> ob_digit [j ] >> loshift ) & lomask ;
43314329 if (i + 1 < newsize )
43324330 z -> ob_digit [i ] |= (a -> ob_digit [j + 1 ] << hishift ) & himask ;
43334331 }
4334- z = long_normalize (z );
4332+ z = maybe_small_long ( long_normalize (z ) );
43354333 }
4336- rshift_error :
4337- return (PyObject * ) maybe_small_long (z );
4338-
4334+ return (PyObject * )z ;
43394335}
43404336
43414337static PyObject *
You can’t perform that action at this time.
0 commit comments