Skip to content

Commit

Permalink
Fix python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
csm10495 committed Oct 16, 2020
1 parent 1a0533d commit ed48ada
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions six.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ def python_2_unicode_compatible(klass):


if PY2:
def min(*iterable, key=None, default=None):
def min(*iterable, **kwargs):
"""
min(...)
min(iterable, *[, default=obj, key=func]) -> value
Expand All @@ -969,13 +969,19 @@ def min(*iterable, key=None, default=None):
the provided iterable is empty.
With two or more arguments, return the smallest argument.
"""
default = kwargs.pop('default', None)
key = kwargs.pop('key', None)

if kwargs:
raise TypeError('min() got an unexpected keyword argument')

if default is not None and len(iterable) == 1 and len(iterable[0]) == 0:
return default

return __builtins__['min'](*iterable, key=key)


def max(*iterable, key=None, default=None):
def max(*iterable, **kwargs):
"""
max(...)
max(iterable, *[, default=obj, key=func]) -> value
Expand All @@ -986,6 +992,12 @@ def max(*iterable, key=None, default=None):
the provided iterable is empty.
With two or more arguments, return the largest argument.
"""
default = kwargs.pop('default', None)
key = kwargs.pop('key', None)

if kwargs:
raise TypeError('max() got an unexpected keyword argument')

if default is not None and len(iterable) == 1 and len(iterable[0]) == 0:
return default

Expand Down

0 comments on commit ed48ada

Please sign in to comment.