Skip to content

Commits on Dec 23, 2022

  1. gh-76963: PEP3118 itemsize of an empty ctypes array should not be 0 (G…

    …H-5576)
    
    The itemsize returned in a memoryview of a ctypes array is now computed from the item type, instead of dividing the total size by the length and assuming that the length is not zero.
    eric-wieser committed Dec 23, 2022

Commits on Dec 22, 2022

  1. gh-85432: Harmonise parameter names between C and pure-Python impleme…

    …ntations of `datetime.time.strftime`, `datetime.datetime.fromtimestamp` (#99993)
    AlexWaygood committed Dec 22, 2022
  2. gh-100344: Add C implementation for asyncio.current_task (#100345)

    Co-authored-by: pranavtbhat
    itamaro committed Dec 22, 2022

Commits on Dec 21, 2022

  1. gh-85267: Improvements to inspect.signature __text_signature__ handli…

    …ng (#98796)
    
    This makes a couple related changes to inspect.signature's behaviour
    when parsing a signature from `__text_signature__`.
    
    First, `inspect.signature` is documented as only raising ValueError or
    TypeError. However, in some cases, we could raise RuntimeError.  This PR
    changes that, thereby fixing #83685.
    
    (Note that the new ValueErrors in RewriteSymbolics are caught and then
    reraised with a message)
    
    Second, `inspect.signature` could randomly drop parameters that it
    didn't understand (corresponding to `return None` in the `p` function).
    This is the core issue in #85267. I think this is very surprising
    behaviour and it seems better to fail outright.
    
    Third, adding this new failure broke a couple tests. To fix them (and to
    e.g. allow `inspect.signature(select.epoll.register)` as in #85267), I
    add constant folding of a couple binary operations to RewriteSymbolics.
    
    (There's some discussion of making signature expression evaluation
    arbitrary powerful in #68155. I think that's out of scope. The
    additional constant folding here is pretty straightforward, useful, and
    not much of a slippery slope)
    
    Fourth, while #85267 is incorrect about the cause of the issue, it turns
    out if you had consecutive newlines in __text_signature__, you'd get
    `tokenize.TokenError`.
    
    Finally, the `if name is invalid:` code path was dead, since
    `parse_name` never returned `invalid`.
    hauntsaninja committed Dec 21, 2022

Commits on Dec 20, 2022

  1. gh-99576: Fix cookiejar file that was not truncated for some classes (G…

    …H-99616)
    
    Co-authored-by: Łukasz Langa <lukasz@langa.pl>
    sobolevn and ambv committed Dec 20, 2022
  2. gh-89051: Add ssl.OP_LEGACY_SERVER_CONNECT (#93927)

    Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
    Co-authored-by: Christian Heimes <christian@python.org>
    Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
    Fixes #89051
    graingert committed Dec 20, 2022

Commits on Dec 19, 2022

  1. gh-89727: Fix os.walk RecursionError on deep trees (#99803)

    Use a stack to implement os.walk iteratively instead of recursively to
    avoid hitting recursion limits on deeply nested trees.
    jonburdo committed Dec 19, 2022

Commits on Dec 18, 2022

  1. gh-94912: Added marker for non-standard coroutine function detection (#…

    …99247)
    
    This introduces a new decorator `@inspect.markcoroutinefunction`,
    which, applied to a sync function, makes it appear async to
    `inspect.iscoroutinefunction()`.
    carltongibson committed Dec 18, 2022

Commits on Dec 17, 2022

  1. gh-100272: Fix JSON serialization of OrderedDict (GH-100273)

    It now preserves the order of keys.
    serhiy-storchaka committed Dec 17, 2022
  2. gh-99240: Reset pointer to NULL when the pointed memory is freed in a…

    …rgument parsing (#99890)
    
    Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
    Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
    3 people committed Dec 17, 2022
  3. gh-78707: deprecate passing >1 argument to `PurePath.[is_]relative_to…

    …()` (GH-94469)
    
    This brings `relative_to()` and `is_relative_to()` more in line with other pathlib methods like `rename()` and `symlink_to()`.
    
    Resolves #78707.
    barneygale committed Dec 17, 2022

Commits on Dec 16, 2022

  1. gh-100039: enhance __signature__ to work with str and callables (GH-1…

    …00168)
    
    Callables should be either class- or static-methods.
    Enum now uses the classmethod version to greatly improve the help
    given for enums and flags.
    ethanfurman committed Dec 16, 2022

Commits on Dec 11, 2022

  1. gh-99688: Fix outdated tests in test_unary (#99712)

    * Remove duplicates from "L" suffix removal
    * test_invert now tests `~`.
    Isaac-Lee committed Dec 11, 2022
  2. gh-88500: Reduce memory use of urllib.unquote (#96763)

    `urllib.unquote_to_bytes` and `urllib.unquote` could both potentially generate `O(len(string))` intermediate `bytes` or `str` objects while computing the unquoted final result depending on the input provided. As Python objects are relatively large, this could consume a lot of ram.
    
    This switches the implementation to using an expanding `bytearray` and a generator internally instead of precomputed `split()` style operations.
    
    Microbenchmarks with some antagonistic inputs like `mess = "\u0141%%%20a%fe"*1000` show this is 10-20% slower for unquote and unquote_to_bytes and no different for typical inputs that are short or lack much unicode or % escaping. But the functions are already quite fast anyways so not a big deal.  The slowdown scales consistently linear with input size as expected.
    
    Memory usage observed manually using `/usr/bin/time -v` on `python -m timeit` runs of larger inputs. Unittesting memory consumption is difficult and does not seem worthwhile.
    
    Observed memory usage is ~1/2 for `unquote()` and <1/3 for `unquote_to_bytes()` using `python -m timeit -s 'from urllib.parse import unquote, unquote_to_bytes; v="\u0141%01\u0161%20"*500_000' 'unquote_to_bytes(v)'` as a test.
    gpshead committed Dec 11, 2022

Commits on Dec 8, 2022

  1. test_ast uses infinite_recursion() to prevent crash (#100104)

    test.test_ast_recursion_limit() now uses infinite_recursion() of
    test.support to prevent crashes on debug builds.
    
    Before this change, the test crashed on ARM64 Windows 3.x buildbot
    worker which builds Python in debug mode.
    vstinner committed Dec 8, 2022
  2. Fix test_run_until_complete_baseexception test to check for `Keyboa…

    …rdInterrupt` in asyncio (#24477)
    fantix committed Dec 8, 2022
  3. gh-100098: [Enum] insist on actual tuples, no subclasses, for auto (G…

    …H-100099)
    
    When checking for auto() instances, only top-level usage is supported,
    which means either alone or as part of a regular tuple. Other
    containers, such as lists, dicts, or namedtuples, will not have auto()
    transformed into a value.
    ethanfurman committed Dec 8, 2022
  4. gh-100086: Add build info to test.libregrtest (#100093)

    The Python test runner (libregrtest) now logs Python build information like
    "debug" vs "release" build, or LTO and PGO optimizations.
    vstinner committed Dec 8, 2022
Older