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

Change from pop to keys for reporting proper error message #2391

Merged
merged 6 commits into from
Apr 21, 2024

Conversation

marinelay
Copy link
Contributor

Fixes #2390

@peace-maker
Copy link
Member

Cool, can you add a test to avoid this regression in the future please? We use doctests, so adding another entry to the "Examples" is the way.

@marinelay
Copy link
Contributor Author

Done!
But, this is my first time using doctest, so I'm not sure if this is correct...

@peace-maker
Copy link
Member

I'm confused if this actually runs since it'd expect it to require an # ELLIPSIS: ... comment or similar. I'll test locally.

@marinelay
Copy link
Contributor Author

Oh, I saw in the documentation for doctest that ELLIPSIS option is independent of traceback (https://docs.python.org/3/library/doctest.html#what-about-exceptions).
I just tested it locally in Python 3.9.18 and it worked fine without the option!

@Arusekk
Copy link
Member

Arusekk commented Apr 18, 2024

I think this code originally meant to use popitem.

(Note to self: This code will be gone anyway with the migration to py3 keyword-only arguments hopefully.)

"""

cut = kwargs.pop('cut', 'max')

if kwargs != {}:
raise TypeError("xor() got an unexpected keyword argument '%s'" % kwargs.pop()[0])
raise TypeError("xor() got an unexpected keyword argument '%s'" % list(kwargs.keys())[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise TypeError("xor() got an unexpected keyword argument '%s'" % list(kwargs.keys())[0])
raise TypeError("xor() got an unexpected keyword argument '%s'" % kwargs.popitem()[0])

@peace-maker peace-maker merged commit 7ac5a34 into Gallopsled:dev Apr 21, 2024
7 of 8 checks passed
@peace-maker
Copy link
Member

Thank you again!

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

Successfully merging this pull request may close these issues.

xor function raises TypeError: pop expected at least 1 argument, got 0
3 participants