[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] BUG: UintFromObj from base.c does not check for errors
- To: pygame-users@xxxxxxxx
- Subject: [pygame] BUG: UintFromObj from base.c does not check for errors
- From: Devan <devlai@xxxxxxxxx>
- Date: Sun, 31 Aug 2008 13:08:48 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sun, 31 Aug 2008 16:08:52 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=wOKl7Jr1x66zpr1c+98/L6PDoh9CtNsNLwKY5hNO0YM=; b=t76iPQNcX1RNerR90PN/UrGGBf/figYXs5FBD7CL6y3pMoae2xVl398h1MHpLZVY1u V4Xg+Vqf/bdQmWc2ZD+2PzjtpFwZUus1FH56PdbFOT3e2LKJM0AnlAab/2woDwK7F7Gn NtGEZhUN9P0nlp3sX1W6zczTddS/nVYGHYFOU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=bJzd8L2h/aaZgU2LqwURZW5q+7/kK7IeylDl9Ff0ubE5Eb02SRzIF+zZYvZw5M0M8i /bRsn5nrg4tGgxK72IcjASeMA6YnyQwhByj4Q2ohefbDW6ihYsLsgYRtIlQbgOeSzrgq SRdvBqd3qxSzOEOsOcRJfCcYyCCXUSLzjH8ng=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hi,
It appears that the utility function UintFromObj does not check if an
error has occurred after calling PyInt_AsLong. If an error (namely an
overflow error if the object is actually a long) occured, then it is
silently ignored until the next call to PyErr_Occurred. In my case
this propped up while working on an extension module that caught an
OverflowError on a subsequent call.
If there is a specific reason for ignoring any errors (IntFromObj
seems to explicitly clear any errors and return 0 instead), then I
think the best thing would be to replace PyInt_AsLong with the macro
PyInt_AS_LONG which does not do error checking and will not leave an
exception hanging around.
Thanks,
- Devan.
PS: I ran into this while trying using surface.convert(masks). Is
there a better way to create the masks than x |= (1 << 0) | (1 << 1) |
(1 << 2)... | (1 <<7) ?