Mercurial > hg
diff mercurial/diffhelpers.c @ 24624:6f0e6fa9fdd7
dirs._addpath: don't mutate Python strings after exposing them (issue4589)
One of the rules of Python strings is that they're immutable. dirs._addpath
breaks this assumption for performance, which is fine as long as it is done
safely -- once a string is no longer internal-only it shouldn't be mutated.
Unfortunately, we weren't being safe here -- we were mutating 'key' even after
adding it to a dictionary.
This only really affects other C code that reads strings, so it's somewhat hard
to write a test for this without poking into the internal representation of the
string via ctypes or similar. There is currently no C code that reads the
output of the string, but there will likely be some soon as the bug indicates.
There's no significant difference in performance.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 06 Apr 2015 10:46:44 -0700 |
parents | f1c127df7c4f |
children | 2f51f4c535d2 |