Skip to content

[pull] main from python:main #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 31, 2025
Merged

[pull] main from python:main #48

merged 8 commits into from
Mar 31, 2025

Conversation

pull[bot]
Copy link

@pull pull bot commented Mar 31, 2025

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.1)

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by Sourcery

Merge various improvements and fixes across different Python modules and system components

Bug Fixes:

  • Fixed type checking and suggestion generation in _suggestions module to handle list types more precisely
  • Improved atomic yield implementation for different architectures

Enhancements:

  • Optimized textwrap.indent() function for better performance
  • Simplified type deduplication logic in typing module
  • Updated thread exit handling in Windows thread implementation

Tests:

  • Added test cases for _suggestions module to verify suggestion generation behavior

chris-eibl and others added 8 commits March 31, 2025 16:15
Leftover from #105511 I believe. GitHub code search found no usages other
than copies of typing.py and lists of stdlib functions.
…#131866)

When using --with-dtrace the resulting object file could be missing
specific CFLAGS exported by the build system due to the systemtap
script using specific defaults.

Exporting the CC and CFLAGS variables before the dtrace invocation
allows us to properly apply CFLAGS exported by the build system
even when cross-compiling.

The fix does not affect the dtrace invocation on Solaris/macOS.
Use the standard `__ARM_ARCH` macro, which is supported by GCC and Clang.

The branching logic for of `__ARMEL__` has been removed so if the target
architecture supports v7+ instructions, a yield is emitted, otherwise a nop
is emitted. This covers both big and little endian scenarios.

Signed-off-by: Vincent Fazio <[email protected]>
@pull pull bot added the ⤵️ pull label Mar 31, 2025
@pull pull bot merged commit 2e96f5a into Futurist-Forever:main Mar 31, 2025
Copy link

sourcery-ai bot commented Mar 31, 2025

Reviewer's Guide by Sourcery

This pull request includes several bug fixes and performance improvements. It adds a test case for suggestions, improves the performance of textwrap.indent, refactors the _deduplicate function in typing.py, modifies mi_atomic_yield for ARM architectures, checks for exact list type in _generate_suggestions, corrects the type of previousTpSize in _winapi.c, adds Py_UNREACHABLE() in thread_nt.h, and adds NEWS entries for several issues.

Updated class diagram for textwrap.indent

classDiagram
    class textwrap {
        +indent(text, prefix, predicate=None)
    }
    note for textwrap.indent "Performance improvement by inlining the predicate and using str.isspace()"
Loading

Updated class diagram for typing module

classDiagram
    class typing {
        -_deduplicate_unhashable(unhashable_params)
        +_deduplicate(params, *, unhashable_fallback=False)
    }
    note for typing "Refactored _deduplicate function by removing the _deduplicate_unhashable function and inlining its logic into _deduplicate"
Loading

File-Level Changes

Change Details Files
Added a test case to ensure that _generate_suggestions() raises a TypeError when called with a subclass of list.
  • Added a test case test_suggestions_extension to TestTraceback.
  • The test asserts that _generate_suggestions() raises a TypeError when a list subclass is passed as an argument.
Lib/test/test_traceback.py
Improved the performance of the textwrap.indent function by inlining the predicate when it is None.
  • Inlined the lambda s: not s.isspace() predicate directly into the loop within textwrap.indent when predicate is None.
  • This change avoids a function call on each line, resulting in a performance improvement.
Lib/textwrap.py
Refactored the _deduplicate function in typing.py to inline the unhashable deduplication logic.
  • The _deduplicate_unhashable function was inlined into the _deduplicate function.
  • This removes the need for a separate function call and simplifies the code.
Lib/typing.py
Modified the mi_atomic_yield function in mimalloc/atomic.h to include a nop instruction for ARM architectures with architecture version less than 7.
  • Added a condition to check the ARM architecture version.
  • If the version is less than 7, a nop instruction is used instead of yield.
Include/internal/mimalloc/mimalloc/atomic.h
Modified the _generate_suggestions function in _suggestions.c to check for exact list type.
  • Changed PyList_Check to PyList_CheckExact to ensure that the argument is an exact list and not a subclass.
Modules/_suggestions.c
Corrected the type of previousTpSize in _winapi.c from int to DWORD.
  • Changed the type declaration of previousTpSize to DWORD to match the expected type.
Modules/_winapi.c
Added Py_UNREACHABLE() after _endthreadex(0) in thread_nt.h.
  • Added Py_UNREACHABLE() to indicate that the code after _endthreadex(0) should not be reached.
Python/thread_nt.h
Added NEWS entries for issues pythongh-131675, pythongh-131865, and pythongh-107369. Misc/NEWS.d/next/Build/2025-03-27-01-21-50.gh-issue-131675.l2zfOO.rst
Misc/NEWS.d/next/Build/2025-03-31-19-22-41.gh-issue-131865.PIJy7X.rst
Misc/NEWS.d/next/Library/2025-03-31-02-06-57.gh-issue-107369.8M-HVz.rst

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants