Commit 8ffe0bc5 authored by Georg Brandl's avatar Georg Brandl

Merged revisions 76923,76926,77009,77082-77083,77085,77087,77121 via svnmerge from

svn+ssh://svn.python.org/python/branches/py3k

................
  r76923 | georg.brandl | 2009-12-20 15:24:06 +0100 (So, 20 Dez 2009) | 1 line

  #7493: more review fixes.
................
  r76926 | georg.brandl | 2009-12-20 15:38:23 +0100 (So, 20 Dez 2009) | 9 lines

  Recorded merge of revisions 76925 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r76925 | georg.brandl | 2009-12-20 15:33:20 +0100 (So, 20 Dez 2009) | 1 line

    #7381: subprocess documentation and library docstring consistency fixes.
  ........
................
  r77009 | georg.brandl | 2009-12-23 11:30:45 +0100 (Mi, 23 Dez 2009) | 1 line

  #7417: add signature to open() docstring.
................
  r77082 | georg.brandl | 2009-12-28 08:59:20 +0100 (Mo, 28 Dez 2009) | 1 line

  #7577: fix signature info for getbufferproc.
................
  r77083 | georg.brandl | 2009-12-28 09:00:47 +0100 (Mo, 28 Dez 2009) | 9 lines

  Merged revisions 77081 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r77081 | georg.brandl | 2009-12-28 08:59:05 +0100 (Mo, 28 Dez 2009) | 1 line

    #7577: fix signature of PyBuffer_FillInfo().
  ........
................
  r77085 | georg.brandl | 2009-12-28 09:02:38 +0100 (Mo, 28 Dez 2009) | 9 lines

  Merged revisions 77084 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r77084 | georg.brandl | 2009-12-28 09:01:59 +0100 (Mo, 28 Dez 2009) | 1 line

    #7586: fix typo.
  ........
................
  r77087 | georg.brandl | 2009-12-28 09:10:38 +0100 (Mo, 28 Dez 2009) | 9 lines

  Recorded merge of revisions 77086 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r77086 | georg.brandl | 2009-12-28 09:09:32 +0100 (Mo, 28 Dez 2009) | 1 line

    #7381: consistency update, and backport avoiding ``None >= 0`` check from py3k.
  ........
................
  r77121 | georg.brandl | 2009-12-29 22:38:35 +0100 (Di, 29 Dez 2009) | 1 line

  #7590: exception classes no longer are in the "exceptions" module. Also clean up text that was written with string exceptions in mind.
................
parent 107690c2
......@@ -324,7 +324,7 @@ Buffer-related functions
given shape with the given number of bytes per element.
.. cfunction:: int PyBuffer_FillInfo(Py_buffer *view, void *buf, Py_ssize_t len, int readonly, int infoflags)
.. cfunction:: int PyBuffer_FillInfo(Py_buffer *view, PyObject *obj, void *buf, Py_ssize_t len, int readonly, int infoflags)
Fill in a buffer-info structure, *view*, correctly for an exporter that can
only share a contiguous chunk of memory of "unsigned bytes" of the given
......
......@@ -1210,7 +1210,7 @@ member in the :ctype:`PyTypeObject` structure should be *NULL*. Otherwise, the
This should fill a :ctype:`Py_buffer` with the necessary data for
exporting the type. The signature of :data:`getbufferproc` is ``int
(PyObject *obj, PyObject *view, int flags)``. *obj* is the object to
(PyObject *obj, Py_buffer *view, int flags)``. *obj* is the object to
export, *view* is the :ctype:`Py_buffer` struct to fill, and *flags* gives
the conditions the caller wants the memory under. (See
:cfunc:`PyObject_GetBuffer` for all flags.) :cmember:`bf_getbuffer` is
......
This diff is collapsed.
......@@ -709,7 +709,7 @@ a fixed-width print format:
Point: x= 3.000 y= 4.000 hypot= 5.000
Point: x=14.000 y= 0.714 hypot=14.018
The subclass shown above sets ``__slots__`` to an empty tuple. This keeps
The subclass shown above sets ``__slots__`` to an empty tuple. This helps
keep memory requirements low by preventing the creation of instance dictionaries.
......
......@@ -3,20 +3,12 @@
Built-in Exceptions
===================
.. module:: exceptions
:synopsis: Standard exception classes.
Exceptions should be class objects. The exceptions are defined in the module
:mod:`exceptions`. This module never needs to be imported explicitly: the
exceptions are provided in the built-in namespace as well as the
:mod:`exceptions` module.
.. index::
statement: try
statement: except
For class exceptions, in a :keyword:`try` statement with an :keyword:`except`
In Python, all exceptions must be instances of a class that derives from
:class:`BaseException`. In a :keyword:`try` statement with an :keyword:`except`
clause that mentions a particular class, that clause also handles any exception
classes derived from that class (but not exception classes from which *it* is
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
defining exceptions is available in the Python Tutorial under
:ref:`tut-userexceptions`.
The following exceptions are only used as base classes for other exceptions.
The following exceptions are used mostly as base classes for other exceptions.
.. XXX document with_traceback()
......@@ -99,8 +91,8 @@ The following exceptions are only used as base classes for other exceptions.
In this last case, :attr:`args` contains the verbatim constructor arguments as a
tuple.
The following exceptions are the exceptions that are actually raised.
The following exceptions are the exceptions that are usually raised.
.. exception:: AssertionError
......@@ -369,10 +361,10 @@ The following exceptions are the exceptions that are actually raised.
associated value is a string indicating the type of the operands and the
operation.
The following exceptions are used as warning categories; see the :mod:`warnings`
module for more information.
.. exception:: Warning
Base class for warning categories.
......
......@@ -136,10 +136,9 @@ This module defines one class called :class:`Popen`:
.. note::
If specified, *env* must provide any variables required
for the program to execute. On Windows, in order to run a
`side-by-side assembly`_ the specified *env* **must** include a valid
:envvar:`SystemRoot`.
If specified, *env* must provide any variables required for the program to
execute. On Windows, in order to run a `side-by-side assembly`_ the
specified *env* **must** include a valid :envvar:`SystemRoot`.
.. _side-by-side assembly: http://en.wikipedia.org/wiki/Side-by-Side_Assembly
......@@ -188,7 +187,7 @@ This module also defines four shortcut functions:
The arguments are the same as for the Popen constructor. Example::
retcode = call(["ls", "-l"])
>>> retcode = subprocess.call(["ls", "-l"])
.. warning::
......@@ -206,7 +205,8 @@ This module also defines four shortcut functions:
The arguments are the same as for the Popen constructor. Example::
check_call(["ls", "-l"])
>>> subprocess.check_call(["ls", "-l"])
0
.. warning::
......@@ -225,15 +225,15 @@ This module also defines four shortcut functions:
The arguments are the same as for the :class:`Popen` constructor. Example::
>>> subprocess.check_output(["ls", "-l", "/dev/null"])
'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
The stdout argument is not allowed as it is used internally.
To capture standard error in the result, use ``stderr=subprocess.STDOUT``::
>>> subprocess.check_output(
["/bin/sh", "-c", "ls non_existent_file ; exit 0"],
stderr=subprocess.STDOUT)
'ls: non_existent_file: No such file or directory\n'
... ["/bin/sh", "-c", "ls non_existent_file; exit 0"],
... stderr=subprocess.STDOUT)
b'ls: non_existent_file: No such file or directory\n'
.. versionadded:: 3.1
......@@ -247,7 +247,6 @@ This module also defines four shortcut functions:
stripped from the output. The exit status for the command can be interpreted
according to the rules for the C function :cfunc:`wait`. Example::
>>> import subprocess
>>> subprocess.getstatusoutput('ls /bin/ls')
(0, '/bin/ls')
>>> subprocess.getstatusoutput('cat /bin/junk')
......@@ -264,7 +263,6 @@ This module also defines four shortcut functions:
Like :func:`getstatusoutput`, except the exit status is ignored and the return
value is a string containing the command's output. Example::
>>> import subprocess
>>> subprocess.getoutput('ls /bin/ls')
'/bin/ls'
......
......@@ -110,7 +110,7 @@ call(*popenargs, **kwargs):
The arguments are the same as for the Popen constructor. Example:
retcode = call(["ls", "-l"])
>>> retcode = call(["ls", "-l"])
check_call(*popenargs, **kwargs):
Run command with arguments. Wait for command to complete. If the
......@@ -120,7 +120,8 @@ check_call(*popenargs, **kwargs):
The arguments are the same as for the Popen constructor. Example:
check_call(["ls", "-l"])
>>> check_call(["ls", "-l"])
0
getstatusoutput(cmd):
Return (status, output) of executing cmd in a shell.
......@@ -131,7 +132,6 @@ getstatusoutput(cmd):
is stripped from the output. The exit status for the command can be
interpreted according to the rules for the C function wait(). Example:
>>> import subprocess
>>> subprocess.getstatusoutput('ls /bin/ls')
(0, '/bin/ls')
>>> subprocess.getstatusoutput('cat /bin/junk')
......@@ -145,20 +145,19 @@ getoutput(cmd):
Like getstatusoutput(), except the exit status is ignored and the return
value is a string containing the command's output. Example:
>>> import subprocess
>>> subprocess.getoutput('ls /bin/ls')
'/bin/ls'
check_output(*popenargs, **kwargs):
Run command with arguments and return its output as a byte string.
Run command with arguments and return its output as a byte string.
If the exit code was non-zero it raises a CalledProcessError. The
CalledProcessError object will have the return code in the returncode
attribute and output in the output attribute.
If the exit code was non-zero it raises a CalledProcessError. The
CalledProcessError object will have the return code in the returncode
attribute and output in the output attribute.
The arguments are the same as for the Popen constructor. Example:
The arguments are the same as for the Popen constructor. Example:
output = subprocess.check_output(["ls", "-l", "/dev/null"])
>>> output = subprocess.check_output(["ls", "-l", "/dev/null"])
Exceptions
......@@ -437,7 +436,7 @@ def check_call(*popenargs, **kwargs):
def check_output(*popenargs, **kwargs):
"""Run command with arguments and return its output as a byte string.
r"""Run command with arguments and return its output as a byte string.
If the exit code was non-zero it raises a CalledProcessError. The
CalledProcessError object will have the return code in the returncode
......@@ -446,15 +445,15 @@ def check_output(*popenargs, **kwargs):
The arguments are the same as for the Popen constructor. Example:
>>> check_output(["ls", "-l", "/dev/null"])
'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
The stdout argument is not allowed as it is used internally.
To capture standard error in the result, use stderr=subprocess.STDOUT.
To capture standard error in the result, use stderr=STDOUT.
>>> check_output(["/bin/sh", "-c",
"ls -l non_existent_file ; exit 0"],
stderr=subprocess.STDOUT)
'ls: non_existent_file: No such file or directory\n'
... "ls -l non_existent_file ; exit 0"],
... stderr=STDOUT)
b'ls: non_existent_file: No such file or directory\n'
"""
if 'stdout' in kwargs:
raise ValueError('stdout argument not allowed, it will be overridden.')
......
......@@ -176,6 +176,9 @@ PyObject *PyExc_BlockingIOError = (PyObject *)&_PyExc_BlockingIOError;
* The main open() function
*/
PyDoc_STRVAR(open_doc,
"open(file, mode='r', buffering=None, encoding=None,\n"
" errors=None, newline=None, closefd=True) -> file object\n"
"\n"
"Open file and return a stream. Raise IOError upon failure.\n"
"\n"
"file is either a text or byte string giving the name (and the path\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment