| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 107690c commit 8ffe0bc
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -324,7 +324,7 @@ Buffer-related functions | |||
| 324 | 324 | given shape with the given number of bytes per element. | |
| 325 | 325 | ||
| 326 | 326 | ||
| 327 | - .. cfunction:: int PyBuffer_FillInfo(Py_buffer *view, void *buf, Py_ssize_t len, int readonly, int infoflags) | ||
| 327 | + .. cfunction:: int PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len, int readonly, int infoflags) | ||
| 328 | 328 | ||
| 329 | 329 | Fill in a buffer-info structure, *view*, correctly for an exporter that can | |
| 330 | 330 | only share a contiguous chunk of memory of "unsigned bytes" of the given | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1210,7 +1210,7 @@ member in the :ctype:`PyTypeObject` structure should be *NULL*. Otherwise, the | |||
| 1210 | 1210 | ||
| 1211 | 1211 | This should fill a :ctype:`Py_buffer` with the necessary data for | |
| 1212 | 1212 | exporting the type. The signature of :data:`getbufferproc` is ``int | |
| 1213 | - (PyObject *obj, PyObject *view, int flags)``. *obj* is the object to | ||
| 1213 | + (PyObject *obj, Py_buffer *view, int flags)``. *obj* is the object to | ||
| 1214 | 1214 | export, *view* is the :ctype:`Py_buffer` struct to fill, and *flags* gives | |
| 1215 | 1215 | the conditions the caller wants the memory under. (See | |
| 1216 | 1216 | :cfunc:`PyObject_GetBuffer` for all flags.) :cmember:`bf_getbuffer` is | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -709,7 +709,7 @@ a fixed-width print format: | |||
| 709 | 709 | Point: x= 3.000 y= 4.000 hypot= 5.000 | |
| 710 | 710 | Point: x=14.000 y= 0.714 hypot=14.018 | |
| 711 | 711 | ||
| 712 | - The subclass shown above sets ``__slots__`` to an empty tuple. This keeps | ||
| 712 | + The subclass shown above sets ``__slots__`` to an empty tuple. This helps | ||
| 713 | 713 | keep memory requirements low by preventing the creation of instance dictionaries. | |
| 714 | 714 | ||
| 715 | 715 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,20 +3,12 @@ | |||
| 3 | 3 | Built-in Exceptions | |
| 4 | 4 | =================== | |
| 5 | 5 | ||
| 6 | - .. module:: exceptions | ||
| 7 | - :synopsis: Standard exception classes. | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - Exceptions should be class objects. The exceptions are defined in the module | ||
| 11 | - :mod:`exceptions`. This module never needs to be imported explicitly: the | ||
| 12 | - exceptions are provided in the built-in namespace as well as the | ||
| 13 | - :mod:`exceptions` module. | ||
| 14 | - | ||
| 15 | 6 | .. index:: | |
| 16 | 7 | statement: try | |
| 17 | 8 | statement: except | |
| 18 | 9 | ||
| 19 | - For class exceptions, in a :keyword:`try` statement with an :keyword:`except` | ||
| 10 | + In Python, all exceptions must be instances of a class that derives from | ||
| 11 | + :class:`BaseException`. In a :keyword:`try` statement with an :keyword:`except` | ||
| 20 | 12 | clause that mentions a particular class, that clause also handles any exception | |
| 21 | 13 | classes derived from that class (but not exception classes from which *it* is | |
| 22 | 14 | derived). Two exception classes that are not related via subclassing are never | |
@@ -44,7 +36,7 @@ programmers are encouraged to at least derive new exceptions from the | |||
| 44 | 36 | defining exceptions is available in the Python Tutorial under | |
| 45 | 37 | :ref:`tut-userexceptions`. | |
| 46 | 38 | ||
| 47 | - The following exceptions are only used as base classes for other exceptions. | ||
| 39 | + The following exceptions are used mostly as base classes for other exceptions. | ||
| 48 | 40 | ||
| 49 | 41 | .. XXX document with_traceback() | |
| 50 | 42 | ||
@@ -99,8 +91,8 @@ The following exceptions are only used as base classes for other exceptions. | |||
| 99 | 91 | In this last case, :attr:`args` contains the verbatim constructor arguments as a | |
| 100 | 92 | tuple. | |
| 101 | 93 | ||
| 102 | - The following exceptions are the exceptions that are actually raised. | ||
| 103 | 94 | ||
| 95 | + The following exceptions are the exceptions that are usually raised. | ||
| 104 | 96 | ||
| 105 | 97 | .. exception:: AssertionError | |
| 106 | 98 | ||
@@ -369,10 +361,10 @@ The following exceptions are the exceptions that are actually raised. | |||
| 369 | 361 | associated value is a string indicating the type of the operands and the | |
| 370 | 362 | operation. | |
| 371 | 363 | ||
| 364 | + | ||
| 372 | 365 | The following exceptions are used as warning categories; see the :mod:`warnings` | |
| 373 | 366 | module for more information. | |
| 374 | 367 | ||
| 375 | - | ||
| 376 | 368 | .. exception:: Warning | |
| 377 | 369 | ||
| 378 | 370 | Base class for warning categories. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,10 +136,9 @@ This module defines one class called :class:`Popen`: | |||
| 136 | 136 | ||
| 137 | 137 | .. note:: | |
| 138 | 138 | ||
| 139 | - If specified, *env* must provide any variables required | ||
| 140 | - for the program to execute. On Windows, in order to run a | ||
| 141 | - `side-by-side assembly`_ the specified *env* **must** include a valid | ||
| 142 | - :envvar:`SystemRoot`. | ||
| 139 | + If specified, *env* must provide any variables required for the program to | ||
| 140 | + execute. On Windows, in order to run a `side-by-side assembly`_ the | ||
| 141 | + specified *env* **must** include a valid :envvar:`SystemRoot`. | ||
| 143 | 142 | ||
| 144 | 143 | .. _side-by-side assembly: http://en.wikipedia.org/wiki/Side-by-Side_Assembly | |
| 145 | 144 | ||
@@ -188,7 +187,7 @@ This module also defines four shortcut functions: | |||
| 188 | 187 | ||
| 189 | 188 | The arguments are the same as for the Popen constructor. Example:: | |
| 190 | 189 | ||
| 191 | - retcode = call(["ls", "-l"]) | ||
| 190 | + >>> retcode = subprocess.call(["ls", "-l"]) | ||
| 192 | 191 | ||
| 193 | 192 | .. warning:: | |
| 194 | 193 | ||
@@ -206,7 +205,8 @@ This module also defines four shortcut functions: | |||
| 206 | 205 | ||
| 207 | 206 | The arguments are the same as for the Popen constructor. Example:: | |
| 208 | 207 | ||
| 209 | - check_call(["ls", "-l"]) | ||
| 208 | + >>> subprocess.check_call(["ls", "-l"]) | ||
| 209 | + 0 | ||
| 210 | 210 | ||
| 211 | 211 | .. warning:: | |
| 212 | 212 | ||
@@ -225,15 +225,15 @@ This module also defines four shortcut functions: | |||
| 225 | 225 | The arguments are the same as for the :class:`Popen` constructor. Example:: | |
| 226 | 226 | ||
| 227 | 227 | >>> subprocess.check_output(["ls", "-l", "/dev/null"]) | |
| 228 | - 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' | ||
| 228 | + b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' | ||
| 229 | 229 | ||
| 230 | 230 | The stdout argument is not allowed as it is used internally. | |
| 231 | 231 | To capture standard error in the result, use ``stderr=subprocess.STDOUT``:: | |
| 232 | 232 | ||
| 233 | 233 | >>> subprocess.check_output( | |
| 234 | - ["/bin/sh", "-c", "ls non_existent_file ; exit 0"], | ||
| 235 | - stderr=subprocess.STDOUT) | ||
| 236 | - 'ls: non_existent_file: No such file or directory\n' | ||
| 234 | + ... ["/bin/sh", "-c", "ls non_existent_file; exit 0"], | ||
| 235 | + ... stderr=subprocess.STDOUT) | ||
| 236 | + b'ls: non_existent_file: No such file or directory\n' | ||
| 237 | 237 | ||
| 238 | 238 | .. versionadded:: 3.1 | |
| 239 | 239 | ||
@@ -247,7 +247,6 @@ This module also defines four shortcut functions: | |||
| 247 | 247 | stripped from the output. The exit status for the command can be interpreted | |
| 248 | 248 | according to the rules for the C function :cfunc:`wait`. Example:: | |
| 249 | 249 | ||
| 250 | - >>> import subprocess | ||
| 251 | 250 | >>> subprocess.getstatusoutput('ls /bin/ls') | |
| 252 | 251 | (0, '/bin/ls') | |
| 253 | 252 | >>> subprocess.getstatusoutput('cat /bin/junk') | |
@@ -264,7 +263,6 @@ This module also defines four shortcut functions: | |||
| 264 | 263 | Like :func:`getstatusoutput`, except the exit status is ignored and the return | |
| 265 | 264 | value is a string containing the command's output. Example:: | |
| 266 | 265 | ||
| 267 | - >>> import subprocess | ||
| 268 | 266 | >>> subprocess.getoutput('ls /bin/ls') | |
| 269 | 267 | '/bin/ls' | |
| 270 | 268 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,7 +110,7 @@ class Popen(args, bufsize=0, executable=None, | |||
| 110 | 110 | ||
| 111 | 111 | The arguments are the same as for the Popen constructor. Example: | |
| 112 | 112 | ||
| 113 | - retcode = call(["ls", "-l"]) | ||
| 113 | + >>> retcode = call(["ls", "-l"]) | ||
| 114 | 114 | ||
| 115 | 115 | check_call(*popenargs, **kwargs): | |
| 116 | 116 | Run command with arguments. Wait for command to complete. If the | |
@@ -120,7 +120,8 @@ class Popen(args, bufsize=0, executable=None, | |||
| 120 | 120 | ||
| 121 | 121 | The arguments are the same as for the Popen constructor. Example: | |
| 122 | 122 | ||
| 123 | - check_call(["ls", "-l"]) | ||
| 123 | + >>> check_call(["ls", "-l"]) | ||
| 124 | + 0 | ||
| 124 | 125 | ||
| 125 | 126 | getstatusoutput(cmd): | |
| 126 | 127 | Return (status, output) of executing cmd in a shell. | |
@@ -131,7 +132,6 @@ class Popen(args, bufsize=0, executable=None, | |||
| 131 | 132 | is stripped from the output. The exit status for the command can be | |
| 132 | 133 | interpreted according to the rules for the C function wait(). Example: | |
| 133 | 134 | ||
| 134 | - >>> import subprocess | ||
| 135 | 135 | >>> subprocess.getstatusoutput('ls /bin/ls') | |
| 136 | 136 | (0, '/bin/ls') | |
| 137 | 137 | >>> subprocess.getstatusoutput('cat /bin/junk') | |
@@ -145,20 +145,19 @@ class Popen(args, bufsize=0, executable=None, | |||
| 145 | 145 | Like getstatusoutput(), except the exit status is ignored and the return | |
| 146 | 146 | value is a string containing the command's output. Example: | |
| 147 | 147 | ||
| 148 | - >>> import subprocess | ||
| 149 | 148 | >>> subprocess.getoutput('ls /bin/ls') | |
| 150 | 149 | '/bin/ls' | |
| 151 | 150 | ||
| 152 | 151 | check_output(*popenargs, **kwargs): | |
| 153 | - Run command with arguments and return its output as a byte string. | ||
| 152 | + Run command with arguments and return its output as a byte string. | ||
| 154 | 153 | ||
| 155 | - If the exit code was non-zero it raises a CalledProcessError. The | ||
| 156 | - CalledProcessError object will have the return code in the returncode | ||
| 157 | - attribute and output in the output attribute. | ||
| 154 | + If the exit code was non-zero it raises a CalledProcessError. The | ||
| 155 | + CalledProcessError object will have the return code in the returncode | ||
| 156 | + attribute and output in the output attribute. | ||
| 158 | 157 | ||
| 159 | - The arguments are the same as for the Popen constructor. Example: | ||
| 158 | + The arguments are the same as for the Popen constructor. Example: | ||
| 160 | 159 | ||
| 161 | - output = subprocess.check_output(["ls", "-l", "/dev/null"]) | ||
| 160 | + >>> output = subprocess.check_output(["ls", "-l", "/dev/null"]) | ||
| 162 | 161 | ||
| 163 | 162 | ||
| 164 | 163 | Exceptions | |
@@ -437,7 +436,7 @@ def check_call(*popenargs, **kwargs): | |||
| 437 | 436 | ||
| 438 | 437 | ||
| 439 | 438 | def check_output(*popenargs, **kwargs): | |
| 440 | - """Run command with arguments and return its output as a byte string. | ||
| 439 | + r"""Run command with arguments and return its output as a byte string. | ||
| 441 | 440 | ||
| 442 | 441 | If the exit code was non-zero it raises a CalledProcessError. The | |
| 443 | 442 | CalledProcessError object will have the return code in the returncode | |
@@ -446,15 +445,15 @@ def check_output(*popenargs, **kwargs): | |||
| 446 | 445 | The arguments are the same as for the Popen constructor. Example: | |
| 447 | 446 | ||
| 448 | 447 | >>> check_output(["ls", "-l", "/dev/null"]) | |
| 449 | - 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' | ||
| 448 | + b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n' | ||
| 450 | 449 | ||
| 451 | 450 | The stdout argument is not allowed as it is used internally. | |
| 452 | - To capture standard error in the result, use stderr=subprocess.STDOUT. | ||
| 451 | + To capture standard error in the result, use stderr=STDOUT. | ||
| 453 | 452 | ||
| 454 | 453 | >>> check_output(["/bin/sh", "-c", | |
| 455 | - "ls -l non_existent_file ; exit 0"], | ||
| 456 | - stderr=subprocess.STDOUT) | ||
| 457 | - 'ls: non_existent_file: No such file or directory\n' | ||
| 454 | + ... "ls -l non_existent_file ; exit 0"], | ||
| 455 | + ... stderr=STDOUT) | ||
| 456 | + b'ls: non_existent_file: No such file or directory\n' | ||
| 458 | 457 | """ | |
| 459 | 458 | if 'stdout' in kwargs: | |
| 460 | 459 | raise ValueError('stdout argument not allowed, it will be overridden.') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -176,6 +176,9 @@ PyObject *PyExc_BlockingIOError = (PyObject *)&_PyExc_BlockingIOError; | |||
| 176 | 176 | * The main open() function | |
| 177 | 177 | */ | |
| 178 | 178 | PyDoc_STRVAR(open_doc, | |
| 179 | + "open(file, mode='r', buffering=None, encoding=None,\n" | ||
| 180 | + " errors=None, newline=None, closefd=True) -> file object\n" | ||
| 181 | + "\n" | ||
| 179 | 182 | "Open file and return a stream. Raise IOError upon failure.\n" | |
| 180 | 183 | "\n" | |
| 181 | 184 | "file is either a text or byte string giving the name (and the path\n" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments