[2.7] bpo-28315: Improve code examples in docs (GH-1372) (#1447)
Replace
File "<stdin>", line 1, in ?
with
File "<stdin>", line 1, in <module>.
(cherry picked from commit 8856940cf2e82cb17db2b684cd5732fe658605ca)
diff --git a/Doc/extending/newtypes.rst b/Doc/extending/newtypes.rst
index ebeca05..5959e4f 100644
--- a/Doc/extending/newtypes.rst
+++ b/Doc/extending/newtypes.rst
@@ -127,7 +127,7 @@
>>> "" + noddy.new_noddy()
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
TypeError: cannot add type "noddy.Noddy" to string
Note that the name is a dotted name that includes both the module name and the
diff --git a/Doc/howto/functional.rst b/Doc/howto/functional.rst
index ee9a5f6d..a06e29c 100644
--- a/Doc/howto/functional.rst
+++ b/Doc/howto/functional.rst
@@ -207,7 +207,7 @@
3
>>> it.next()
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
StopIteration
>>>
@@ -477,7 +477,7 @@
2
>>> gen.next()
Traceback (most recent call last):
- File "stdin", line 1, in ?
+ File "stdin", line 1, in <module>
File "stdin", line 2, in generate_ints
StopIteration
@@ -581,7 +581,7 @@
9
>>> print it.next()
Traceback (most recent call last):
- File "t.py", line 15, in ?
+ File "t.py", line 15, in <module>
print it.next()
StopIteration
diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
index 052cdee..df9ccbf 100644
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -87,7 +87,7 @@
<_FuncPtr object at 0x...>
>>> print windll.kernel32.MyOwnFunction # doctest: +WINDOWS
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
File "ctypes.py", line 239, in __getattr__
func = _StdcallFuncPtr(name, self)
AttributeError: function 'MyOwnFunction' not found
@@ -126,7 +126,7 @@
<_FuncPtr object at 0x...>
>>> cdll.kernel32[0] # doctest: +WINDOWS
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
File "ctypes.py", line 310, in __getitem__
func = _StdcallFuncPtr(name, self)
AttributeError: function ordinal 0 not found
@@ -159,11 +159,11 @@
>>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ValueError: Procedure probably called with not enough arguments (4 bytes missing)
>>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
>>>
@@ -172,13 +172,13 @@
>>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ValueError: Procedure probably called with not enough arguments (4 bytes missing)
>>>
>>> windll.msvcrt.printf("spam") # doctest: +WINDOWS
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
>>>
@@ -191,7 +191,7 @@
>>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
WindowsError: exception: access violation reading 0x00000020
>>>
@@ -354,7 +354,7 @@
19
>>> printf("%f bottles of beer\n", 42.5)
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ArgumentError: argument 2: exceptions.TypeError: Don't know how to convert parameter 2
>>>
@@ -417,7 +417,7 @@
>>> printf("%d %d %d", 1, 2, 3)
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ArgumentError: argument 2: exceptions.TypeError: wrong type
>>> printf("%s %d %f\n", "X", 2, 3)
X 2 3.000000
@@ -467,7 +467,7 @@
'def'
>>> strchr("abcdef", "def")
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ArgumentError: argument 2: exceptions.TypeError: one character string expected
>>> print strchr("abcdef", "x")
None
@@ -493,7 +493,7 @@
486539264
>>> GetModuleHandle("something silly") # doctest: +WINDOWS
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in ValidHandle
WindowsError: [Errno 126] The specified module could not be found.
>>>
@@ -564,7 +564,7 @@
0 5
>>> POINT(1, 2, 3)
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ValueError: too many initializers
>>>
@@ -767,7 +767,7 @@
<class 'ctypes.LP_c_long'>
>>> PI(42)
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
TypeError: expected c_long instead of int
>>> PI(c_int(42))
<ctypes.LP_c_long object at 0x...>
@@ -843,7 +843,7 @@
>>> bar.values = (c_byte * 4)()
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
TypeError: incompatible types, c_byte_Array_4 instance instead of LP_c_long instance
>>>
@@ -894,7 +894,7 @@
... ("next", POINTER(cell))]
...
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
File "<stdin>", line 2, in cell
NameError: name 'cell' is not defined
>>>
diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst
index b31d620..cf67b23 100644
--- a/Doc/library/doctest.rst
+++ b/Doc/library/doctest.rst
@@ -425,7 +425,7 @@
>>> [1, 2, 3].remove(42)
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ValueError: list.remove(x): x not in list
That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x):
@@ -449,7 +449,7 @@
>>> raise ValueError('multi\n line\ndetail')
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ValueError: multi
line
detail
@@ -607,7 +607,7 @@
>>> (1, 2)[3] = 'moo'
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
TypeError: object doesn't support item assignment
passes under Python 2.3 and later Python versions with the flag specified,
diff --git a/Doc/library/fpectl.rst b/Doc/library/fpectl.rst
index 8ca671b..d48b820 100644
--- a/Doc/library/fpectl.rst
+++ b/Doc/library/fpectl.rst
@@ -88,7 +88,7 @@
>>> import math
>>> math.exp(1000)
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
FloatingPointError: in math_1
diff --git a/Doc/library/pdb.rst b/Doc/library/pdb.rst
index 9177f95..33d7750 100644
--- a/Doc/library/pdb.rst
+++ b/Doc/library/pdb.rst
@@ -70,7 +70,7 @@
>>> import mymodule
>>> mymodule.test()
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
File "./mymodule.py", line 4, in test
test2()
File "./mymodule.py", line 3, in test2
diff --git a/Doc/library/unicodedata.rst b/Doc/library/unicodedata.rst
index a3a7c96..d7c48c4 100644
--- a/Doc/library/unicodedata.rst
+++ b/Doc/library/unicodedata.rst
@@ -161,7 +161,7 @@
9
>>> unicodedata.decimal(u'a')
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ValueError: not a decimal
>>> unicodedata.category(u'A') # 'L'etter, 'u'ppercase
'Lu'
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 97975ce..8556fa8 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -767,7 +767,7 @@
2 1
>>> f(a=1, *(2,))
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
TypeError: f() got multiple values for keyword argument 'a'
>>> f(1, *(2,))
1 2
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index 963581b..216dcae 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -787,7 +787,7 @@
'c'
>>> it.next()
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
it.next()
StopIteration
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index e1ac89f..a264bd7 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -444,7 +444,7 @@
...
>>> function(0, a=0)
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
TypeError: function() got multiple values for keyword argument 'a'
When a final formal parameter of the form ``**name`` is present, it receives a
diff --git a/Doc/tutorial/datastructures.rst b/Doc/tutorial/datastructures.rst
index 916da4a..4e60e32 100644
--- a/Doc/tutorial/datastructures.rst
+++ b/Doc/tutorial/datastructures.rst
@@ -311,7 +311,7 @@
[(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]
>>> # the tuple must be parenthesized, otherwise an error is raised
>>> [x, x**2 for x in range(6)]
- File "<stdin>", line 1
+ File "<stdin>", line 1, in <module>
[x, x**2 for x in range(6)]
^
SyntaxError: invalid syntax
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index 3e32af2..d354246 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -340,7 +340,7 @@
>>> f.close()
>>> f.read()
Traceback (most recent call last):
- File "<stdin>", line 1, in ?
+ File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
It is good practice to use the :keyword:`with` keyword when dealing with file