[issue15815] Add numerator to ZeroDivisionError messages

2012-09-26 Thread Ezio Melotti

Ezio Melotti added the comment:

Terry, do you still think that adding the numerator would be useful?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15815] Add numerator to ZeroDivisionError messages

2012-09-26 Thread Mark Dickinson

Mark Dickinson added the comment:

I'll add my -1 to this;  I don't really see the use.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15815] Add numerator to ZeroDivisionError messages

2012-09-26 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Not enough, at present, to leave this open.

--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15815] Add numerator to ZeroDivisionError messages

2012-08-31 Thread Ezio Melotti

Ezio Melotti added the comment:

I'm not sure this is really useful.  Once I know that I divided by zero and I 
know where the division is, I don't really care what the numerator is.  Knowing 
the exact type of the denominator (0, 0.0, 0j) doesn't sound too useful as well 
-- unless you somehow manage to get the wrong type and a 0-value at the same 
time.

On a side note, I don't like
ZeroDivisionError: integer division or modulo of 3 by 0
too much, but I would prefer
ZeroDivisionError: integer division (or modulo) by zero
over
ZeroDivisionError: integer division or modulo by zero

IIRC the reason why both division and modulo are included in the message is 
because the error is created in a piece of code that is shared by both 
operations.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15815] Add numerator to ZeroDivisionError messages

2012-08-29 Thread Terry J. Reedy

New submission from Terry J. Reedy:

I propose that we add 'of ' to all ZeroDivisionError messagesso it is less 
necessary to use a debugger to add print statements to recover the information 
currently tossed away. (I also propose to change denominator from 'zero' to 
'0', '0.0', '0+0j', as appropriate.) 

 3//0
...
ZeroDivisionError: integer division or modulo by zero

# augment to
ZeroDivisionError: integer division or modulo of 3 by 0

Similarly for

 3 / 0
ZeroDivisionError: division by zero

# perhaps this should be 'true division of 3 by 0'

 3.0 / 0.0
ZeroDivisionError: float division by zero

 (3+3j) / (0+0j)
ZeroDivisionError: complex division by zero

In #7482 it was proposed to make float and complex messages same as int message 
by adding 'or modulo'. I an not sure why not to do that, or if it was just 
deferred.

Fractions currently print the numerator as part of an invalid numerator / 0 
result from *either* construction or division.

 from fractions import Fraction as F
 F(3, 0)
Traceback (most recent call last):
  File pyshell#20, line 1, in module
F(3, 0)
  File C:\Programs\Python33\lib\fractions.py, line 167, in __new__
raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
ZeroDivisionError: Fraction(3, 0)

# Here, 'Fraction(3, 0)' is invalid input.

 F(3, 1) / F(0, 1)
Traceback (most recent call last):
  File pyshell#19, line 1, in module
F(3, 1) / F(0, 1)
  File C:\Programs\Python33\lib\fractions.py, line 367, in forward
return monomorphic_operator(a, b)
  File C:\Programs\Python33\lib\fractions.py, line 417, in _div
a.denominator * b.numerator)
  File C:\Programs\Python33\lib\fractions.py, line 167, in __new__
raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
ZeroDivisionError: Fraction(3, 0)

# Here, 'Fraction(3, 0)' is invalid output.
I found this confusing until I worked out the dual meaning. I think

ZeroDevisionError: invalid Fraction(3, 0) from construction or division

might be a bit clearer.

I have not looked at decimals.

--
components: Interpreter Core
messages: 169410
nosy: ezio.melotti, mark.dickinson, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: Add numerator to ZeroDivisionError messages
type: enhancement
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15815] Add numerator to ZeroDivisionError messages

2012-08-29 Thread Antoine Pitrou

Antoine Pitrou added the comment:

What would be the point? Usually you should find out why the denominator is 
zero, not what the numerator's value is.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15815] Add numerator to ZeroDivisionError messages

2012-08-29 Thread Terry J. Reedy

Terry J. Reedy added the comment:

In case the value of the numerator helps find out why the denominator is 0. The 
example given by Mike Graham on python-ideas, Verbose traceback formatting was

def f(a):
x = a * 4
y = a - 4
return x / y

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15815] Add numerator to ZeroDivisionError messages

2012-08-29 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 In case the value of the numerator helps find out why the denominator
 is 0. The example given by Mike Graham on python-ideas, Verbose
 traceback formatting was
 
 def f(a):
 x = a * 4
 y = a - 4
 return x / y

Well, in this case y == 0 iff a == 4. I don't see how the numerator
helps at all.
(and besides, it's a rather silly artificial example)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15815
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com