A couple of fixes here to make this more PEP-8:
* Avoid multiple statements on one line with `;` statement separator -- this is very rare in Python and is "generally discouraged" in PEP 8 (and if used, per PEP 8 there shouldn't be a space before the `;`)
* Add output for the first "Formatted String Literals" example. (Side note: are the doctests for this being run? If so, why didn't it fail?)
* Avoid space before `!r`. I have generally not seen spaces before the `!`, and this also matches the style used in the docs here: https://docs.python.org/3/library/string.htmlGH-format-string-syntaxhttps://bugs.python.org/issue34712
(cherry picked from commit 3705b98620)
Co-authored-by: Ben Hoyt <benhoyt@gmail.com>
The `gather` method requires to close the parenthesis, but it is being closed twice.
(cherry picked from commit 9c53fa6ad9)
Co-authored-by: Miguel Ángel García <magmax@users.noreply.github.com>
* bpo-34589: Make _PyCoreConfig.coerce_c_locale private (GH-9371)
_PyCoreConfig:
* Rename coerce_c_locale to _coerce_c_locale
* Rename coerce_c_locale_warn to _coerce_c_locale_warn
These fields are now private (name prefixed by "_").
(cherry picked from commit 188ebfa475)
* bpo-34589: C locale coercion off by default (GH-9073)
Py_Initialize() and Py_Main() cannot enable the C locale coercion
(PEP 538) anymore: it is always disabled. It can now only be enabled
by the Python program ("python3).
test_embed: get_filesystem_encoding() doesn't have to set PYTHONUTF8
nor PYTHONCOERCECLOCALE, these variables are already set in the
parent.
(cherry picked from commit 7a0791b699)
* bpo-34589: Add -X coerce_c_locale command line option (GH-9378)
Add a new -X coerce_c_locale command line option to control C locale
coercion (PEP 538).
(cherry picked from commit dbdee0073c)
Co-authored-by: Benjamin Peterson <benjamin@python.org>
(cherry picked from commit ad8a000420)
Co-authored-by: Tony Flury <anthony.flury@btinternet.com>
Returning EINTR from pthread semaphore or lock acquisition is an optional POSIX
feature. musl does not provide this feature, so some threadsignal tests fail
when Python is built against it.
There's no good way to test for musl, so we skip if we're on Linux and not using
glibc pthreads.
Also, hedge in the threading documentation about when we can provide interrupts
from lock acquisition.
(cherry picked from commit 5b10d5111d)
Co-authored-by: Benjamin Peterson <benjamin@python.org>
Mention the implicit cache in struct.Struct() docs.
Consistent with the re.compile documentation note.
(cherry picked from commit 3666b3c1f6)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Remove ellipsis that look like continuation prompts,
has a side benefit of putting rest of error message in proper text color.
(cherry picked from commit f019579828)
Co-authored-by: Lew Kurtz <37632626+lew18@users.noreply.github.com>
Some methods of the SMTP class use mutable default arguments. Specially
`send_message` is affected as it mutates one of the args by appending items
to it, which has side effects on further calls.
(cherry picked from commit d5fbe9b1a3)
Co-authored-by: Pablo Aguiar <scorphus@gmail.com>
... by removing a superfluous "either".
Reported by Никита Люшненко on docs@.
(cherry picked from commit 98b976a2f8)
Co-authored-by: Zachary Ware <zachary.ware@gmail.com>
If a globals dictionary without a '__builtins__' key is passed to
eval(), a '__builtins__' key will be inserted to the dictionary:
>>> eval("print('__builtins__' in globals())", {})
True
(As a result of this behavior, we can use the builtins
print() and globals() even if we passed a dictionary without a
'__builtins__' key to eval().)
(cherry picked from commit 225b055480)
Co-authored-by: Berker Peksag <berker.peksag@gmail.com>
The http_response() and https_response() methods of the HTTPErrorProcessor
class have two required parameters, 'request' and 'response'.
(cherry picked from commit c53aaec793)
Co-authored-by: Sebastian Rittau <srittau@rittau.org>
In the documentation, the `env` directory is specified when we execute
the `make venv` command. But in the code, `make venv` will create the
virtualenv inside the `venv` directory (defined by `VENVDIR`)
(cherry picked from commit 599bfa18f8)
Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
* bpo-34273: Change 'Fixed point' to 'Fixed-point notation'.
The change in the mini language floating point and decimal table
is consistent with 'Exponential notation' and clarifies that we
are referring to the output notation, not an object type.
* Update string.rst
* Update string.rst
* Update string.rst
* Update string.rst
(cherry picked from commit 28c7f8c8ce)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
In the documentation for the traceback module, the definitions of functions
extract_tb(), format_list() and classmethod StackSummary.from_list()
mention the old style 4-tuples that these functions used to return or accept.
Since Python 3.5, however, they return or accept a FrameSummary object
instead of a 4-tuple, or a StackSummary object instead of a list of 4-tuples.
Co-authored-by: torsava <torsava@redhat.com>
Co-Authored-By: Berker Peksag <berker.peksag@gmail.com>
(cherry picked from commit f394ee5eaf)
* help(hashlib) didn't work because of incorrect module name in blake2b and
blake2s classes.
* Constructors blake2*(), sha3_*(), shake_*() and keccak_*() incorrectly
accepted keyword argument "string" for binary data, but documented as
accepting the "data" keyword argument. Now this parameter is positional-only.
* Keyword-only parameters in blake2b() and blake2s() were not documented as
keyword-only.
* Default value for some parameters of blake2b() and blake2s() was None,
which is not acceptable value.
* The length argument for shake_*.digest() was wrapped out to 32 bits.
* The argument for shake_128.digest() and shake_128.hexdigest() was not
positional-only as intended.
* TypeError messages for incorrect arguments in all constructors sha3_*(),
shake_*() and keccak_*() incorrectly referred to sha3_224.
Also made the following enhancements:
* More accurately specified input and result types for strings, bytes and
bytes-like objects.
* Unified positional parameter names for update() and constructors.
* Improved formatting.
(cherry picked from commit f1d36d8efa)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Mathematically, bitwise operations on integers behave as if there were an
infinite number of sign bits. Pragmatically, that gives the same answer as
using one extra sign bit for the bitwise logical operations.
(cherry picked from commit b4bc5cab82)
Co-authored-by: Sanyam Khurana <8039608+CuriousLearner@users.noreply.github.com>
Clarify how to bind to all interfaces using socket
(cherry picked from commit 95dfb9c3ae)
Co-authored-by: johnthagen <johnthagen@users.noreply.github.com>
Also, update the list of exceptions that may raised by PyMarshal_*
functions. We usually don't document exceptions raised by a
function, but in this case most of them were already documented
in C API and standard library documentation.
(cherry picked from commit defcffdf86)
Co-authored-by: Berker Peksag <berker.peksag@gmail.com>
The script will exit with the number 0 (zero), instead of the letter O.
(cherry picked from commit 95d34c2a37)
Co-authored-by: Mariatta <Mariatta@users.noreply.github.com>
Many users won't realise the implications the OpenSSL 1.0.2
minimum version requirement has when it comes to Ubuntu
14.04 and Debian 8, so expand on that in the platform support
section.
Also explicitly note the non-ASCII-based locale requirement for
full Unicode text handling support on non-Windows systems.
(cherry picked from commit 5fe7c98a54)
Co-authored-by: Nick Coghlan <ncoghlan@gmail.com>
Include a more easily understood example for nullcontext
(cherry picked from commit c287545d62)
Co-authored-by: Daniel Porteous <danielporteous1@gmail.com>
The 'output formatting' section of the tutorial talks a lot about manual formatting with things like .rjust() and .zfill(), with only a passing reference to 3.6's new f-strings.
This doesn't drop all of the old material, but it does rearrange the topics into a more modern order: f-strings first, discussing formatting specifiers a bit; then calling .format(); finally manual formatting with .ljust().
(cherry picked from commit ced350b195)
Co-authored-by: Andrew Kuchling <amk@amk.ca>
Make the change where discussing the CPython implementation of lists and dicts.
(cherry picked from commit 8d41278045)
Co-authored-by: Andrés Delfino <adelfino@gmail.com>