Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xor function raises TypeError: pop expected at least 1 argument, got 0 #2390

Closed
marinelay opened this issue Apr 16, 2024 · 2 comments · Fixed by #2391
Closed

xor function raises TypeError: pop expected at least 1 argument, got 0 #2390

marinelay opened this issue Apr 16, 2024 · 2 comments · Fixed by #2391

Comments

@marinelay
Copy link
Contributor

# misc binary functions
def xor(*args, **kwargs):
"""xor(*args, cut = 'max') -> str
Flattens its arguments using :func:`pwnlib.util.packing.flat` and
then xors them together. If the end of a string is reached, it wraps
around in the string.
Arguments:
args: The arguments to be xor'ed together.
cut: How long a string should be returned.
Can be either 'min'/'max'/'left'/'right' or a number.
Returns:
The string of the arguments xor'ed together.
Example:
>>> xor(b'lol', b'hello', 42)
b'. ***'
"""
cut = kwargs.pop('cut', 'max')
if kwargs != {}:
raise TypeError("xor() got an unexpected keyword argument '%s'" % kwargs.pop()[0])

At line 330, it raises the type error TypeError: pop expected at least 1 argument, got 0 because pop method cannot be used without arguments.

I believe that it should be fixed to report proper error message.

@Arusekk
Copy link
Member

Arusekk commented Apr 17, 2024

The code looks as if the intention was always to use popitem; anyway, when we finally drop py2 support, we could finally use keyword-only arguments here to get rid of all of this boilerplate.

Have you spotted more such uses throughout the code?

@marinelay
Copy link
Contributor Author

I couldn't find any other occurrences for dict.pop like this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants