Skip to content

Commit a6f8ee7

Browse files
authored
Handle more ambiguous cases
1 parent 1699b91 commit a6f8ee7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Lib/hashlib.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,15 @@ def __data_argument(funcname, data_sentinel, kwargs):
155155
# new(name, string=...)
156156
return kwargs.pop('string')
157157
return b''
158-
# new(name, data)
159-
return data_sentinel
158+
else:
159+
if 'data' in kwargs:
160+
# new(name, data, data=...)
161+
raise TypeError(f"{funcname}(): got multiple values for argument 'data'")
162+
if 'string' in kwargs:
163+
# new(name, data, string=...)
164+
raise TypeError(f"{funcname}(): got multiple values for argument 'string'")
165+
# new(name, data)
166+
return data_sentinel
160167

161168

162169
def __py_new(name, __data_sentinel=None, **kwargs):

0 commit comments

Comments
 (0)