File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1371,7 +1371,7 @@ Return the dictionary containing the current scope's local variables.";
13711371
13721372
13731373static PyObject *
1374- min_max (PyObject * args , int sign )
1374+ min_max (PyObject * args , int op )
13751375{
13761376 int i ;
13771377 PyObject * v , * w , * x ;
@@ -1401,16 +1401,16 @@ min_max(PyObject *args, int sign)
14011401 if (w == NULL )
14021402 w = x ;
14031403 else {
1404- int c = PyObject_Compare (x , w );
1405- if (c && PyErr_Occurred ()) {
1404+ int cmp = PyObject_RichCompareBool (x , w , op );
1405+ if (cmp > 0 ) {
1406+ Py_DECREF (w );
1407+ w = x ;
1408+ }
1409+ else if (cmp < 0 ) {
14061410 Py_DECREF (x );
14071411 Py_XDECREF (w );
14081412 return NULL ;
14091413 }
1410- if (c * sign > 0 ) {
1411- Py_DECREF (w );
1412- w = x ;
1413- }
14141414 else
14151415 Py_DECREF (x );
14161416 }
@@ -1424,7 +1424,7 @@ min_max(PyObject *args, int sign)
14241424static PyObject *
14251425builtin_min (PyObject * self , PyObject * v )
14261426{
1427- return min_max (v , -1 );
1427+ return min_max (v , Py_LT );
14281428}
14291429
14301430static char min_doc [] =
@@ -1438,7 +1438,7 @@ With two or more arguments, return the smallest argument.";
14381438static PyObject *
14391439builtin_max (PyObject * self , PyObject * v )
14401440{
1441- return min_max (v , 1 );
1441+ return min_max (v , Py_GT );
14421442}
14431443
14441444static char max_doc [] =
You can’t perform that action at this time.
0 commit comments