[New-bugs-announce] [issue12909] Inconsistent exception usage in PyLong_As* C functions

Nadeem Vawda report at bugs.python.org
Tue Sep 6 09:40:18 CEST 2011


New submission from Nadeem Vawda <nadeem.vawda at gmail.com>:

The C functions for converting a Python 'int' object to a C integer are
inconsistent about what exception gets raised when the object passed to
them is not an integer. Most of these functions raise a TypeError, but
PyLong_AsUnsignedLongLong() and PyLong_AsDouble() raise a SystemError
instead.

Raising a SystemError here is quite unhelpful. My understanding is that
it is intended to indicate internal programming errors, so an extension
module should not raise one when (for example) a function is passed an
argument of the incorrect type. In such a case, raising a TypeError is a
reasonable default.

Is there any reason not to change the behaviour of these two functions to
be consistent with their siblings?

----------
components: Interpreter Core
messages: 143588
nosy: nadeem.vawda, pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: Inconsistent exception usage in PyLong_As* C functions
type: behavior
versions: Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12909>
_______________________________________


More information about the New-bugs-announce mailing list