[issue22238] fractions.gcd results in infinite loop when nan or inf given as parameter.
Changes by Mark Dickinson dicki...@gmail.com: -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22238 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22238] fractions.gcd results in infinite loop when nan or inf given as parameter.
Mark Dickinson added the comment: I agreed with Raymond. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22238 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22238] fractions.gcd results in infinite loop when nan or inf given as parameter.
New submission from Robert Snoeberger: import fractions fractions.gcd(16, float('inf')) Traceback (most recent call last): File pyshell#1, line 1, in module fractions.gcd(16, float('inf')) File C:\Python34-32bit\lib\fractions.py, line 24, in gcd a, b = b, a%b KeyboardInterrupt fractions.gcd(16, float('nan')) Traceback (most recent call last): File pyshell#2, line 1, in module fractions.gcd(16, float('nan')) File C:\Python34-32bit\lib\fractions.py, line 24, in gcd a, b = b, a%b KeyboardInterrupt With the iterative algorithm that is used a, b = b, a%b b converges to float('nan'). It will never become 0 to break out of the loop. It might be nice to error when the iteration has converged b to a value other than 0. -- components: Library (Lib) messages: 225576 nosy: snoeberger priority: normal severity: normal status: open title: fractions.gcd results in infinite loop when nan or inf given as parameter. type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22238 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22238] fractions.gcd results in infinite loop when nan or inf given as parameter.
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +mark.dickinson, rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22238 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22238] fractions.gcd results in infinite loop when nan or inf given as parameter.
Raymond Hettinger added the comment: I don't think this is an actual problem in practice and isn't worth mucking up clear and beautiful code. -- priority: normal - low ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22238 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22238] fractions.gcd results in infinite loop when nan or inf given as parameter.
Raymond Hettinger added the comment: Also note that the fractions module is primarily about rational numbers (integer ratios). The int type has no concept of NaNs and Infs, so I don't see any reason why the fractions module should cater to them. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22238 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com