New submission from Nadeem Vawda <nadeem.va...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue12909>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to