[New-bugs-announce] [issue28315] incorrect "in ?" output in 'divide' example at "Defining Clean-up Actions" in tutorial

Viorel Tabara report at bugs.python.org
Thu Sep 29 20:17:25 EDT 2016


New submission from Viorel Tabara:

At https://docs.python.org/3.5/tutorial/errors.html#defining-clean-up-actions 
when I'm running the "divide('2', '1')" example I get:

  File "<stdin>", line 1, in <module>

instead of the documentation output of:

   File "<stdin>", line 1, in ? 

The same message is included with the 2.7 tutorial.

To wit:

   $ python3
   Python 3.5.2 (default, Sep 14 2016, 11:28:32)
   [GCC 6.2.1 20160901 (Red Hat 6.2.1-1)] on linux
   Type "help", "copyright", "credits" or "license" for more information.
   >>> def divide(x, y):
   ...     try:
   ...             result = x / y
   ...     except ZeroDivisionError:
   ...             print('division by zero!')
   ...     else:
   ...             print('result is', result)
   ...     finally:
   ...             print('executing finally clause')
   ...
   >>> divide(2, 1)
   result is 2.0
   executing finally clause
   >>> divide(2, 0)
   division by zero!
   executing finally clause
   >>> divide('2', '1')
   executing finally clause
   Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<stdin>", line 3, in divide
   TypeError: unsupported operand type(s) for /: 'str' and 'str'


   $ python2
   Python 2.7.12 (default, Sep  2 2016, 15:40:50)
   [GCC 6.2.1 20160901 (Red Hat 6.2.1-1)] on linux2
   Type "help", "copyright", "credits" or "license" for more information.
   >>> def divide(x, y):
   ...     result = x / y
   KeyboardInterrupt
   >>> def divide(x, y):
   ...     try:
   ...             result = x / y
   ...     except ZeroDivisionError:
   ...             print('division by zero!')
   ...     else:
   ...             print('result is', result)
   ...     finally:
   ...             print('executing finally clause')
   ...
   >>> divide(2, 1)
   ('result is', 2)
   executing finally clause
   >>> divide(2, 0)
   division by zero!
   executing finally clause
   >>> divide('2', '1')
   executing finally clause
   Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "<stdin>", line 3, in divide
   TypeError: unsupported operand type(s) for /: 'str' and 'str'
  

Nice tutorial by the way ;) Thanks!

----------
assignee: docs at python
components: Documentation
messages: 277731
nosy: docs at python, viorel
priority: normal
severity: normal
status: open
title: incorrect "in ?" output in 'divide' example at "Defining Clean-up Actions" in tutorial
type: behavior
versions: Python 2.7, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28315>
_______________________________________


More information about the New-bugs-announce mailing list