Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

float("INFI") returns inf on certain platforms #52154

Closed
csernazs mannequin opened this issue Feb 11, 2010 · 8 comments
Closed

float("INFI") returns inf on certain platforms #52154

csernazs mannequin opened this issue Feb 11, 2010 · 8 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@csernazs
Copy link
Mannequin

csernazs mannequin commented Feb 11, 2010

BPO 7906
Nosy @rhettinger, @csernazs, @mdickinson, @ericvsmith, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2010-02-11.18:58:47.123>
created_at = <Date 2010-02-11.13:40:31.616>
labels = ['interpreter-core', 'type-bug']
title = 'float("INFI") returns inf on certain platforms'
updated_at = <Date 2010-02-12.13:10:49.734>
user = 'https://github.com/csernazs'

bugs.python.org fields:

activity = <Date 2010-02-12.13:10:49.734>
actor = 'r.david.murray'
assignee = 'none'
closed = True
closed_date = <Date 2010-02-11.18:58:47.123>
closer = 'rhettinger'
components = ['Interpreter Core']
creation = <Date 2010-02-11.13:40:31.616>
creator = 'csernazs'
dependencies = []
files = []
hgrepos = []
issue_num = 7906
keywords = []
message_count = 8.0
messages = ['99206', '99214', '99228', '99232', '99234', '99258', '99261', '99264']
nosy_count = 5.0
nosy_names = ['rhettinger', 'csernazs', 'mark.dickinson', 'eric.smith', 'r.david.murray']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue7906'
versions = ['Python 2.6']

@csernazs
Copy link
Mannequin Author

csernazs mannequin commented Feb 11, 2010

Python 2.6.4
On my system which is solaris 8/sparc, float("INFI") returns inf instead of raising ValueError, both 32 and 64-bit. (since it's case-insensitive it applies to any upper/lower combination of letters).

This issue breaks test_float regression test which has a test for that value and it expects ValueError.

Doing some research and debugging showed me that strtod(const char *str, char **endptr) function behaves differently on solaris 8 than linux.
On solaris it stores \0 in **endptr meaning that it processed the string completely - and that's the reason why python doesn't raise ValueError.
On linux, strtod() stores 'I' in **endptr, and it results the ValueError.

With python 2.6.1 there's no such issue.

@csernazs csernazs mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Feb 11, 2010
@mdickinson
Copy link
Member

Thanks for the report, and for the analysis.

I'd call this a bug in the Solaris strtod function (though that doesn't preclude adding a workaround for Python): the C standards (well, C99, anyway; I don't have access to C89 at the moment) enumerate clearly which strings are permitted, and "INFI" isn't among them.

string <-> float conversions got significantly reworked for Python 2.7 and 3.1, so there shouldn't be any problem with those versions. Are you in a position to confirm this?

It would be fairly easy to work around this strtod issue by backporting the _Py_parse_inf_or_nan and case_insensitive match functions (in Python/pystrtod.c) from trunk to Python 2.6, and using those functions in PyOS_ascii_strtod.

@csernazs
Copy link
Mannequin Author

csernazs mannequin commented Feb 11, 2010

I was not able to compile 3.1.1 due to bpo-6236, but with 2.7a3 it raises the expected ValueError, which is correct.

Is there any chance to get those changes you mentioned backported to 2.6?

@mdickinson
Copy link
Member

Is there any chance to get those changes you mentioned backported to 2.6?

Actually, to be honest, I'm not sure that backporting these changes to the release branch is a good idea. Is this bug causing problems in real code (besides the test suite)?

It seems to me that this bug is fairly harmless, and the backport of the 2.7 behaviour could have unintended consequences (seems unlikely, but it's always difficult to be sure :); I'm tempted suggest closing it as a 'won't fix', especially given that it's already fixed in 2.7.

@rhettinger
Copy link
Contributor

I concur with Mark.

@csernazs
Copy link
Mannequin Author

csernazs mannequin commented Feb 12, 2010

This issue doesn't seem to cause any problems in our production code, however I haven't tested it.

Btw what is the status of the solaris support? According to wiki page it should be supported by python, in real it seems it's not really supported (I mean not just this bug, but others related to solaris).

@ericvsmith
Copy link
Member

I agree that backporting the various parts needed to get this working would be risky and shouldn't be done.

As for Solaris sure, I'm not sure. You might ask on python-dev. I get the impression that few (if any) core developers have access to a Solaris machine.

@bitdancer
Copy link
Member

My feeling from watching bug reports is that Solaris is no less well supported than other non-linux, non-windows platforms. When you look at the number of open Solaris bug reports, also consider the number of open bug reports over all. We just don't have enough developer resources to close them all :( And yes, developer access to appropriate test systems is one of the big issues.

If you have time to actively participate in resolving Solaris bugs by testing and proposing patches, my guess is you will get cooperation (and gratitude) from the dev team.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants