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/2008-January/075845.html below:

[Python-Dev] long(float('nan')) conversion

[Python-Dev] long(float('nan')) conversion [Python-Dev] long(float('nan')) conversionChristian Heimes lists at cheimes.de
Fri Jan 4 14:07:14 CET 2008
Hello!

Bug http://bugs.python.org/issue1481296 describes a problem where
long(float('nan')) causes a seg fault on Mac OS X. On other platforms it
returns 0L, e.g.

Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> float('nan')
nan
>>> long(float('nan'))
0L

My patch to Python 2.6 adds an explicit check for NaNs to always return
0L. It did feel a bit strange but it's the default on some platforms.
Today an user pointed out that he doesn't like the patch, too.

How should the problem be solved? In my humble opinion
long(float('nan')) should return 0L in Python 2.5.2 for b/w
compatibility and raise a ValueError or OverflowError in Python 2.6+.

Christian

More information about the Python-Dev mailing list

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