Skip to content

Commit 7ac5a34

Browse files
marinelaymarinelaypeace-maker
authored
Change from pop to keys for reporting proper error message (#2391)
* Change from pop to keys for reporting proper error message * update changelog * add doctest for xor * Add newline to run xor doctests * Switch to `dict.popitem()` --------- Co-authored-by: marinelay <[email protected]> Co-authored-by: Peace-Maker <[email protected]>
1 parent eec3321 commit 7ac5a34

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ The table below shows which release corresponds to each branch, and what date th
7878
- [#2322][2322] Add basic RISCV64 shellcraft support
7979
- [#2330][2330] Change `context.newline` when setting `context.os` to `"windows"`
8080
- [#2389][2389] Fix passing bytes to `context.log_file` and `crc.BitPolynom`
81+
- [#2391][2391] Fix error message when passing invalid kwargs to `xor`
8182

8283
[2360]: https://github.com/Gallopsled/pwntools/pull/2360
8384
[2356]: https://github.com/Gallopsled/pwntools/pull/2356
@@ -86,6 +87,7 @@ The table below shows which release corresponds to each branch, and what date th
8687
[2322]: https://github.com/Gallopsled/pwntools/pull/2322
8788
[2330]: https://github.com/Gallopsled/pwntools/pull/2330
8889
[2389]: https://github.com/Gallopsled/pwntools/pull/2389
90+
[2391]: https://github.com/Gallopsled/pwntools/pull/2391
8991

9092
## 4.13.0 (`beta`)
9193

pwnlib/util/fiddling.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,19 @@ def xor(*args, **kwargs):
320320
The string of the arguments xor'ed together.
321321
322322
Example:
323+
323324
>>> xor(b'lol', b'hello', 42)
324325
b'. ***'
326+
>>> xor(cut = 'min', other = '')
327+
Traceback (most recent call last):
328+
...
329+
TypeError: xor() got an unexpected keyword argument 'other'
325330
"""
326331

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

329334
if kwargs != {}:
330-
raise TypeError("xor() got an unexpected keyword argument '%s'" % kwargs.pop()[0])
335+
raise TypeError("xor() got an unexpected keyword argument '%s'" % kwargs.popitem()[0])
331336

332337
if len(args) == 0:
333338
raise ValueError("Must have something to xor")

0 commit comments

Comments
 (0)