]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[2.7] bpo-28315: Improve code examples in docs (GH-1372) (#1447)
authorMariatta <Mariatta@users.noreply.github.com>
Thu, 4 May 2017 01:54:28 +0000 (18:54 -0700)
committerGitHub <noreply@github.com>
Thu, 4 May 2017 01:54:28 +0000 (18:54 -0700)
Replace
   File "<stdin>", line 1, in ?
with
   File "<stdin>", line 1, in <module>.
(cherry picked from commit 8856940cf2e82cb17db2b684cd5732fe658605ca)

12 files changed:
Doc/extending/newtypes.rst
Doc/howto/functional.rst
Doc/library/ctypes.rst
Doc/library/doctest.rst
Doc/library/fpectl.rst
Doc/library/pdb.rst
Doc/library/unicodedata.rst
Doc/reference/expressions.rst
Doc/tutorial/classes.rst
Doc/tutorial/controlflow.rst
Doc/tutorial/datastructures.rst
Doc/tutorial/inputoutput.rst

index ebeca0534c7ca31eb48c04505015b32ddc2d9f43..5959e4f2b1ee6a6699d2a17315e3364b339b098d 100644 (file)
@@ -127,7 +127,7 @@ our objects and in some error messages, for example::
 
    >>> "" + 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
index ee9a5f6d94fd72286ab208746836931583de8d50..a06e29ce090747694c3eebbdea9fa7a230c00726 100644 (file)
@@ -207,7 +207,7 @@ You can experiment with the iteration interface manually:
     3
     >>> it.next()
     Traceback (most recent call last):
-      File "<stdin>", line 1, in ?
+      File "<stdin>", line 1, in <module>
     StopIteration
     >>>
 
@@ -477,7 +477,7 @@ Here's a sample usage of the ``generate_ints()`` generator:
     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 @@ And here's an example of changing the counter:
     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
 
index 052cdee47813129aa1184dd6312e8257fd258503..df9ccbf390840c7a3b930c000b73874f50711f6b 100644 (file)
@@ -87,7 +87,7 @@ Functions are accessed as attributes of dll objects::
    <_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 @@ functions can be accessed by indexing the dll object with the ordinal number::
    <_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 @@ although an error is raised the function *has* been called::
 
    >>> 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 @@ The same exception is raised when you call an ``stdcall`` function with the
 
    >>> 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 @@ argument values::
 
    >>> 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 @@ from within *IDLE* or *PythonWin*::
    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 @@ prototype for a C function), and tries to convert the arguments to valid types::
 
    >>> 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 @@ single character Python string into a C char::
    '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 @@ useful to check for error return values and automatically raise an exception::
    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 @@ Here is a simple example of a POINT structure, which contains two integers named
    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 @@ a new type::
    <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 @@ but not instances of other types::
 
    >>> 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 @@ work::
    ...                 ("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
    >>>
index b31d620643f6acea8b45b73842d07db5cb3f180e..cf67b234eded300db4ed2b86304b85f4729c1ed5 100644 (file)
@@ -425,7 +425,7 @@ Simple example::
 
    >>> [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 @@ multi-line detail::
 
    >>> 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 @@ doctest decides whether actual output matches an example's expected output:
 
       >>> (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,
index 8ca671b809c49fab72dfaa006816bb97fbd264d9..d48b8206d121aa4e2a3cd39e9559dfe5dfade390 100644 (file)
@@ -88,7 +88,7 @@ The following example demonstrates how to start up and test operation of the
    >>> 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
 
 
index 9177f95d517cf9a8bd48feaaedc12acb8e86a51f..33d7750c5149e86d54a2e5c14280953253ec70eb 100644 (file)
@@ -70,7 +70,7 @@ The typical usage to inspect a crashed program is::
    >>> 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
index a3a7c962bf2012903a824bf6208af11a661fc1fc..d7c48c4ab31212cec9646bace449ce82abda17ab 100644 (file)
@@ -161,7 +161,7 @@ Examples:
    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'
index 97975ce92b3c4b7e57a01fa8a4664bc1e184ca5e..8556fa810f6cb3c81f40a8ca48150cf030e46cc8 100644 (file)
@@ -767,7 +767,7 @@ A consequence of this is that although the ``*expression`` syntax may appear
    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
index 963581beb1d0af970df9528b972339d386564c17..216dcae6b60e4d9eb8e2dda785ae93be32e05873 100644 (file)
@@ -787,7 +787,7 @@ This example shows how it all works::
    'c'
    >>> it.next()
    Traceback (most recent call last):
-     File "<stdin>", line 1, in ?
+     File "<stdin>", line 1, in <module>
        it.next()
    StopIteration
 
index e1ac89f5e2d658e8b572d777334615dfd2722caf..a264bd728bf0f695e0b11675572750d9e5a03654 100644 (file)
@@ -444,7 +444,7 @@ Here's an example that fails due to this restriction::
    ...
    >>> 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
index 916da4a23bc98a3f3fc35f63694f25679b7e0a66..4e60e3232b60221f910d3ad88f4fefb6744094ef 100644 (file)
@@ -311,7 +311,7 @@ it must be parenthesized. ::
    [(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
index 3e32af26caae59964fe5605ad9b6f0a2bdb54b2d..d3542462ef0212e02f200bdb4a767e399042191a 100644 (file)
@@ -340,7 +340,7 @@ attempts to use the file object will automatically fail. ::
    >>> 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