Skip to content

Commit 740cb40

Browse files
committed
Merge branch 'hashlib-fips-oddmode' into multiprocessing-forkserver-no-hmac-disable
2 parents adfd6c7 + 7a5ab6c commit 740cb40

26 files changed

+308
-212
lines changed

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pydoc-topics: build
144144

145145
.PHONY: gettext
146146
gettext: BUILDER = gettext
147-
gettext: SPHINXOPTS += -d build/doctrees-gettext
147+
gettext: override SPHINXOPTS := -d build/doctrees-gettext $(SPHINXOPTS)
148148
gettext: build
149149

150150
.PHONY: htmlview

Doc/library/hashlib.rst

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,14 @@ hash supplied more than 2047 bytes of data at once in its constructor or
5555
.. index:: single: OpenSSL; (use in module hashlib)
5656

5757
Constructors for hash algorithms that are always present in this module are
58-
:func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, :func:`sha512`,
58+
:func:`md5`, :func:`sha1`, :func:`sha224`, :func:`sha256`, :func:`sha384`, :func:`sha512`,
5959
:func:`sha3_224`, :func:`sha3_256`, :func:`sha3_384`, :func:`sha3_512`,
6060
:func:`shake_128`, :func:`shake_256`, :func:`blake2b`, and :func:`blake2s`.
61-
:func:`md5` is normally available as well, though it may be missing or blocked
62-
if you are using a rare "FIPS compliant" build of Python.
61+
Some of these may be missing or blocked if you are running in an environment
62+
with OpenSSL's "FIPS mode" configured to exclude some hash algorithms from its
63+
default provider and are using a Python runtime built with that in mind. Such
64+
environments are unusual.
65+
6366
These correspond to :data:`algorithms_guaranteed`.
6467

6568
Additional algorithms may also be available if your Python distribution's
@@ -119,7 +122,7 @@ More condensed:
119122
Constructors
120123
------------
121124

122-
.. function:: new(name[, data], *, usedforsecurity=True)
125+
.. function:: new(name[, data], \*, usedforsecurity=True)
123126

124127
Is a generic constructor that takes the string *name* of the desired
125128
algorithm as its first parameter. It also exists to allow access to the
@@ -134,16 +137,16 @@ Using :func:`new` with an algorithm name:
134137
'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'
135138

136139

137-
.. function:: md5([, data], *, usedforsecurity=True)
138-
.. function:: sha1([, data], *, usedforsecurity=True)
139-
.. function:: sha224([, data], *, usedforsecurity=True)
140-
.. function:: sha256([, data], *, usedforsecurity=True)
141-
.. function:: sha384([, data], *, usedforsecurity=True)
142-
.. function:: sha512([, data], *, usedforsecurity=True)
143-
.. function:: sha3_224([, data], *, usedforsecurity=True)
144-
.. function:: sha3_256([, data], *, usedforsecurity=True)
145-
.. function:: sha3_384([, data], *, usedforsecurity=True)
146-
.. function:: sha3_512([, data], *, usedforsecurity=True)
140+
.. function:: md5([, data], \*, usedforsecurity=True)
141+
.. function:: sha1([, data], \*, usedforsecurity=True)
142+
.. function:: sha224([, data], \*, usedforsecurity=True)
143+
.. function:: sha256([, data], \*, usedforsecurity=True)
144+
.. function:: sha384([, data], \*, usedforsecurity=True)
145+
.. function:: sha512([, data], \*, usedforsecurity=True)
146+
.. function:: sha3_224([, data], \*, usedforsecurity=True)
147+
.. function:: sha3_256([, data], \*, usedforsecurity=True)
148+
.. function:: sha3_384([, data], \*, usedforsecurity=True)
149+
.. function:: sha3_512([, data], \*, usedforsecurity=True)
147150

148151
Named constructors such as these are faster than passing an algorithm name to
149152
:func:`new`.
@@ -156,9 +159,10 @@ Hashlib provides the following constant module attributes:
156159
.. data:: algorithms_guaranteed
157160

158161
A set containing the names of the hash algorithms guaranteed to be supported
159-
by this module on all platforms. Note that 'md5' is in this list despite
160-
some upstream vendors offering an odd "FIPS compliant" Python build that
161-
excludes it.
162+
by this module on all platforms. Note that the guarnatees do not hold true
163+
in the face of vendors offering "FIPS compliant" Python builds that exclude
164+
some algorithms entirely. Similarly when OpenSSL is used and its FIPS mode
165+
configuration disables some in the default provider.
162166

163167
.. versionadded:: 3.2
164168

Doc/whatsnew/3.14.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,14 @@ sys
576576
from other interpreters than the one it's called in.
577577

578578

579+
tkinter
580+
-------
581+
582+
* Make tkinter widget methods :meth:`!after` and :meth:`!after_idle` accept
583+
arguments passed by keyword.
584+
(Contributed by Zhikang Yan in :gh:`126899`.)
585+
586+
579587
unicodedata
580588
-----------
581589

InternalDocs/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# CPython Internals Documentation
32

43
The documentation in this folder is intended for CPython maintainers.

InternalDocs/adaptive.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ quality of specialization and keeping the overhead of specialization low.
9696
Specialized instructions must be fast. In order to be fast,
9797
specialized instructions should be tailored for a particular
9898
set of values that allows them to:
99+
99100
1. Verify that incoming value is part of that set with low overhead.
100101
2. Perform the operation quickly.
101102

@@ -107,9 +108,11 @@ For example, `LOAD_GLOBAL_MODULE` is specialized for `globals()`
107108
dictionaries that have a keys with the expected version.
108109

109110
This can be tested quickly:
111+
110112
* `globals->keys->dk_version == expected_version`
111113

112114
and the operation can be performed quickly:
115+
113116
* `value = entries[cache->index].me_value;`.
114117

115118
Because it is impossible to measure the performance of an instruction without
@@ -122,10 +125,11 @@ base instruction.
122125
### Implementation of specialized instructions
123126

124127
In general, specialized instructions should be implemented in two parts:
128+
125129
1. A sequence of guards, each of the form
126-
`DEOPT_IF(guard-condition-is-false, BASE_NAME)`.
130+
`DEOPT_IF(guard-condition-is-false, BASE_NAME)`.
127131
2. The operation, which should ideally have no branches and
128-
a minimum number of dependent memory accesses.
132+
a minimum number of dependent memory accesses.
129133

130134
In practice, the parts may overlap, as data required for guards
131135
can be re-used in the operation.

InternalDocs/changing_grammar.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Below is a checklist of things that may need to change.
3232
[`Include/internal/pycore_ast.h`](../Include/internal/pycore_ast.h) and
3333
[`Python/Python-ast.c`](../Python/Python-ast.c).
3434

35-
* [`Parser/lexer/`](../Parser/lexer/) contains the tokenization code.
35+
* [`Parser/lexer/`](../Parser/lexer) contains the tokenization code.
3636
This is where you would add a new type of comment or string literal, for example.
3737

3838
* [`Python/ast.c`](../Python/ast.c) will need changes to validate AST objects
@@ -60,4 +60,4 @@ Below is a checklist of things that may need to change.
6060
to the tokenizer.
6161

6262
* Documentation must be written! Specifically, one or more of the pages in
63-
[`Doc/reference/`](../Doc/reference/) will need to be updated.
63+
[`Doc/reference/`](../Doc/reference) will need to be updated.

InternalDocs/compiler.md

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Compiler design
32
===============
43

@@ -7,8 +6,8 @@ Abstract
76

87
In CPython, the compilation from source code to bytecode involves several steps:
98

10-
1. Tokenize the source code [Parser/lexer/](../Parser/lexer/)
11-
and [Parser/tokenizer/](../Parser/tokenizer/).
9+
1. Tokenize the source code [Parser/lexer/](../Parser/lexer)
10+
and [Parser/tokenizer/](../Parser/tokenizer).
1211
2. Parse the stream of tokens into an Abstract Syntax Tree
1312
[Parser/parser.c](../Parser/parser.c).
1413
3. Transform AST into an instruction sequence
@@ -134,9 +133,8 @@ this case) a `stmt_ty` struct with the appropriate initialization. The
134133
`FunctionDef()` constructor function sets 'kind' to `FunctionDef_kind` and
135134
initializes the *name*, *args*, *body*, and *attributes* fields.
136135

137-
See also
138-
[Green Tree Snakes - The missing Python AST docs](https://greentreesnakes.readthedocs.io/en/latest)
139-
by Thomas Kluyver.
136+
See also [Green Tree Snakes - The missing Python AST docs](
137+
https://greentreesnakes.readthedocs.io/en/latest) by Thomas Kluyver.
140138

141139
Memory management
142140
=================
@@ -260,33 +258,33 @@ manually -- `generic`, `identifier` and `int`. These types are found in
260258
[Include/internal/pycore_asdl.h](../Include/internal/pycore_asdl.h).
261259
Functions and macros for creating `asdl_xx_seq *` types are as follows:
262260

263-
`_Py_asdl_generic_seq_new(Py_ssize_t, PyArena *)`
264-
Allocate memory for an `asdl_generic_seq` of the specified length
265-
`_Py_asdl_identifier_seq_new(Py_ssize_t, PyArena *)`
266-
Allocate memory for an `asdl_identifier_seq` of the specified length
267-
`_Py_asdl_int_seq_new(Py_ssize_t, PyArena *)`
268-
Allocate memory for an `asdl_int_seq` of the specified length
261+
* `_Py_asdl_generic_seq_new(Py_ssize_t, PyArena *)`:
262+
Allocate memory for an `asdl_generic_seq` of the specified length
263+
* `_Py_asdl_identifier_seq_new(Py_ssize_t, PyArena *)`:
264+
Allocate memory for an `asdl_identifier_seq` of the specified length
265+
* `_Py_asdl_int_seq_new(Py_ssize_t, PyArena *)`:
266+
Allocate memory for an `asdl_int_seq` of the specified length
269267

270268
In addition to the three types mentioned above, some ASDL sequence types are
271269
automatically generated by [Parser/asdl_c.py](../Parser/asdl_c.py) and found in
272270
[Include/internal/pycore_ast.h](../Include/internal/pycore_ast.h).
273271
Macros for using both manually defined and automatically generated ASDL
274272
sequence types are as follows:
275273

276-
`asdl_seq_GET(asdl_xx_seq *, int)`
277-
Get item held at a specific position in an `asdl_xx_seq`
278-
`asdl_seq_SET(asdl_xx_seq *, int, stmt_ty)`
279-
Set a specific index in an `asdl_xx_seq` to the specified value
274+
* `asdl_seq_GET(asdl_xx_seq *, int)`:
275+
Get item held at a specific position in an `asdl_xx_seq`
276+
* `asdl_seq_SET(asdl_xx_seq *, int, stmt_ty)`:
277+
Set a specific index in an `asdl_xx_seq` to the specified value
280278

281-
Untyped counterparts exist for some of the typed macros. These are useful
279+
Untyped counterparts exist for some of the typed macros. These are useful
282280
when a function needs to manipulate a generic ASDL sequence:
283281

284-
`asdl_seq_GET_UNTYPED(asdl_seq *, int)`
285-
Get item held at a specific position in an `asdl_seq`
286-
`asdl_seq_SET_UNTYPED(asdl_seq *, int, stmt_ty)`
287-
Set a specific index in an `asdl_seq` to the specified value
288-
`asdl_seq_LEN(asdl_seq *)`
289-
Return the length of an `asdl_seq` or `asdl_xx_seq`
282+
* `asdl_seq_GET_UNTYPED(asdl_seq *, int)`:
283+
Get item held at a specific position in an `asdl_seq`
284+
* `asdl_seq_SET_UNTYPED(asdl_seq *, int, stmt_ty)`:
285+
Set a specific index in an `asdl_seq` to the specified value
286+
* `asdl_seq_LEN(asdl_seq *)`:
287+
Return the length of an `asdl_seq` or `asdl_xx_seq`
290288

291289
Note that typed macros and functions are recommended over their untyped
292290
counterparts. Typed macros carry out checks in debug mode and aid
@@ -379,33 +377,33 @@ arguments to a node that used the '*' modifier).
379377

380378
Emission of bytecode is handled by the following macros:
381379

382-
* `ADDOP(struct compiler *, location, int)`
383-
add a specified opcode
384-
* `ADDOP_IN_SCOPE(struct compiler *, location, int)`
385-
like `ADDOP`, but also exits current scope; used for adding return value
386-
opcodes in lambdas and closures
387-
* `ADDOP_I(struct compiler *, location, int, Py_ssize_t)`
388-
add an opcode that takes an integer argument
389-
* `ADDOP_O(struct compiler *, location, int, PyObject *, TYPE)`
390-
add an opcode with the proper argument based on the position of the
391-
specified PyObject in PyObject sequence object, but with no handling of
392-
mangled names; used for when you
393-
need to do named lookups of objects such as globals, consts, or
394-
parameters where name mangling is not possible and the scope of the
395-
name is known; *TYPE* is the name of PyObject sequence
396-
(`names` or `varnames`)
397-
* `ADDOP_N(struct compiler *, location, int, PyObject *, TYPE)`
398-
just like `ADDOP_O`, but steals a reference to PyObject
399-
* `ADDOP_NAME(struct compiler *, location, int, PyObject *, TYPE)`
400-
just like `ADDOP_O`, but name mangling is also handled; used for
401-
attribute loading or importing based on name
402-
* `ADDOP_LOAD_CONST(struct compiler *, location, PyObject *)`
403-
add the `LOAD_CONST` opcode with the proper argument based on the
404-
position of the specified PyObject in the consts table.
405-
* `ADDOP_LOAD_CONST_NEW(struct compiler *, location, PyObject *)`
406-
just like `ADDOP_LOAD_CONST_NEW`, but steals a reference to PyObject
407-
* `ADDOP_JUMP(struct compiler *, location, int, basicblock *)`
408-
create a jump to a basic block
380+
* `ADDOP(struct compiler *, location, int)`:
381+
add a specified opcode
382+
* `ADDOP_IN_SCOPE(struct compiler *, location, int)`:
383+
like `ADDOP`, but also exits current scope; used for adding return value
384+
opcodes in lambdas and closures
385+
* `ADDOP_I(struct compiler *, location, int, Py_ssize_t)`:
386+
add an opcode that takes an integer argument
387+
* `ADDOP_O(struct compiler *, location, int, PyObject *, TYPE)`:
388+
add an opcode with the proper argument based on the position of the
389+
specified PyObject in PyObject sequence object, but with no handling of
390+
mangled names; used for when you
391+
need to do named lookups of objects such as globals, consts, or
392+
parameters where name mangling is not possible and the scope of the
393+
name is known; *TYPE* is the name of PyObject sequence
394+
(`names` or `varnames`)
395+
* `ADDOP_N(struct compiler *, location, int, PyObject *, TYPE)`:
396+
just like `ADDOP_O`, but steals a reference to PyObject
397+
* `ADDOP_NAME(struct compiler *, location, int, PyObject *, TYPE)`:
398+
just like `ADDOP_O`, but name mangling is also handled; used for
399+
attribute loading or importing based on name
400+
* `ADDOP_LOAD_CONST(struct compiler *, location, PyObject *)`:
401+
add the `LOAD_CONST` opcode with the proper argument based on the
402+
position of the specified PyObject in the consts table.
403+
* `ADDOP_LOAD_CONST_NEW(struct compiler *, location, PyObject *)`:
404+
just like `ADDOP_LOAD_CONST_NEW`, but steals a reference to PyObject
405+
* `ADDOP_JUMP(struct compiler *, location, int, basicblock *)`:
406+
create a jump to a basic block
409407

410408
The `location` argument is a struct with the source location to be
411409
associated with this instruction. It is typically extracted from an
@@ -433,7 +431,7 @@ Finally, the sequence of pseudo-instructions is converted into actual
433431
bytecode. This includes transforming pseudo instructions into actual instructions,
434432
converting jump targets from logical labels to relative offsets, and
435433
construction of the [exception table](exception_handling.md) and
436-
[locations table](locations.md).
434+
[locations table](code_objects.md#source-code-locations).
437435
The bytecode and tables are then wrapped into a `PyCodeObject` along with additional
438436
metadata, including the `consts` and `names` arrays, information about function
439437
reference to the source code (filename, etc). All of this is implemented by
@@ -453,7 +451,7 @@ in [Python/ceval.c](../Python/ceval.c).
453451
Important files
454452
===============
455453

456-
* [Parser/](../Parser/)
454+
* [Parser/](../Parser)
457455

458456
* [Parser/Python.asdl](../Parser/Python.asdl):
459457
ASDL syntax file.
@@ -534,7 +532,7 @@ Important files
534532
* [Python/instruction_sequence.c](../Python/instruction_sequence.c):
535533
A data structure representing a sequence of bytecode-like pseudo-instructions.
536534

537-
* [Include/](../Include/)
535+
* [Include/](../Include)
538536

539537
* [Include/cpython/code.h](../Include/cpython/code.h)
540538
: Header file for [Objects/codeobject.c](../Objects/codeobject.c);
@@ -556,7 +554,7 @@ Important files
556554
: Declares `_PyAST_Validate()` external (from [Python/ast.c](../Python/ast.c)).
557555

558556
* [Include/internal/pycore_symtable.h](../Include/internal/pycore_symtable.h)
559-
: Header for [Python/symtable.c](../Python/symtable.c).
557+
: Header for [Python/symtable.c](../Python/symtable.c).
560558
`struct symtable` and `PySTEntryObject` are defined here.
561559

562560
* [Include/internal/pycore_parser.h](../Include/internal/pycore_parser.h)
@@ -570,7 +568,7 @@ Important files
570568
by
571569
[Tools/cases_generator/opcode_id_generator.py](../Tools/cases_generator/opcode_id_generator.py).
572570

573-
* [Objects/](../Objects/)
571+
* [Objects/](../Objects)
574572

575573
* [Objects/codeobject.c](../Objects/codeobject.c)
576574
: Contains PyCodeObject-related code.
@@ -579,7 +577,7 @@ Important files
579577
: Contains the `frame_setlineno()` function which should determine whether it is allowed
580578
to make a jump between two points in a bytecode.
581579

582-
* [Lib/](../Lib/)
580+
* [Lib/](../Lib)
583581

584582
* [Lib/opcode.py](../Lib/opcode.py)
585583
: opcode utilities exposed to Python.
@@ -591,7 +589,7 @@ Important files
591589
Objects
592590
=======
593591

594-
* [Locations](locations.md): Describes the location table
592+
* [Locations](code_objects.md#source-code-locations): Describes the location table
595593
* [Frames](frames.md): Describes frames and the frame stack
596594
* [Objects/object_layout.md](../Objects/object_layout.md): Describes object layout for 3.11 and later
597595
* [Exception Handling](exception_handling.md): Describes the exception table

0 commit comments

Comments
 (0)