summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* gh-67790: Support float-style formatting for Fraction instances (#100161)Mark Dickinson2023-01-225-0/+618
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR adds support for float-style formatting for `Fraction` objects: it supports the `"e"`, `"E"`, `"f"`, `"F"`, `"g"`, `"G"` and `"%"` presentation types, and all the various bells and whistles of the formatting mini-language for those presentation types. The behaviour almost exactly matches that of `float`, but the implementation works with the exact `Fraction` value and does not do an intermediate conversion to `float`, and so avoids loss of precision or issues with numbers that are outside the dynamic range of the `float` type. Note that the `"n"` presentation type is _not_ supported. That support could be added later if people have a need for it. There's one corner-case where the behaviour differs from that of float: for the `float` type, if explicit alignment is specified with a fill character of `'0'` and alignment type `'='`, then thousands separators (if specified) are inserted into the padding string: ```python >>> format(3.14, '0=11,.2f') '0,000,003.14' ``` The exact same effect can be achieved by using the `'0'` flag: ```python >>> format(3.14, '011,.2f') '0,000,003.14' ``` For `Fraction`, only the `'0'` flag has the above behaviour with respect to thousands separators: there's no special-casing of the particular `'0='` fill-character/alignment combination. Instead, we treat the fill character `'0'` just like any other: ```python >>> format(Fraction('3.14'), '0=11,.2f') '00000003.14' >>> format(Fraction('3.14'), '011,.2f') '0,000,003.14' ``` The `Fraction` formatter is also stricter about combining these two things: it's not permitted to use both the `'0'` flag _and_ explicit alignment, on the basis that we should refuse the temptation to guess in the face of ambiguity. `float` is less picky: ```python >>> format(3.14, '0<011,.2f') '3.140000000' >>> format(Fraction('3.14'), '0<011,.2f') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/mdickinson/Repositories/python/cpython/Lib/fractions.py", line 414, in __format__ raise ValueError( ValueError: Invalid format specifier '0<011,.2f' for object of type 'Fraction'; can't use explicit alignment when zero-padding ```
* Revert "gh-100795: avoid unexpected `freeaddrinfo` after failed ↵Kumar Aditya2023-01-222-4/+0
| | | | | | | `getaddrinfo` (#101220)" (#101238) Revert "gh-100795: avoid unexpected `freeaddrinfo` after failed `getaddrinfo` (#101220)" This reverts commit 5f08fe4a2c055880c23c6f9b57ff03005d193bfc.
* gh-100795: avoid unexpected `freeaddrinfo` after failed `getaddrinfo` (#101220)Sergey G. Brester2023-01-222-0/+4
| | | Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
* GH-88597: Added command line interface to UUID module. (#99463)achhina2023-01-226-0/+174
| | | | | | | | | | | | The `uuid` module now supports command line usage. ```python ❯ ./python.exe -m uuid 5f2d57b1-90e8-417c-ba5d-69b9b6f74289 ❯ ./python.exe -m uuid -h usage: uuid.py [-h] [-u {uuid1,uuid3,uuid4,uuid5}] [-ns NAMESPACE] [-n NAME] ... ```
* gh-100518: Add tests for `ast.NodeTransformer` (#100521)Nikita Sobolev2023-01-213-42/+171
|
* gh-100726: Optimize construction of range object for medium sized integers ↵Pieter Eendebak2023-01-213-0/+60
| | | | | | | | (#100810) Use C long arithmetic instead of PyLong arithmetic to compute the range length, where possible. Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
* gh-99266: ctypes: Preserve more detailed exception in `ArgumentError`Kamil Turek2023-01-215-7/+83
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* GH-92123: Move _elementtree heap types to module state (#101187)Erlend E. Aasland2023-01-213-68/+98
|
* gh-101037: Fix potential memory underallocation for zeros of int subtypes ↵Mark Dickinson2023-01-213-0/+10
| | | | | | | | | (#101038) This PR fixes object allocation in long_subtype_new to ensure that there's at least one digit in all cases, and makes sure that the value of that digit is copied over from the source long. Needs backport to 3.11, but not any further: the change to require at least one digit was only introduced for Python 3.11. Fixes #101037.
* gh-101143: Remove references to `TimerHandle` from ↵J. Nick Koston2023-01-212-6/+5
| | | | | `asyncio.base_events.BaseEventLoop._add_callback` (#101197) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* Bump Azure Pipelines to ubuntu-22.04 (#101089)Hugo van Kemenade2023-01-212-8/+8
|
* Fix rst formatting in 3.12 What's New (#101110)scrazzz2023-01-211-6/+6
|
* gh-91351: Fix some bugs in importlib handling of re-entrant imports (GH-94504)Jean-Paul Calderone2023-01-212-37/+201
| | | Co-authored-by: Brett Cannon <brett@python.org>
* gh-100750: pass encoding kwarg in lib/platform.py (#100751)Thomas Grainger2023-01-202-0/+3
| | | | Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
* gh-86610: Use attribute directive in docs for pathlib.PurePath (#101114)Barney Gale2023-01-201-14/+14
|
* GH-101111: Disambigaute origin of const for store_const and append_const ↵Jürgen Gmach2023-01-201-3/+3
| | | | | | | | | (#101121) While the documentation for `optparse` mentioned that both `store_const` and `append_const` store a constant value, it was not clear where this value was coming from. A link to `Option.const` makes this explicit.
* GH-101112: Specify type of pattern for Path.rglob (#101132)Jürgen Gmach2023-01-201-1/+2
| | | | | | | The documentation for `rglob` did not mention what `pattern` actually is. Mentioning and linking to `fnmatch` makes this explicit, as the documentation for `fnmatch` both shows the syntax and some explanation.
* Fix a typo in whatsnew/3.12.rst (#101150)caozhanhao2023-01-201-1/+1
|
* Fix minor typos in SSL documentation (#101158)Simon Robinson2023-01-201-8/+8
|
* gh-91485: Avoid unnecessary use of non-Python syntax in io docs (#101177)Shantanu2023-01-201-2/+2
|
* Fix typo in comment in compile.c (#101194)Ikko Eltociear Ashimine2023-01-201-1/+1
|
* gh-101181: Fix `unused-variable` warning in `pystate.c` (#101188)Nikita Sobolev2023-01-201-0/+3
| | | Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
* gh-92123: Convert `_elementtree` types to heap types (#99221)Erlend E. Aasland2023-01-204-236/+185
|
* GH-90699: Clear interned strings in `_elementtree` (#101185)Erlend E. Aasland2023-01-201-0/+10
|
* Provided better example for logging cookbook (GH-101164)Vladimir Malinovskii2023-01-201-10/+31
| | | Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
* gh-88324: Clarify documentation for redirected stdout/stderr when using ↵richardhob2023-01-203-17/+19
| | | | | | | | | | | | subprocess in Linux (#94035) * Update description of stdout, stderr, and stdin. Changes: - Move the ``None`` option (which is default) to the front of the list of input options - Move the ``None`` option description up to make the default behavior more clear (No redirection) - Remove mention of Child File Descriptors from ``None`` option description
* gh-101144: Allow open and read_text encoding to be positional. (#101145)Gregory P. Smith2023-01-204-10/+95
| | | | | The zipfile.Path open() and read_text() encoding parameter can be supplied as a positional argument without causing a TypeError again. 3.10.0b1 included a regression that made it keyword only. Documentation update included as users writing code to be compatible with a wide range of versions will need to consider this for some time.
* gh-101100: [Enum] Fix sphinx warnings in docs (GH-101122)Nikita Sobolev2023-01-201-12/+12
| | | | | * gh-101100: [Enum] Fix sphinx warnings in Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
* gh-59956: Fix Function Groupings in pystate.c (gh-101172)Eric Snow2023-01-201-237/+352
| | | | | This is a follow-up to gh-101161. The objective is to make it easier to read Python/pystate.c by grouping the functions there in a consistent way. This exclusively involves moving code around and adding various kinds of comments. https://github.com/python/cpython/issues/59956
* gh-101167: fix bug in the new test.support.requires_specialization decorator ↵Irit Katriel2023-01-191-1/+2
| | | | | | | (GH-101171) Fixes #101167. Automerge-Triggered-By: GH:iritkatriel
* gh-101169: reduce the implementation of except* by one bytecode instruction ↵Irit Katriel2023-01-191-16/+11
| | | | (#101170)
* gh-59956: Clarify GILState-related Code (gh-101161)Eric Snow2023-01-1910-250/+373
| | | | | | | | | | The objective of this change is to help make the GILState-related code easier to understand. This mostly involves moving code around and some semantically equivalent refactors. However, there are a also a small number of slight changes in structure and behavior: * tstate_current is moved out of _PyRuntimeState.gilstate * autoTSSkey is moved out of _PyRuntimeState.gilstate * autoTSSkey is initialized earlier * autoTSSkey is re-initialized (after fork) earlier https://github.com/python/cpython/issues/59956
* gh-98831: register instructions have 0 pushes and pops (#101163)Irit Katriel2023-01-191-0/+1
|
* gh-100712: make it possible to disable specialization (for debugging) (#100713)Irit Katriel2023-01-1911-3/+87
|
* gh-100940: Change "char *str" to "const char *str" in KeywordToken: It is ↵Stepfen Shawn2023-01-181-1/+1
| | | | an immutable string. (#100936)
* gh-100340: Allows -Wno-int-conversion for wasm (#100341)Kushal Das2023-01-184-0/+47
| | | Fixes #100340 allows -Wno-int-conversion for wasm
* GH-98831: Move assorted macros from ceval.h to a new header (#101116)Guido van Rossum2023-01-184-385/+364
|
* fix typo in 3.12 What's New (#101105)Tushar Sadhwani2023-01-181-1/+1
|
* Docs: improve sqlite3 placeholders example (#101092)Erlend E. Aasland2023-01-181-13/+12
|
* Fix typo and old link in wasm readme (#101096)Zac Hatfield-Dodds2023-01-181-2/+2
|
* GH-98831: Implement array support in cases generator (#100912)Guido van Rossum2023-01-176-177/+398
| | | | | | | | You can now write things like this: ``` inst(BUILD_STRING, (pieces[oparg] -- str)) { ... } inst(LIST_APPEND, (list, unused[oparg-1], v -- list, unused[oparg-1])) { ... } ``` Note that array output effects are only partially supported (they must be named `unused` or correspond to an input effect).
* gh-82052: Don't send partial UTF-8 sequences to the Windows API (GH-101103)Paul Moore2023-01-172-1/+17
| | | Don't send partial UTF-8 sequences to the Windows API
* Fix typo in `ReprEnum` documentation (#101079)Viicos2023-01-171-1/+1
|
* gh-101046: Fix a potential memory leak in the parser when raising ↵Pablo Galindo Salgado2023-01-163-1/+111
| | | | MemoryError (#101051)
* gh-100247: Improve documentation for custom shebang commands in py.exe ↵Steve Dower2023-01-161-4/+5
| | | | launcher (GH-101083)
* gh-100320: Fix path calculations on Windows when python.exe is moved outside ↵Steve Dower2023-01-164-33/+54
| | | | of the normal location (GH-100947)
* GH-100982: Add `COMPARE_AND_BRANCH` instruction (GH-100983)Mark Shannon2023-01-1617-239/+267
|
* gh-101056: Fix memory leak in `formatfloat()` in `bytesobject.c` (#101057)Nikita Sobolev2023-01-161-1/+3
|
* Docs: Remove duplicate `TraversableResources` reference (#101068)scrazzz2023-01-161-1/+0
|
* GH-100997: fix refleak in `_testinternalcapi.c` (#101058)Kumar Aditya2023-01-161-0/+1
|