Skip to content

Commit b0d6dcf

Browse files
authored
safeeval: allow LIST_APPEND and SET_ADD opcodes (Python 3.14) (#2722)
* safeeval: allow LIST_APPEND and SET_ADD opcodes (Python 3.14) * changelog: add entry for #2722 (safeeval Python 3.14 opcodes) * ci: retrigger after transient libcdb network failure --------- Co-authored-by: Chris (ChrisJr404) <11917633+ChrisJr404@users.noreply.github.com>
1 parent 52a354b commit b0d6dcf

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ The table below shows which release corresponds to each branch, and what date th
130130
- [#2713][2713] Remove python-dateutil dependency
131131
- [#2720][2720] ssh: resolve PermissionError on Windows during SFTP upload
132132
- [#2702][2702] ssh: Don't cache username in ssh checksec output
133+
- [#2722][2722] safeeval: allow LIST_APPEND and SET_ADD opcodes (Python 3.14)
133134

134135
[2675]: https://github.com/Gallopsled/pwntools/pull/2675
135136
[2652]: https://github.com/Gallopsled/pwntools/pull/2652
@@ -185,6 +186,7 @@ The table below shows which release corresponds to each branch, and what date th
185186
[2713]: https://github.com/Gallopsled/pwntools/pull/2713
186187
[2720]: https://github.com/Gallopsled/pwntools/pull/2720
187188
[2702]: https://github.com/Gallopsled/pwntools/pull/2702
189+
[2722]: https://github.com/Gallopsled/pwntools/pull/2722
188190

189191
## 4.15.1
190192

pwnlib/util/safeeval.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'BUILD_LIST','BUILD_MAP', 'MAP_ADD', 'BUILD_TUPLE','BUILD_SET',
44
'BUILD_CONST_KEY_MAP', 'BUILD_STRING',
55
'LOAD_CONST','LOAD_SMALL_INT','RETURN_VALUE','STORE_SUBSCR', 'STORE_MAP',
6-
'LIST_TO_TUPLE', 'LIST_EXTEND', 'SET_UPDATE', 'DICT_UPDATE', 'DICT_MERGE',
6+
'LIST_TO_TUPLE', 'LIST_APPEND', 'LIST_EXTEND', 'SET_ADD', 'SET_UPDATE', 'DICT_UPDATE', 'DICT_MERGE',
77
'COPY', 'RESUME', 'RETURN_CONST'
88
]
99

@@ -69,6 +69,10 @@ def const(expr):
6969
Traceback (most recent call last):
7070
...
7171
ValueError: opcode BINARY_ADD not allowed
72+
>>> const("[" + ",".join(str(i) for i in range(40)) + "]") == list(range(40))
73+
True
74+
>>> const("{" + ",".join(str(i) for i in range(40)) + "}") == set(range(40))
75+
True
7276
"""
7377

7478
c = test_expr(expr, _const_codes)

0 commit comments

Comments
 (0)