This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: fix inplace string concat hash error
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: rhettinger, rthalley
Priority: normal Keywords: patch

Created on 2004-10-25 23:22 by rthalley, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
hash.patch rthalley, 2004-10-25 23:22
Messages (2)
msg47146 - (view) Author: Bob Halley (rthalley) Date: 2004-10-25 23:22
This is a fix for #1054139. 
 
The problem was that the fast path in the new 
higher-performance string concatenation code in ceval.c 
didn't invalide the cached hash value. 
 
My patch makes it set ob_shash to -1, and ob_sstate = 
SSTATE_NOT_INTERNED, just like what would happen if the 
slow path through PyString_Concat(&v, w) was used. 
 
/Bob 
 
msg47147 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-10-26 01:57
Logged In: YES 
user_id=80475

Thanks for the patch.

I applied a more generic fix. Now, _PyString_Resize()
invalidates the cached hash value on each call.

Also, both the code in ceval.c and the code in
_PyString_Resize already had guards to check ob_sstate, so
no changes were needed for that field.

See:
   Objects/stringobject.c 2.226
   Lib/test/string_tests.py 1.42
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 41080
2004-10-25 23:22:28rthalleycreate