This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pystone.main(10) causes ZeroDivisionError
Type: behavior Stage:
Components: Library (Lib), Tests Versions: Python 3.0, Python 2.6, Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, mokeefe
Priority: normal Keywords: patch

Created on 2008-07-08 08:44 by mokeefe, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pystone_1_py3k.diff mokeefe, 2008-07-09 04:11 patch for python 3.0 on Lib/test/pystone.py
pystone_1_trunk.diff mokeefe, 2008-07-09 04:11 patch for python 2.6 trunk to Lib/test/pystone.py
pystone_err.py mokeefe, 2008-07-09 04:12 file to demonstrate the ZeroDivisionError
Messages (4)
msg69418 - (view) Author: Michael Patrick O'Keefe (mokeefe) Date: 2008-07-08 08:44
The following call results in a ZeroDivisionError in python 2.5.2 and
python 3.0 alpha 3 (I presume this is also an issue for Python 2.6 but I
can't explicitly confirm):

>>> from test import pystone
>>> pystone.main(10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/test/pystone.py",
line 61, in main
    benchtime, stones = pystones(loops)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/test/pystone.py",
line 68, in pystones
    return Proc0(loops)
  File
"/opt/local/Library/Frameworks/Python.framework/Versions/3.0/lib/python3.0/test/pystone.py",
line 131, in Proc0
    return benchtime, (loops / benchtime)
ZeroDivisionError: float division

Note the patch I submitted checks if the benchtime is equal to 0.0
(which apparently happens on my Mac OS 10.5 PPC). If this is the case I
arbitrarily set the benchtime to 1e-6. I'm not sure what the units of
the benchtime variable is (seconds?). Anyhow, this fixes the issue but
can someone review to confirm this is the correct behavior?

Thanks!

-Michael
msg69420 - (view) Author: Michael Patrick O'Keefe (mokeefe) Date: 2008-07-08 09:02
I'm resubmitting the patch -- I think this one's a little bit better
than my first attempt. I only change the value of loops / benchtime
msg69456 - (view) Author: Michael Patrick O'Keefe (mokeefe) Date: 2008-07-09 04:11
After a more careful study of the documentation on how to make (proper)
patches, I'm submitting the patches again. This patches against the 2.6
trunk and py3k branch (R64812). I compiled both 2.6 and py3k and
confirmed that the ZeroDivisionError does not appear for both sets of code.
msg70017 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-07-19 13:00
Thanks, fixed in trunk in r65135, will be merged to Py3k automatically.
History
Date User Action Args
2022-04-11 14:56:36adminsetgithub: 47569
2008-07-19 13:00:42georg.brandlsetstatus: open -> closed
nosy: + georg.brandl
messages: + msg70017
resolution: fixed
2008-07-09 04:12:47mokeefesetfiles: + pystone_err.py
2008-07-09 04:11:57mokeefesetfiles: + pystone_1_trunk.diff
2008-07-09 04:11:16mokeefesetfiles: + pystone_1_py3k.diff
messages: + msg69456
versions: + Python 2.6
2008-07-09 04:02:31mokeefesetfiles: - pystone.py.patch
2008-07-08 09:02:32mokeefesetfiles: + pystone.py.patch
keywords: + patch
messages: + msg69420
2008-07-08 08:56:11mokeefesetfiles: - pystone_patch.txt
2008-07-08 08:44:05mokeefecreate