➜

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.

作者 skrah
收信人 ezio.melotti, georg.brandl, lemburg, skrah
日期 2011-02-10.19:25:16
SpamBayes Score 1.446046e-07
Marked as misclassified 否
Message-id <20110210192449.GA5470@sleipnir.bytereef.org>
In-reply-to <1297330831.08.0.0747559116298.issue11167@psf.upfronthosting.co.za>
内容
Marc-Andre Lemburg <report@bugs.python.org> wrote:
> 
> Marc-Andre Lemburg <mal@egenix.com> added the comment:
> 
> Could you try the same in Python 2.7 ?

It's the same, just in stringobject.c. Many hash functions have this issue.

> The overflow is intended (after all, it's a hash function), but we should
> probably add a cast to Py_hash_t to the hash building line in order to make
> the compiler aware of this.

I think I'd just do the hash calculation in unsigned and cast at the end
of the function. For the conversion from unsigned to signed we'd still
rely on implementation defined behavior [1], but at least the signed
integer overflow would be gone.

[1] Mark Dickinson made an effort to document assumptions for unsigned
to signed conversions. I don't know if this has found its way it into
the developer docs:

http://mail.python.org/pipermail/python-dev/2009-December/094388.html
历史
日期 用户 动作 参数
2011-02-10 19:25:17skrah修改recipients: + skrah, lemburg, georg.brandl, ezio.melotti
2011-02-10 19:25:16skrah链接issue11167 messages
2011-02-10 19:25:16skrah创建