Skip to content

[pull] main from python:main#31

Merged
pull[bot] merged 6 commits intowebfutureiorepo:mainfrom
python:main
Feb 21, 2025
Merged

[pull] main from python:main#31
pull[bot] merged 6 commits intowebfutureiorepo:mainfrom
python:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull bot commented Feb 21, 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

This pull request includes several bug fixes and enhancements across different modules. It ensures that unicodedata.normalize() returns a str object, improves code readability by introducing *_CAST macros, and simplifies the logic in Lib/test/libregrtest/main.py.

Bug Fixes:

Enhancements:

  • Improves code readability by introducing *_CAST macros for type casting in _functools, _queue, and _random modules.
  • Removes the previous_test variable in Lib/test/libregrtest/main.py to simplify the logic and improve readability.

sobolevn and others added 6 commits February 21, 2025 15:59
…in str (#129570)

Co-authored-by: Victor Stinner <vstinner@python.org>
First, write the test name without color. Then, write the test name
and the result with color. Each test is displayed twice.

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
)

Fix UBSan failures for `keyobject`, `lru_list_elem`, `lru_cache_object`.
Suppress unused return values.
Change `_PyPartialObject_CAST` (from #124733) to `partialobject_CAST`
for consistency with the current style for these macros
Fix UBSan failures for `simplequeueobject`

Suppress unused return values
Fix UBSan failures for `RandomObject`
Suppress unused return values
@pull pull bot added the ⤵️ pull label Feb 21, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Feb 21, 2025

Reviewer's Guide by Sourcery

This pull request includes changes to improve type safety by introducing *_CAST macros, ensures unicodedata.normalize() returns str, enhances test progress display, and removes redundant casts.

Updated class diagram for partialobject

classDiagram
  class partialobject {
    PyObject* fn
    PyObject* args
    PyObject* kw
    PyObject* dict
    PyObject* weakreflist
  }
  note for partialobject "Added partialobject_CAST macro"
Loading

Updated class diagram for keyobject

classDiagram
  class keyobject {
    PyObject* cmp
    PyObject* object
  }
  note for keyobject "Added keyobject_CAST macro"
Loading

Updated class diagram for lru_list_elem

classDiagram
  class lru_list_elem {
    PyObject *key
    PyObject *result
  }
  note for lru_list_elem "Added lru_list_elem_CAST macro"
Loading

Updated class diagram for lru_cache_object

classDiagram
  class lru_cache_object {
    PyObject *cache
    PyObject *func
    PyObject *wrapper
    lru_list_elem root
    Py_ssize_t hits
    Py_ssize_t misses
    Py_ssize_t maxsize
    int typed
    PyObject *weakreflist
  }
  note for lru_cache_object "Added lru_cache_object_CAST macro"
Loading

Updated class diagram for simplequeueobject

classDiagram
  class simplequeueobject {
    RingBuf buf
    PyObject *mutex
    PyObject *not_empty
    PyObject *not_full
    Py_ssize_t maxsize
    PyObject *weakreflist
  }
  note for simplequeueobject "Added simplequeueobject_CAST macro"
Loading

Updated class diagram for RandomObject

classDiagram
  class RandomObject {
    uint32_t state[N]
  }
  note for RandomObject "Added RandomObject_CAST macro"
Loading

File-Level Changes

Change Details Files
Replaced direct casts with *_CAST macros for type safety and readability.
  • Replaced _PyPartialObject_CAST(self) with partialobject_CAST(self) in multiple functions.
  • Introduced keyobject_CAST(op) macro.
  • Replaced direct cast to keyobject with keyobject_CAST(op) in keyobject_clear, keyobject_dealloc, keyobject_traverse, and keyobject_call.
  • Introduced lru_list_elem_CAST(op) macro.
  • Replaced direct cast to lru_list_elem with lru_list_elem_CAST(op) in lru_list_elem_dealloc.
  • Introduced lru_cache_object_CAST(op) macro.
  • Replaced direct cast to lru_cache_object with lru_cache_object_CAST(op) in lru_cache_tp_clear, lru_cache_dealloc, lru_cache_tp_traverse, and lru_cache_call.
  • Introduced simplequeueobject_CAST(op) macro.
  • Replaced direct cast to simplequeueobject with simplequeueobject_CAST(op) in simplequeue_clear, simplequeue_dealloc, and simplequeue_traverse.
  • Introduced RandomObject_CAST(op) macro.
  • Replaced direct cast to RandomObject with RandomObject_CAST(op) in random_init.
Modules/_functoolsmodule.c
Modules/_queuemodule.c
Modules/_randommodule.c
Ensured that unicodedata.normalize() always returns a str object, even when the input is a subclass of str.
  • Modified unicodedata_UCD_normalize_impl to use PyUnicode_FromObject instead of Py_NewRef to create the return value.
  • Added a test case test_normalize_return_type to verify the return type of unicodedata.normalize().
Modules/unicodedata.c
Lib/test/test_unicodedata.py
Improved the display of test progress in Lib/test/libregrtest/main.py.
  • Removed previous_test variable and its associated logic.
  • Consolidated the display of test progress and result into a single line.
  • Included test execution time in the progress display if it exceeds a threshold.
Lib/test/libregrtest/main.py
Lib/test/test_regrtest.py
Removed redundant casts in _functoolsmodule.c, _queuemodule.c, and _randommodule.c.
  • Removed redundant cast in _functools_free function.
  • Removed redundant cast in queue_free function.
  • Removed redundant cast in _random_free function.
Modules/_functoolsmodule.c
Modules/_queuemodule.c
Modules/_randommodule.c

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

@pull pull bot merged commit 2922429 into webfutureiorepo:main Feb 21, 2025
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.

The function unicodedata.normalize() should always return an instance of the built-in str type.

4 participants