Skip to content

Commit e1b02ff

Browse files
authored
[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 8856940)
1 parent 74f0db8 commit e1b02ff

File tree

12 files changed

+30
-30
lines changed

12 files changed

+30
-30
lines changed

Doc/extending/newtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ our objects and in some error messages, for example::
127127

128128
>>> "" + noddy.new_noddy()
129129
Traceback (most recent call last):
130-
File "<stdin>", line 1, in ?
130+
File "<stdin>", line 1, in <module>
131131
TypeError: cannot add type "noddy.Noddy" to string
132132

133133
Note that the name is a dotted name that includes both the module name and the

Doc/howto/functional.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ You can experiment with the iteration interface manually:
207207
3
208208
>>> it.next()
209209
Traceback (most recent call last):
210-
File "<stdin>", line 1, in ?
210+
File "<stdin>", line 1, in <module>
211211
StopIteration
212212
>>>
213213

@@ -477,7 +477,7 @@ Here's a sample usage of the ``generate_ints()`` generator:
477477
2
478478
>>> gen.next()
479479
Traceback (most recent call last):
480-
File "stdin", line 1, in ?
480+
File "stdin", line 1, in <module>
481481
File "stdin", line 2, in generate_ints
482482
StopIteration
483483

@@ -581,7 +581,7 @@ And here's an example of changing the counter:
581581
9
582582
>>> print it.next()
583583
Traceback (most recent call last):
584-
File "t.py", line 15, in ?
584+
File "t.py", line 15, in <module>
585585
print it.next()
586586
StopIteration
587587

Doc/library/ctypes.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Functions are accessed as attributes of dll objects::
8787
<_FuncPtr object at 0x...>
8888
>>> print windll.kernel32.MyOwnFunction # doctest: +WINDOWS
8989
Traceback (most recent call last):
90-
File "<stdin>", line 1, in ?
90+
File "<stdin>", line 1, in <module>
9191
File "ctypes.py", line 239, in __getattr__
9292
func = _StdcallFuncPtr(name, self)
9393
AttributeError: function 'MyOwnFunction' not found
@@ -126,7 +126,7 @@ functions can be accessed by indexing the dll object with the ordinal number::
126126
<_FuncPtr object at 0x...>
127127
>>> cdll.kernel32[0] # doctest: +WINDOWS
128128
Traceback (most recent call last):
129-
File "<stdin>", line 1, in ?
129+
File "<stdin>", line 1, in <module>
130130
File "ctypes.py", line 310, in __getitem__
131131
func = _StdcallFuncPtr(name, self)
132132
AttributeError: function ordinal 0 not found
@@ -159,11 +159,11 @@ although an error is raised the function *has* been called::
159159

160160
>>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS
161161
Traceback (most recent call last):
162-
File "<stdin>", line 1, in ?
162+
File "<stdin>", line 1, in <module>
163163
ValueError: Procedure probably called with not enough arguments (4 bytes missing)
164164
>>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS
165165
Traceback (most recent call last):
166-
File "<stdin>", line 1, in ?
166+
File "<stdin>", line 1, in <module>
167167
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
168168
>>>
169169

@@ -172,13 +172,13 @@ The same exception is raised when you call an ``stdcall`` function with the
172172

173173
>>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS
174174
Traceback (most recent call last):
175-
File "<stdin>", line 1, in ?
175+
File "<stdin>", line 1, in <module>
176176
ValueError: Procedure probably called with not enough arguments (4 bytes missing)
177177
>>>
178178

179179
>>> windll.msvcrt.printf("spam") # doctest: +WINDOWS
180180
Traceback (most recent call last):
181-
File "<stdin>", line 1, in ?
181+
File "<stdin>", line 1, in <module>
182182
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
183183
>>>
184184

@@ -191,7 +191,7 @@ argument values::
191191

192192
>>> windll.kernel32.GetModuleHandleA(32) # doctest: +WINDOWS
193193
Traceback (most recent call last):
194-
File "<stdin>", line 1, in ?
194+
File "<stdin>", line 1, in <module>
195195
WindowsError: exception: access violation reading 0x00000020
196196
>>>
197197

@@ -354,7 +354,7 @@ from within *IDLE* or *PythonWin*::
354354
19
355355
>>> printf("%f bottles of beer\n", 42.5)
356356
Traceback (most recent call last):
357-
File "<stdin>", line 1, in ?
357+
File "<stdin>", line 1, in <module>
358358
ArgumentError: argument 2: exceptions.TypeError: Don't know how to convert parameter 2
359359
>>>
360360

@@ -417,7 +417,7 @@ prototype for a C function), and tries to convert the arguments to valid types::
417417

418418
>>> printf("%d %d %d", 1, 2, 3)
419419
Traceback (most recent call last):
420-
File "<stdin>", line 1, in ?
420+
File "<stdin>", line 1, in <module>
421421
ArgumentError: argument 2: exceptions.TypeError: wrong type
422422
>>> printf("%s %d %f\n", "X", 2, 3)
423423
X 2 3.000000
@@ -467,7 +467,7 @@ single character Python string into a C char::
467467
'def'
468468
>>> strchr("abcdef", "def")
469469
Traceback (most recent call last):
470-
File "<stdin>", line 1, in ?
470+
File "<stdin>", line 1, in <module>
471471
ArgumentError: argument 2: exceptions.TypeError: one character string expected
472472
>>> print strchr("abcdef", "x")
473473
None
@@ -493,7 +493,7 @@ useful to check for error return values and automatically raise an exception::
493493
486539264
494494
>>> GetModuleHandle("something silly") # doctest: +WINDOWS
495495
Traceback (most recent call last):
496-
File "<stdin>", line 1, in ?
496+
File "<stdin>", line 1, in <module>
497497
File "<stdin>", line 3, in ValidHandle
498498
WindowsError: [Errno 126] The specified module could not be found.
499499
>>>
@@ -564,7 +564,7 @@ Here is a simple example of a POINT structure, which contains two integers named
564564
0 5
565565
>>> POINT(1, 2, 3)
566566
Traceback (most recent call last):
567-
File "<stdin>", line 1, in ?
567+
File "<stdin>", line 1, in <module>
568568
ValueError: too many initializers
569569
>>>
570570

@@ -767,7 +767,7 @@ a new type::
767767
<class 'ctypes.LP_c_long'>
768768
>>> PI(42)
769769
Traceback (most recent call last):
770-
File "<stdin>", line 1, in ?
770+
File "<stdin>", line 1, in <module>
771771
TypeError: expected c_long instead of int
772772
>>> PI(c_int(42))
773773
<ctypes.LP_c_long object at 0x...>
@@ -843,7 +843,7 @@ but not instances of other types::
843843

844844
>>> bar.values = (c_byte * 4)()
845845
Traceback (most recent call last):
846-
File "<stdin>", line 1, in ?
846+
File "<stdin>", line 1, in <module>
847847
TypeError: incompatible types, c_byte_Array_4 instance instead of LP_c_long instance
848848
>>>
849849

@@ -894,7 +894,7 @@ work::
894894
... ("next", POINTER(cell))]
895895
...
896896
Traceback (most recent call last):
897-
File "<stdin>", line 1, in ?
897+
File "<stdin>", line 1, in <module>
898898
File "<stdin>", line 2, in cell
899899
NameError: name 'cell' is not defined
900900
>>>

Doc/library/doctest.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ Simple example::
425425

426426
>>> [1, 2, 3].remove(42)
427427
Traceback (most recent call last):
428-
File "<stdin>", line 1, in ?
428+
File "<stdin>", line 1, in <module>
429429
ValueError: list.remove(x): x not in list
430430

431431
That doctest succeeds if :exc:`ValueError` is raised, with the ``list.remove(x):
@@ -449,7 +449,7 @@ multi-line detail::
449449

450450
>>> raise ValueError('multi\n line\ndetail')
451451
Traceback (most recent call last):
452-
File "<stdin>", line 1, in ?
452+
File "<stdin>", line 1, in <module>
453453
ValueError: multi
454454
line
455455
detail
@@ -607,7 +607,7 @@ doctest decides whether actual output matches an example's expected output:
607607

608608
>>> (1, 2)[3] = 'moo'
609609
Traceback (most recent call last):
610-
File "<stdin>", line 1, in ?
610+
File "<stdin>", line 1, in <module>
611611
TypeError: object doesn't support item assignment
612612

613613
passes under Python 2.3 and later Python versions with the flag specified,

Doc/library/fpectl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The following example demonstrates how to start up and test operation of the
8888
>>> import math
8989
>>> math.exp(1000)
9090
Traceback (most recent call last):
91-
File "<stdin>", line 1, in ?
91+
File "<stdin>", line 1, in <module>
9292
FloatingPointError: in math_1
9393

9494

Doc/library/pdb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The typical usage to inspect a crashed program is::
7070
>>> import mymodule
7171
>>> mymodule.test()
7272
Traceback (most recent call last):
73-
File "<stdin>", line 1, in ?
73+
File "<stdin>", line 1, in <module>
7474
File "./mymodule.py", line 4, in test
7575
test2()
7676
File "./mymodule.py", line 3, in test2

Doc/library/unicodedata.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Examples:
161161
9
162162
>>> unicodedata.decimal(u'a')
163163
Traceback (most recent call last):
164-
File "<stdin>", line 1, in ?
164+
File "<stdin>", line 1, in <module>
165165
ValueError: not a decimal
166166
>>> unicodedata.category(u'A') # 'L'etter, 'u'ppercase
167167
'Lu'

Doc/reference/expressions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ A consequence of this is that although the ``*expression`` syntax may appear
767767
2 1
768768
>>> f(a=1, *(2,))
769769
Traceback (most recent call last):
770-
File "<stdin>", line 1, in ?
770+
File "<stdin>", line 1, in <module>
771771
TypeError: f() got multiple values for keyword argument 'a'
772772
>>> f(1, *(2,))
773773
1 2

Doc/tutorial/classes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ This example shows how it all works::
787787
'c'
788788
>>> it.next()
789789
Traceback (most recent call last):
790-
File "<stdin>", line 1, in ?
790+
File "<stdin>", line 1, in <module>
791791
it.next()
792792
StopIteration
793793

Doc/tutorial/controlflow.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ Here's an example that fails due to this restriction::
444444
...
445445
>>> function(0, a=0)
446446
Traceback (most recent call last):
447-
File "<stdin>", line 1, in ?
447+
File "<stdin>", line 1, in <module>
448448
TypeError: function() got multiple values for keyword argument 'a'
449449

450450
When a final formal parameter of the form ``**name`` is present, it receives a

0 commit comments

Comments
 (0)