Hacker News new | ask | show | jobs
by lisael 2875 days ago
FWIW Pypy used to share this behaviour. It was clearly a bug, as it doesn't follow CPython convention.

It's around since 2013 and was found in a unit test coverage improvement effort in Feb. 2018.

Given that pypy is mostly used for hard-core math and scientific computations, how the hell this bug wasn't found earlier by a user ?

My bet is that ZeroDivisionErrors are very rare. Do you even remember a ZeroDivisionError in production code ? I don't.

1/0 is my dirty little trick to add a breakpoint when I'm too lazy to launch a debuger. Why does this work? Here again, because nobody never catch ZeroDivisionErrors, because they don't happen.

So, what a fuss for such a tiny convention. Granted, it breaks the math correctness, as do ±Infinity. CPU integer math is broken anyway. In what world does 2^31 - 1 + 1 == -2^31 ?

I took a fairly large, used and old repository, Django and I search for ZeroDivisionError:

https://github.com/django/django/search?q=ZeroDivisionError&...

guess what:

- 4 occurrences in the tests

- 3 occurences in the issues

- last, but not least 1 occurrence in the code:

   except ZeroDivisionError:
       result = '0'