summaryrefslogtreecommitdiffstats
path: root/Lib
Commit message (Collapse)AuthorAgeFilesLines
* gh-121798: Add class method Decimal.from_number() (GH-121801)Serhiy Storchaka2024-10-142-0/+38
| | | | | | It is an alternate constructor which only accepts a single numeric argument. Unlike to Decimal.from_float() it accepts also Decimal. Unlike to the standard constructor, it does not accept strings and tuples.
* gh-121797: Add class method Fraction.from_number() (GH-121800)Serhiy Storchaka2024-10-142-8/+66
| | | | | | | | It is an alternative constructor which only accepts a single numeric argument. Unlike to Fraction.from_float() and Fraction.from_decimal() it accepts any real numbers supported by the standard constructor (int, float, Decimal, Rational numbers, objects with as_integer_ratio()). Unlike to the standard constructor, it does not accept strings.
* gh-86357: argparse: use str() consistently and explicitly to print choices ↵rindeal2024-10-142-8/+35
| | | | | (GH-117766) Signed-off-by: Jan Chren ~rindeal <dev.rindeal@gmail.com>
* GH-125069: Fix inconsistent joining in `WindowsPath(PosixPath(...))` (#125156)Barney Gale2024-10-132-2/+11
| | | | | | | | | | `PurePath.__init__()` incorrectly uses the `_raw_paths` of a given `PurePath` object with a different flavour, even though the procedure to join path segments can differ between flavours. This change makes the `_raw_paths`-enabled deferred joining apply _only_ when the path flavours match. Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
* gh-89967: make WeakKeyDictionary and WeakValueDictionary thread safe (#125325)Kumar Aditya2024-10-132-174/+49
| | | Make `WeakKeyDictionary` and `WeakValueDictionary` thread safe by copying the underlying the dict before iterating over it.
* gh-61698: Use launchctl to detect macOS window manager in tests (#118390)Erlend E. Aasland2024-10-131-15/+9
|
* gh-86673: Loosen test_ttk.test_identify() requirements (#125335)Erlend E. Aasland2024-10-131-5/+5
| | | In aeca373b3 (PR gh-12011, issue gh-71500), test_identify() was changed to expect different results on Darwin. Ned's fix was later adjusted by e52f9bee8. This workaround is only needed for some variants of Tk/Tcl on macOS, so we now allow both the workaround and the generic results for these tests.
* Trivial change: Update comments in activate about what running hash -r does ↵Andrew Athan2024-10-131-2/+3
| | | | | | | (GH-125385) Update comments about what running hash -r does The old comment said "hash -r" forgets "past commands." However, the documentation for "hash" states that it forgets past locations. The old comment was, in my opinion, confusing. This is because it could be interpreted to mean it does something to the command history (HISTORY/HISTFILE etc) vs the cache of locations.
* gh-53203: Fix strptime() for %c and %x formats on many locales (GH-124946)Serhiy Storchaka2024-10-122-34/+129
| | | | | | | | | | | | | | | | | | | In some locales (like French or Hebrew) the full or abbreviated names of the default month and weekday used in __calc_date_time can be part of other name or constant part of the %c format. The month name can also match %m with constant suffix (like in Japanese). So the code failed to correctly distinguish formats %a, %A, %b, %B and %m. Cycle all month and all days of the week to find the variable part and distinguish %a from %A and %b from %B or %m. Fixed locales for the following languges: Arabic, Bislama, Breton, Bodo, Kashubian, Chuvash, Estonian, French, Irish, Ge'ez, Gurajati, Manx Gaelic, Hebrew, Hindi, Chhattisgarhi, Haitian Kreyol, Japanese, Kannada, Korean, Marathi, Malay, Norwegian, Nynorsk, Punjabi, Rajasthani, Tok Pisin, Yoruba, Yue Chinese, Yau/Nungon and Chinese. Co-authored-by: Eli Bendersky <eliben@gmail.com>
* gh-125260: Change the default ``gzip.compress()`` mtime to 0 (#125261)Bernhard M. Wiedemann2024-10-122-3/+14
| | | | | | | | | This follows GNU gzip, which defaults to using 0 as the mtime for compressing stdin, where no file mtime is involved. This makes the output of gzip.compress() deterministic by default, greatly helping reproducible builds. Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
* gh-85935: Check for nargs=0 for positional arguments in argparse (GH-124839)Serhiy Storchaka2024-10-122-3/+14
| | | | | | Raise ValueError in add_argument() if either explicit nargs=0 or action that does not consume arguments (like 'store_const' or 'store_true') is specified for positional argument.
* gh-125254: Fix error report about ambiguous option in argparse (GH-125273)Serhiy Storchaka2024-10-122-3/+13
| | | | | This was a regression introduced in gh-58573. It was only tested for the case when the ambiguous option is the last argument in the command line.
* gh-59330: Improve error message for dest= for positionals (GH-125215)Serhiy Storchaka2024-10-122-2/+4
| | | | | | | Also improve the documentation. Specify how dest and metavar are derived from add_argument() positional arguments. Co-authored-by: Simon Law <sfllaw@sfllaw.ca>
* gh-65865: Raise early errors for invalid help strings in argparse (GH-124899)Serhiy Storchaka2024-10-122-7/+55
|
* gh-124309: fix staggered race on eager tasks (#124847)Thomas Grainger2024-10-113-3/+87
| | | | | | | This patch is entirely by Thomas and Peter Co-authored-by: Thomas Grainger <tagrain@gmail.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* gh-116938: Clarify documentation of `dict` and `dict.update` regarding the ↵Victorien2024-10-111-1/+1
| | | | | | positional argument they accept (#125213) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-124917: Allow keyword args to os.path.exists/lexists on Windows (#124918)Jelle Zijlstra2024-10-111-0/+4
|
* gh-124787: Fix `TypeAliasType` and incorrect `type_params` (#124795)sobolevn2024-10-111-1/+43
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-61011: Fix inheritance of nested mutually exclusive groups in argparse ↵Serhiy Storchaka2024-10-112-1/+34
| | | | | | | | | (GH-125210) Previously, all nested mutually exclusive groups lost their connection to the group containing them and were displayed as belonging directly to the parser. Co-authored-by: Danica J. Sutherland <djsutherland@users.noreply.github.com>
* GH-125174: Make immortal objects more robust, following design from PEP 683 ↵Mark Shannon2024-10-101-2/+2
| | | | (GH-125251)
* gh-124570: ctypes: Run some Structure tests on Union as well (GH-124976)Petr Viktorin2024-10-103-357/+368
| | | | | | | | - Move some Structure tests to test_structunion; use a common base test class + two subclasses to run them on Union too - Remove test_union for now as it's redundant Note: `test_simple_structs` & `test_simple_unions` are in the common file because they share `formats`.
* gh-125118: don't copy arbitrary values to _Bool in the struct module (GH-125169)Sergey B Kirpichev2024-10-101-0/+3
| | | | | | | | | | | memcopy'ing arbitrary values to _Bool variable triggers undefined behaviour. Avoid this. We assume that `false` is represented by all zero bytes. Credits to Alex Gaynor. Co-authored-by: Sam Gross <colesbury@gmail.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Petr Viktorin <encukou@gmail.com>
* gh-125196: Use PyUnicodeWriter for repr(contextvars.Token) (#125220)Victor Stinner2024-10-091-0/+8
| | | Replace the private _PyUnicodeWriter with the public PyUnicodeWriter.
* gh-124969: Skip the test for ALT_DIGITS also on iOS (#125177)Serhiy Storchaka2024-10-091-2/+2
| | | Skip the locale.ALT_DIGITS test on all Apple platforms, not just macOS.
* gh-125140: Remove the current directory from sys.path when using pyrepl ↵Pablo Galindo Salgado2024-10-091-3/+8
| | | | | | | (GH-125212) Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* GH-124693: Support parsing negative scientific and complex numbers argparse ↵Savannah Ostrowski2024-10-092-8/+21
| | | | | (GH-124823) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-91818: Use default program name in the CLI of many modules (GH-124867)Serhiy Storchaka2024-10-099-12/+10
| | | | | | As argparse now detects by default when the code was run as a module. This leads to using the actual executable name instead of simply "python" to display in the usage message ("usage: python -m ...").
* gh-125039: Make `this_instr`/`prev_instr` const in cases generator (GH-125071)Tomas R.2024-10-091-3/+3
|
* gh-107562: Update test certificates to expire far in the future (GH-125104)Petr Viktorin2024-10-0920-1157/+1163
| | | | | Generated with Lib/test/certdata/make_ssl_certs.py using openssl-3.2.2-3.fc40.x86_64 (Fedora 40).
* gh-107562: make_ssl_certs.py: produce test certificates that expire far in ↵Alexander Kanavin2024-10-092-2/+3
| | | | | | | | | the future by default (GH-107594) This allows testing Y2038 with system time set to after that, so that actual Y2038 issues can be exposed, and not masked by expired certificate errors. Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
* gh-124969: Fix locale.nl_langinfo(locale.ALT_DIGITS) (GH-124974)Serhiy Storchaka2024-10-091-1/+40
| | | | | Now it returns a tuple of up to 100 strings (an empty tuple on most locales). Previously it returned the first item of that tuple or an empty string.
* gh-125150: Skip test_fma_zero_result on NetBSD due to IEE 754-2008 ↵Furkan Onder2024-10-091-1/+1
| | | | | implementation issues (#125151) Skip test_fma_zero_result on NetBSD due to IEE 754-2008 implementation issues
* gh-101552: Allow pydoc to display signatures in source format (#124669)Jelle Zijlstra2024-10-095-23/+81
| | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-123849: Fix test_sqlite3.test_table_dump when foreign keys are enabled by ↵Mariusz Felisiak2024-10-081-1/+2
| | | | default (#123859)
* gh-116110: remove extra processing for the __signature__ attribute (GH-116234)Sergey B Kirpichev2024-10-083-48/+16
| | | This is an alternative to GH-100168.
* gh-125063: Emit slices as constants in the bytecode compiler (#125064)Michael Droettboom2024-10-081-2/+25
| | | | | | | | | | | | | | | | | | | | | | | * Make slices marshallable * Emit slices as constants * Update Python/marshal.c Co-authored-by: Peter Bierma <zintensitydev@gmail.com> * Refactor codegen_slice into two functions so it always has the same net effect * Fix for free-threaded builds * Simplify marshal loading of slices * Only return SUCCESS/ERROR from codegen_slice --------- Co-authored-by: Mark Shannon <mark@hotpy.org> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* gh-125096: Don't import _pyrepl in site if PYTHON_BASIC_REPL (#125097)Victor Stinner2024-10-082-7/+31
| | | | | | | If the PYTHON_BASIC_REPL environment variable is set, the site module no longer imports the _pyrepl module. Moreover, the site module now respects -E and -I command line options: ignore PYTHON_BASIC_REPL in this case.
* gh-90102: Fix pyio _isatty_open_only() (#125089)Cody Maloney2024-10-081-1/+1
| | | | | | | Spotted by @ngnpope. `isatty` returns False to indicate the file is not a TTY. The C implementation of _io does that (`Py_RETURN_FALSE`) but I got the bool backwards in the _pyio implementaiton.
* gh-123378: fix a crash in `UnicodeError.__str__` (#124935)Bénédikt Tran2024-10-081-0/+24
|
* gh-53203: Improve tests for strptime() (GH-125090)Serhiy Storchaka2024-10-0810-85/+200
| | | | | | | | | | Run them with different locales and different date and time. Add the @run_with_locales() decorator to run the test with multiple locales. Improve the run_with_locale() context manager/decorator -- it now catches only expected exceptions and reports the test as skipped if no appropriate locale is available.
* bpo-34206: Improve docs and test coverage for pre-init functions (#8023)Alyssa Coghlan2024-10-081-1/+10
| | | | | | | | | | | | | | | | | | | | - move the Py_Main documentation from the very high level API section to the initialization and finalization section - make it clear that it encapsulates a full Py_Initialize/Finalize cycle of its own - point out that exactly which settings will be read and applied correctly when Py_Main is called after a separate runtime initialization call is version dependent - be explicit that Py_IsInitialized can be called prior to initialization - actually test that Py_IsInitialized can be called prior to initialization - flush stdout in the embedding tests that run code so it appears in the expected order when running with "-vv" - make "-vv" on the subinterpreter embedding tests less spammy --------- Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
* gh-69998: Fix decoding error in locale.nl_langinfo() (GH-124963)Serhiy Storchaka2024-10-081-4/+8
| | | | | | | The function now sets temporarily the LC_CTYPE locale to the locale of the category that determines the requested value if the locales are different and the resulting string is non-ASCII. This temporary change affects other threads.
* gh-90102: Remove isatty call during regular open (#124922)Cody Maloney2024-10-081-1/+16
| | | Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-125072: Add label for assignment expressions; update tracked section for ↵Emily Morehouse2024-10-071-27/+37
| | | | assignment expression topic (#125074)
* gh-124502: Add PyUnicode_Equal() function (#124504)Victor Stinner2024-10-072-0/+34
|
* gh-122392: IDLE - Fix overlapping lines in browsers (#122392) (#124975)Zhikang Yan2024-10-071-4/+10
| | | | | | | Increase currently inadequate vertical spacing for the IDLE browsers (path, module, and stack) on high-resolution monitors. --------- Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
* gh-124653: Relax (again) detection of queue API for logging handlers ↵Bénédikt Tran2024-10-072-51/+71
| | | | (GH-124897)
* gh-120762: make_ssl_certs: Don't set extensions for the temporary CSR ↵Petr Viktorin2024-10-071-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-125045) gh-120762: make_ssl_certs: Don't set extensions for the CSR `openssl req` fails with openssl 3.2.2 because the config line authorityKeyIdentifier = keyid:always,issuer:always is not supported for certificate signing requests (since the issuing certificate authority is not known). David von Oheimb, the OpenSSL dev that made the change, commented in: https://github.com/openssl/openssl/issues/22966#issuecomment-1858396738 : > This problem did not show up in older OpenSSL versions because of a bug: > the `req` app ignored the `-extensions` option unless `-x505` is given, > which I fixed in https://github.com/openssl/openssl/pull/16865. (I assume `-x505` is a typo for `-x509`.) In our `make_cert_key` function: If `sign` is true: - We don't pass `-x509` to `req`, so in this case it should be safe to omit the `-extensions` argument. (Old OpenSSL ignores it, new OpenSSL fails on it.) - The extensions are passed to the `ca` call later in the function. There they take effect, and `authorityKeyIdentifier` is valid. If `sign` is false, this commit has no effect except rearranging the CLI arguments.
* GH-119866: Spill the stack around escaping calls. (GH-124392)Mark Shannon2024-10-074-90/+282
| | | | | | | * Spill the evaluation around escaping calls in the generated interpreter and JIT. * The code generator tracks live, cached values so they can be saved to memory when needed. * Spills the stack pointer around escaping calls, so that the exact stack is visible to the cycle GC.
* gh-121249: Support _Complex types in the struct module (#121613)Sergey B Kirpichev2024-10-072-1/+38
| | | | | Co-authored-by: Peter Bierma <zintensitydev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>