mirror of https://github.com/python/cpython
merge
This commit is contained in:
commit
294b93d4c6
|
@ -962,10 +962,9 @@ done. This can be done using the :c:func:`PyErr_Fetch` and
|
||||||
|
|
||||||
if (self->my_callback != NULL) {
|
if (self->my_callback != NULL) {
|
||||||
PyObject *err_type, *err_value, *err_traceback;
|
PyObject *err_type, *err_value, *err_traceback;
|
||||||
int have_error = PyErr_Occurred() ? 1 : 0;
|
|
||||||
|
|
||||||
if (have_error)
|
/* This saves the current exception state */
|
||||||
PyErr_Fetch(&err_type, &err_value, &err_traceback);
|
PyErr_Fetch(&err_type, &err_value, &err_traceback);
|
||||||
|
|
||||||
cbresult = PyObject_CallObject(self->my_callback, NULL);
|
cbresult = PyObject_CallObject(self->my_callback, NULL);
|
||||||
if (cbresult == NULL)
|
if (cbresult == NULL)
|
||||||
|
@ -973,8 +972,8 @@ done. This can be done using the :c:func:`PyErr_Fetch` and
|
||||||
else
|
else
|
||||||
Py_DECREF(cbresult);
|
Py_DECREF(cbresult);
|
||||||
|
|
||||||
if (have_error)
|
/* This restores the saved exception state */
|
||||||
PyErr_Restore(err_type, err_value, err_traceback);
|
PyErr_Restore(err_type, err_value, err_traceback);
|
||||||
|
|
||||||
Py_DECREF(self->my_callback);
|
Py_DECREF(self->my_callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -752,7 +752,7 @@ It is also contained in the Python source distribution, as
|
||||||
# we're passing these as arguments to the diff function
|
# we're passing these as arguments to the diff function
|
||||||
fromdate = time.ctime(os.stat(fromfile).st_mtime)
|
fromdate = time.ctime(os.stat(fromfile).st_mtime)
|
||||||
todate = time.ctime(os.stat(tofile).st_mtime)
|
todate = time.ctime(os.stat(tofile).st_mtime)
|
||||||
with open(fromlines) as fromf, open(tofile) as tof:
|
with open(fromfile) as fromf, open(tofile) as tof:
|
||||||
fromlines, tolines = list(fromf), list(tof)
|
fromlines, tolines = list(fromf), list(tof)
|
||||||
|
|
||||||
if options.u:
|
if options.u:
|
||||||
|
|
|
@ -68,7 +68,7 @@ The following function has been added as a useful debugging tool. It should
|
||||||
text/plain
|
text/plain
|
||||||
text/plain
|
text/plain
|
||||||
|
|
||||||
.. testcleanup::
|
.. testsetup::
|
||||||
|
|
||||||
>>> somefile.close()
|
>>> somefile.close()
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ file on disk and pass it to the system ``sendmail`` program on a Unix system:
|
||||||
>>> p.stdin.close()
|
>>> p.stdin.close()
|
||||||
>>> rc = p.wait()
|
>>> rc = p.wait()
|
||||||
|
|
||||||
.. testcleanup::
|
.. testsetup::
|
||||||
|
|
||||||
>>> mymsg.close()
|
>>> mymsg.close()
|
||||||
>>> mocker.stop()
|
>>> mocker.stop()
|
||||||
|
|
|
@ -897,12 +897,12 @@ Test cases
|
||||||
Test that a warning is triggered when *callable* is called with any
|
Test that a warning is triggered when *callable* is called with any
|
||||||
positional or keyword arguments that are also passed to
|
positional or keyword arguments that are also passed to
|
||||||
:meth:`assertWarns`. The test passes if *warning* is triggered and
|
:meth:`assertWarns`. The test passes if *warning* is triggered and
|
||||||
fails if it isn't. Also, any unexpected exception is an error.
|
fails if it isn't. Any exception is an error.
|
||||||
To catch any of a group of warnings, a tuple containing the warning
|
To catch any of a group of warnings, a tuple containing the warning
|
||||||
classes may be passed as *warnings*.
|
classes may be passed as *warnings*.
|
||||||
|
|
||||||
If only the *warning* and possibly the *msg* arguments are given,
|
If only the *warning* and possibly the *msg* arguments are given,
|
||||||
returns a context manager so that the code under test can be written
|
return a context manager so that the code under test can be written
|
||||||
inline rather than as a function::
|
inline rather than as a function::
|
||||||
|
|
||||||
with self.assertWarns(SomeWarning):
|
with self.assertWarns(SomeWarning):
|
||||||
|
@ -915,7 +915,7 @@ Test cases
|
||||||
:attr:`warning` attribute, and the source line which triggered the
|
:attr:`warning` attribute, and the source line which triggered the
|
||||||
warnings in the :attr:`filename` and :attr:`lineno` attributes.
|
warnings in the :attr:`filename` and :attr:`lineno` attributes.
|
||||||
This can be useful if the intention is to perform additional checks
|
This can be useful if the intention is to perform additional checks
|
||||||
on the exception raised::
|
on the warning caught::
|
||||||
|
|
||||||
with self.assertWarns(SomeWarning) as cm:
|
with self.assertWarns(SomeWarning) as cm:
|
||||||
do_something()
|
do_something()
|
||||||
|
|
|
@ -322,9 +322,11 @@ first::
|
||||||
>>> f.write(s)
|
>>> f.write(s)
|
||||||
18
|
18
|
||||||
|
|
||||||
``f.tell()`` returns an integer giving the file object's current position in the
|
``f.tell()`` returns an integer giving the file object's current position in the file
|
||||||
file, measured in bytes from the beginning of the file. To change the file
|
represented as number of bytes from the beginning of the file when in `binary mode` and
|
||||||
object's position, use ``f.seek(offset, from_what)``. The position is computed
|
an opaque number when in `text mode`.
|
||||||
|
|
||||||
|
To change the file object's position, use ``f.seek(offset, from_what)``. The position is computed
|
||||||
from adding *offset* to a reference point; the reference point is selected by
|
from adding *offset* to a reference point; the reference point is selected by
|
||||||
the *from_what* argument. A *from_what* value of 0 measures from the beginning
|
the *from_what* argument. A *from_what* value of 0 measures from the beginning
|
||||||
of the file, 1 uses the current file position, and 2 uses the end of the file as
|
of the file, 1 uses the current file position, and 2 uses the end of the file as
|
||||||
|
@ -345,7 +347,10 @@ beginning of the file as the reference point. ::
|
||||||
|
|
||||||
In text files (those opened without a ``b`` in the mode string), only seeks
|
In text files (those opened without a ``b`` in the mode string), only seeks
|
||||||
relative to the beginning of the file are allowed (the exception being seeking
|
relative to the beginning of the file are allowed (the exception being seeking
|
||||||
to the very file end with ``seek(0, 2)``).
|
to the very file end with ``seek(0, 2)``) and the only valid *offset* values are
|
||||||
|
those returned from the ``f.tell()``, or zero. Any other *offset* value produces
|
||||||
|
undefined behaviour.
|
||||||
|
|
||||||
|
|
||||||
When you're done with a file, call ``f.close()`` to close it and free up any
|
When you're done with a file, call ``f.close()`` to close it and free up any
|
||||||
system resources taken up by the open file. After calling ``f.close()``,
|
system resources taken up by the open file. After calling ``f.close()``,
|
||||||
|
|
|
@ -1012,7 +1012,7 @@ LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \
|
||||||
tkinter/test/test_ttk site-packages test \
|
tkinter/test/test_ttk site-packages test \
|
||||||
test/capath test/data \
|
test/capath test/data \
|
||||||
test/cjkencodings test/decimaltestdata test/xmltestdata \
|
test/cjkencodings test/decimaltestdata test/xmltestdata \
|
||||||
test/subprocessdata test/sndhdrdata \
|
test/subprocessdata test/sndhdrdata test/support \
|
||||||
test/tracedmodules test/encoded_modules \
|
test/tracedmodules test/encoded_modules \
|
||||||
test/namespace_pkgs \
|
test/namespace_pkgs \
|
||||||
test/namespace_pkgs/both_portions \
|
test/namespace_pkgs/both_portions \
|
||||||
|
|
Loading…
Reference in New Issue