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

Skip to content

Commit 8d5661b

Browse files
authored
Merge branch 'main' into gh-25949
2 parents e7ec54e + d9407b1 commit 8d5661b

6 files changed

Lines changed: 108 additions & 18 deletions

File tree

Doc/library/codecs.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ wider range of codecs when working with binary files:
189189

190190
.. note::
191191

192-
Underlying encoded files are always opened in binary mode.
192+
If *encoding* is not ``None``, then the
193+
underlying encoded files are always opened in binary mode.
193194
No automatic conversion of ``'\n'`` is done on reading and writing.
194195
The *mode* argument may be any binary mode acceptable to the built-in
195196
:func:`open` function; the ``'b'`` is automatically added.

Doc/library/enum.rst

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ Module Contents
9292
the bitwise operators without losing their :class:`IntFlag` membership.
9393
:class:`IntFlag` members are also subclasses of :class:`int`. (`Notes`_)
9494

95+
:class:`ReprEnum`
96+
97+
Used by :class:`IntEnum`, :class:`StrEnum`, and :class:`IntFlag`
98+
to keep the :class:`str() <str>` of the mixed-in type.
99+
95100
:class:`EnumCheck`
96101

97102
An enumeration with the values ``CONTINUOUS``, ``NAMED_FLAGS``, and
@@ -132,9 +137,20 @@ Module Contents
132137

133138
Do not make ``obj`` a member. Can be used as a decorator.
134139

140+
:func:`global_enum`
141+
142+
Modify the :class:`str() <str>` and :func:`repr` of an enum
143+
to show its members as belonging to the module instead of its class.
144+
Should only be used if the enum members will be exported to the
145+
module global namespace.
146+
147+
:func:`show_flag_values`
148+
149+
Return a list of all power-of-two integers contained in a flag.
150+
135151

136152
.. versionadded:: 3.6 ``Flag``, ``IntFlag``, ``auto``
137-
.. versionadded:: 3.11 ``StrEnum``, ``EnumCheck``, ``FlagBoundary``, ``property``, ``member``, ``nonmember``
153+
.. versionadded:: 3.11 ``StrEnum``, ``EnumCheck``, ``ReprEnum``, ``FlagBoundary``, ``property``, ``member``, ``nonmember``, ``global_enum``, ``show_flag_values``
138154

139155
---------------
140156

@@ -573,6 +589,20 @@ Data Types
573589
better support the *replacement of existing constants* use-case.
574590
:meth:`__format__` was already :func:`int.__format__` for that same reason.
575591

592+
.. class:: ReprEnum
593+
594+
:class:`!ReprEum` uses the :meth:`repr() <Enum.__repr__>` of :class:`Enum`,
595+
but the :class:`str() <str>` of the mixed-in data type:
596+
597+
* :meth:`!int.__str__` for :class:`IntEnum` and :class:`IntFlag`
598+
* :meth:`!str.__str__` for :class:`StrEnum`
599+
600+
Inherit from :class:`!ReprEnum` to keep the :class:`str() <str> / :func:`format`
601+
of the mixed-in data type instead of using the
602+
:class:`Enum`-default :meth:`str() <Enum.__str__>`.
603+
604+
605+
.. versionadded:: 3.11
576606

577607
.. class:: EnumCheck
578608

@@ -808,6 +838,22 @@ Utilities and Decorators
808838

809839
.. versionadded:: 3.11
810840

841+
.. decorator:: global_enum
842+
843+
A decorator to change the :class:`str() <str>` and :func:`repr` of an enum
844+
to show its members as belonging to the module instead of its class.
845+
Should only be used when the enum members are exported
846+
to the module global namespace (see :class:`re.RegexFlag` for an example).
847+
848+
849+
.. versionadded:: 3.11
850+
851+
.. function:: show_flag_values(value)
852+
853+
Return a list of all power-of-two integers contained in a flag *value*.
854+
855+
.. versionadded:: 3.11
856+
811857
---------------
812858

813859
Notes

Doc/license.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,3 +987,28 @@ https://www.w3.org/TR/xml-c14n2-testcases/ and is distributed under the
987987
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
988988
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
989989
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
990+
991+
Audioop
992+
-------
993+
The audioop module uses the code base in g771.c file of the SoX project::
994+
Programming the AdLib/Sound Blaster
995+
FM Music Chips
996+
Version 2.0 (24 Feb 1992)
997+
Copyright (c) 1991, 1992 by Jeffrey S. Lee
998+
999+
Warranty and Copyright Policy
1000+
This document is provided on an "as-is" basis, and its author makes
1001+
no warranty or representation, express or implied, with respect to
1002+
its quality performance or fitness for a particular purpose. In no
1003+
event will the author of this document be liable for direct, indirect,
1004+
special, incidental, or consequential damages arising out of the use
1005+
or inability to use the information contained within. Use of this
1006+
document is at your own risk.
1007+
This file may be used and copied freely so long as the applicable
1008+
copyright notices are retained, and no modifications are made to the
1009+
text of the document. No money shall be charged for its distribution
1010+
beyond reasonable shipping, handling and duplication costs, nor shall
1011+
proprietary changes be made to this document so that it cannot be
1012+
distributed freely. This document may not be included in published
1013+
material or commercial packages without the written consent of its
1014+
author.

Lib/codecs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,8 @@ def open(filename, mode='r', encoding=None, errors='strict', buffering=-1):
878878
codecs. Output is also codec dependent and will usually be
879879
Unicode as well.
880880
881-
Underlying encoded files are always opened in binary mode.
881+
If encoding is not None, then the
882+
underlying encoded files are always opened in binary mode.
882883
The default file mode is 'r', meaning to open the file in read mode.
883884
884885
encoding specifies the encoding which is to be used for the

Lib/test/test_codecs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,8 @@ def test_decoder_state(self):
708708
"spamspam", self.spambe)
709709

710710
def test_bug691291(self):
711-
# Files are always opened in binary mode, even if no binary mode was
711+
# If encoding is not None, then
712+
# files are always opened in binary mode, even if no binary mode was
712713
# specified. This means that no automatic conversion of '\n' is done
713714
# on reading and writing.
714715
s1 = 'Hello\r\nworld\r\n'

Modules/audioop.c

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
/* The audioop module uses the code base in g777.c file of the Sox project.
2+
* Source: https://web.archive.org/web/19970716121258/http://www.spies.com/Sox/Archive/soxgamma.tar.gz
3+
* Programming the AdLib/Sound Blaster
4+
* FM Music Chips
5+
* Version 2.0 (24 Feb 1992)
6+
*
7+
* Copyright (c) 1991, 1992 by Jeffrey S. Lee
8+
*
9+
10+
*
11+
*
12+
*
13+
* Warranty and Copyright Policy
14+
*
15+
* This document is provided on an "as-is" basis, and its author makes
16+
* no warranty or representation, express or implied, with respect to
17+
* its quality performance or fitness for a particular purpose. In no
18+
* event will the author of this document be liable for direct, indirect,
19+
* special, incidental, or consequential damages arising out of the use
20+
* or inability to use the information contained within. Use of this
21+
* document is at your own risk.
22+
*
23+
* This file may be used and copied freely so long as the applicable
24+
* copyright notices are retained, and no modifications are made to the
25+
* text of the document. No money shall be charged for its distribution
26+
* beyond reasonable shipping, handling and duplication costs, nor shall
27+
* proprietary changes be made to this document so that it cannot be
28+
* distributed freely. This document may not be included in published
29+
* material or commercial packages without the written consent of its
30+
* author. */
131

232
/* audioopmodule - Module to detect peak values in arrays */
333

@@ -28,20 +58,6 @@ fbound(double val, double minval, double maxval)
2858
}
2959

3060

31-
/* Code shamelessly stolen from sox, 12.17.7, g711.c
32-
** (c) Craig Reese, Joe Campbell and Jeff Poskanzer 1989 */
33-
34-
/* From g711.c:
35-
*
36-
* December 30, 1994:
37-
* Functions linear2alaw, linear2ulaw have been updated to correctly
38-
* convert unquantized 16 bit values.
39-
* Tables for direct u- to A-law and A- to u-law conversions have been
40-
* corrected.
41-
* Borge Lindberg, Center for PersonKommunikation, Aalborg University.
42-
43-
*
44-
*/
4561
#define BIAS 0x84 /* define the add-in bias for 16 bit samples */
4662
#define CLIP 32635
4763
#define SIGN_BIT (0x80) /* Sign bit for an A-law byte. */

0 commit comments

Comments
 (0)