A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2002-June/026000.html below:

[Python-Dev] list.extend

[Python-Dev] list.extendTim Peters tim.one@comcast.net
Fri, 28 Jun 2002 01:20:17 -0400
[David Abrahams]
> As long as I'm eyeballin' (and you're thankin'), I notice in PyInt_AsLong:
>
>  if (op == NULL || (nb = op->ob_type->tp_as_number) == NULL ||
>      nb->nb_int == NULL) {
>     PyErr_SetString(PyExc_TypeError, "an integer is required");
>   return -1;
>  }
>
> But really, an integer isn't required; Any type with a
> tp_as_number section and a conversion to int will do. Should the
> error say "a numeric type convertible to int is required"?

I'll leave it up to Fred, but I don't think so.  The suggestion is wordier,
would be wordier still if converted to the more accurate "an object of a
numeric type convertible to int is required", and even then is not, IMO,
more likely to be of real help when this error triggers.  If you want to
change it, be sure to hunt down all the related ones too; e.g.,

>>> class C: pass
>>> range(12)[C()]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: list indices must be integers
>>>

BTW, most places that call PyInt_AsLong() either do so conditionally upon
the success of a PyInt_Check(), or replace the exception raised when it
returns -1 with an error.  Offhand I wasn't even able to provoke the msg in
question.





RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4