[issue2778] set_swap_bodies is unsafe
Adam Olsen
report at bugs.python.org
Tue May 13 08:31:17 CEST 2008
Adam Olsen <rhamph at gmail.com> added the comment:
Here's another approach to avoiding set_swap_bodies. The existing
semantics are retained. Rather than creating a temporary frozenset and
swapping the contents, I check for a set and call the internal hash
function directly (bypassing PyObject_Hash).
I even retain the current semantics of PySet_Discard and PySet_Contains,
which do NOT do the implicit conversion (and have unit tests to verify
that!)
I do have some concern that calling PySet_Check on every call may be too
slow. It may be better to only call it on failure (which is
more-or-less what the old code did.)
set_swap_bodies has only one remaining caller, and their use case could
probably be significantly simplified.
Added file: http://bugs.python.org/file10315/python-setswap-2.diff
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2778>
__________________________________
More information about the Python-bugs-list
mailing list