Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c27cd71

Browse files
committed
Merge
2 parents 5c30a75 + c91d5ee commit c27cd71

17 files changed

Lines changed: 137 additions & 32 deletions

File tree

.hgignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Modules/Setup.local
3636
Modules/config.c
3737
Modules/ld_so_aix$
3838
Parser/pgen$
39+
^lcov-report/
3940
^core
4041
^python-gdb.py
4142
^python.exe-gdb.py
@@ -91,3 +92,7 @@ Modules/_testembed
9192
.coverage
9293
coverage/
9394
htmlcov/
95+
*.gcda
96+
*.gcno
97+
*.gcov
98+
coverage.info

Doc/library/aifc.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ Module :mod:`aifc` defines the following function:
5151
used for writing, the file object should be seekable, unless you know ahead of
5252
time how many samples you are going to write in total and use
5353
:meth:`writeframesraw` and :meth:`setnframes`.
54-
Objects returned by :func:`.open` also supports the :keyword:`with` statement.
54+
The :func:`.open` function may be used in a :keyword:`with` statement. When
55+
the :keyword:`with` block completes, the :meth:`~aifc.close` method is called.
5556

5657
.. versionchanged:: 3.4
5758
Support for the :keyword:`with` statement was added.

Doc/library/difflib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ It is also contained in the Python source distribution, as
752752
# we're passing these as arguments to the diff function
753753
fromdate = time.ctime(os.stat(fromfile).st_mtime)
754754
todate = time.ctime(os.stat(tofile).st_mtime)
755-
with open(fromlines) as fromf, open(tofile) as tof:
755+
with open(fromfile) as fromf, open(tofile) as tof:
756756
fromlines, tolines = list(fromf), list(tof)
757757

758758
if options.u:

Doc/library/email.iterators.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The following function has been added as a useful debugging tool. It should
6868
text/plain
6969
text/plain
7070

71-
.. testcleanup::
71+
.. testsetup::
7272

7373
>>> somefile.close()
7474

Doc/library/email.policy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ file on disk and pass it to the system ``sendmail`` program on a Unix system:
8585
>>> p.stdin.close()
8686
>>> rc = p.wait()
8787

88-
.. testcleanup::
88+
.. testsetup::
8989

9090
>>> mymsg.close()
9191
>>> mocker.stop()

Doc/library/enum.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ Avoids having to specify the value for each enumeration member::
483483
... def __new__(cls):
484484
... value = len(cls.__members__) + 1
485485
... obj = object.__new__(cls)
486-
... obj._value = value
486+
... obj._value_ = value
487487
... return obj
488488
...
489489
>>> class Color(AutoNumber):
@@ -505,19 +505,19 @@ enumerations)::
505505
>>> class OrderedEnum(Enum):
506506
... def __ge__(self, other):
507507
... if self.__class__ is other.__class__:
508-
... return self._value >= other._value
508+
... return self.value >= other.value
509509
... return NotImplemented
510510
... def __gt__(self, other):
511511
... if self.__class__ is other.__class__:
512-
... return self._value > other._value
512+
... return self.value > other.value
513513
... return NotImplemented
514514
... def __le__(self, other):
515515
... if self.__class__ is other.__class__:
516-
... return self._value <= other._value
516+
... return self.value <= other.value
517517
... return NotImplemented
518518
... def __lt__(self, other):
519519
... if self.__class__ is other.__class__:
520-
... return self._value < other._value
520+
... return self.value < other.value
521521
... return NotImplemented
522522
...
523523
>>> class Grade(OrderedEnum):

Doc/library/unittest.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,12 +974,12 @@ Test cases
974974
Test that a warning is triggered when *callable* is called with any
975975
positional or keyword arguments that are also passed to
976976
:meth:`assertWarns`. The test passes if *warning* is triggered and
977-
fails if it isn't. Also, any unexpected exception is an error.
977+
fails if it isn't. Any exception is an error.
978978
To catch any of a group of warnings, a tuple containing the warning
979979
classes may be passed as *warnings*.
980980

981981
If only the *warning* and possibly the *msg* arguments are given,
982-
returns a context manager so that the code under test can be written
982+
return a context manager so that the code under test can be written
983983
inline rather than as a function::
984984

985985
with self.assertWarns(SomeWarning):
@@ -992,7 +992,7 @@ Test cases
992992
:attr:`warning` attribute, and the source line which triggered the
993993
warnings in the :attr:`filename` and :attr:`lineno` attributes.
994994
This can be useful if the intention is to perform additional checks
995-
on the exception raised::
995+
on the warning caught::
996996

997997
with self.assertWarns(SomeWarning) as cm:
998998
do_something()

Doc/library/wave.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ The :mod:`wave` module defines the following function and exception:
3939
:meth:`close` method is called; it is the caller's responsibility to close
4040
the file object.
4141

42+
The :func:`.open` function may be used in a :keyword:`with` statement. When
43+
the :keyword:`with` block completes, the :meth:`Wave_read.close()
44+
<wave.Wave_read.close>` or :meth:`Wave_write.close()
45+
<wave.Wave_write.close()>` method is called.
46+
4247

4348
.. function:: openfp(file, mode)
4449

Doc/tutorial/inputoutput.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,11 @@ first::
322322
>>> f.write(s)
323323
18
324324

325-
``f.tell()`` returns an integer giving the file object's current position in the
326-
file, measured in bytes from the beginning of the file. To change the file
327-
object's position, use ``f.seek(offset, from_what)``. The position is computed
325+
``f.tell()`` returns an integer giving the file object's current position in the file
326+
represented as number of bytes from the beginning of the file when in `binary mode` and
327+
an opaque number when in `text mode`.
328+
329+
To change the file object's position, use ``f.seek(offset, from_what)``. The position is computed
328330
from adding *offset* to a reference point; the reference point is selected by
329331
the *from_what* argument. A *from_what* value of 0 measures from the beginning
330332
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. ::
345347

346348
In text files (those opened without a ``b`` in the mode string), only seeks
347349
relative to the beginning of the file are allowed (the exception being seeking
348-
to the very file end with ``seek(0, 2)``).
350+
to the very file end with ``seek(0, 2)``) and the only valid *offset* values are
351+
those returned from the ``f.tell()``, or zero. Any other *offset* value produces
352+
undefined behaviour.
353+
349354

350355
When you're done with a file, call ``f.close()`` to close it and free up any
351356
system resources taken up by the open file. After calling ``f.close()``,

Doc/whatsnew/3.4.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,11 @@ wave
239239
The :meth:`~wave.getparams` method now returns a namedtuple rather than a
240240
plain tuple. (Contributed by Claudiu Popa in :issue:`17487`.)
241241

242+
:meth:`wave.open` now supports the context manager protocol. (Contributed
243+
by Claudiu Popa in :issue:`17616`.)
244+
242245
stat
243-
---
246+
----
244247

245248
The stat module is now backed by a C implementation in :mod:`_stat`. A C
246249
implementation is required as most of the values aren't standardized and

0 commit comments

Comments
 (0)