Skip to content

[3.11] Fixup for Cython version 3.1.0 #10849

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

Closed
wants to merge 1 commit into from

Conversation

hswong3i
Copy link

With Cython v3.1.0 + aiohttp v3.11.18 will generate following error message:

cython -3 -o aiohttp/_websocket/reader_c.c aiohttp/_websocket/reader_c.py -I aiohttp -Werror

Error compiling Cython file:
------------------------------------------------------------
...
    def exception(self) -> Optional[BaseException]:
        return self._exception

    def set_exception(
        self,
        exc: "BaseException",
             ^
------------------------------------------------------------

aiohttp/_websocket/reader_c.py:82:13: Strings should no longer be used for type declarations. Use 'cython.int' etc. directly.

This PR include minimal changes backport from master branch, in order to fix above issue with Cython v3.1.0.

What do these changes do?

Are there changes in behavior for the user?

Is it a substantial burden for the maintainers to support this?

Related issue number

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder
    • name it <issue_or_pr_num>.<type>.rst (e.g. 588.bugfix.rst)

    • if you don't have an issue number, change it to the pull request
      number after creating the PR

      • .bugfix: A bug fix for something the maintainers deemed an
        improper undesired behavior that got corrected to match
        pre-agreed expectations.
      • .feature: A new behavior, public APIs. That sort of stuff.
      • .deprecation: A declaration of future API removals and breaking
        changes in behavior.
      • .breaking: When something public is removed in a breaking way.
        Could be deprecated in an earlier release.
      • .doc: Notable updates to the documentation structure or build
        process.
      • .packaging: Notes for downstreams about unobvious side effects
        and tooling. Changes in the test invocation considerations and
        runtime assumptions.
      • .contrib: Stuff that affects the contributor experience. e.g.
        Running tests, building the docs, setting up the development
        environment.
      • .misc: Changes that are hard to assign to any of the above
        categories.
    • Make sure to use full sentences with correct case and punctuation,
      for example:

      Fixed issue with non-ascii contents in doctest text files
      -- by :user:`contributor-gh-handle`.

      Use the past tense or the present tense a non-imperative mood,
      referring to what's changed compared to the last released version
      of this project.

With Cython v3.1.0 + aiohttp v3.11.18 will generate following error
message:

    cython -3 -o aiohttp/_websocket/reader_c.c aiohttp/_websocket/reader_c.py -I aiohttp -Werror

    Error compiling Cython file:
    ------------------------------------------------------------
    ...
        def exception(self) -> Optional[BaseException]:
            return self._exception

        def set_exception(
            self,
            exc: "BaseException",
                 ^
    ------------------------------------------------------------

    aiohttp/_websocket/reader_c.py:82:13: Strings should no longer be used for type declarations. Use 'cython.int' etc. directly.

This PR include minimal changes backport from master branch, in order to
fix above issue with Cython v3.1.0.

Signed-off-by: Wong Hoi Sing Edison <[email protected]>
@hswong3i hswong3i requested a review from asvetlov as a code owner May 10, 2025 11:05
hswong3i pushed a commit to alvistack/aio-libs-aiohttp that referenced this pull request May 10, 2025
    git clean -xdf
    git submodule sync --recursive
    git submodule update --recursive --init
    git submodule foreach --recursive git checkout -- .
    git submodule foreach --recursive git clean -xdf
    make generate-llhttp
    tar zcvf ../python-aiohttp_3.11.18.orig.tar.gz --exclude=.git .
    debuild -uc -us
    cp python-aiohttp.spec ../python-aiohttp_3.11.18-1.spec
    cp ../python*-aiohttp*3.11.18*.{gz,xz,spec,dsc} /osc/home\:alvistack/aio-libs-aiohttp-3.11.18/
    rm -rf ../python*-aiohttp*3.11.18*.*

See aio-libs#10849

Signed-off-by: Wong Hoi Sing Edison <[email protected]>
Copy link

codecov bot commented May 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.11%. Comparing base (a449eb3) to head (01acb8b).
Report is 2 commits behind head on 3.11.

Additional details and impacted files
@@           Coverage Diff           @@
##             3.11   #10849   +/-   ##
=======================================
  Coverage   98.11%   98.11%           
=======================================
  Files         126      126           
  Lines       37682    37682           
  Branches     4555     4555           
=======================================
  Hits        36972    36972           
  Misses        534      534           
  Partials      176      176           
Flag Coverage Δ
CI-GHA 98.00% <100.00%> (ø)
OS-Linux 97.70% <100.00%> (ø)
OS-Windows 94.74% <66.66%> (ø)
OS-macOS 96.83% <66.66%> (ø)
Py-3.10.11 96.71% <66.66%> (+<0.01%) ⬆️
Py-3.10.17 97.26% <100.00%> (+0.04%) ⬆️
Py-3.11.12 97.28% <100.00%> (-0.02%) ⬇️
Py-3.11.9 96.79% <66.66%> (+0.01%) ⬆️
Py-3.12.10 97.73% <100.00%> (-0.05%) ⬇️
Py-3.13.3 97.72% <100.00%> (ø)
Py-3.9.13 96.60% <66.66%> (-0.01%) ⬇️
Py-3.9.22 97.16% <100.00%> (ø)
Py-pypy7.3.16 96.70% <100.00%> (ø)
VM-macos 96.83% <66.66%> (ø)
VM-ubuntu 97.70% <100.00%> (ø)
VM-windows 94.74% <66.66%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

codspeed-hq bot commented May 10, 2025

CodSpeed Performance Report

Merging #10849 will not alter performance

Comparing alvistack:3.11-cython-3.1.0 (01acb8b) with 3.11 (a449eb3)

Summary

✅ 54 untouched benchmarks

@webknjaz
Copy link
Member

PRs should typically go through master first.

@webknjaz
Copy link
Member

Additionally, this requires a change note.

@webknjaz
Copy link
Member

webknjaz commented May 10, 2025

Oh, and the cython.txt pin has to be bumped to demonstrate this actually works.

@bdraco
Copy link
Member

bdraco commented May 16, 2025

Looks like this one is a bit messy since this code exists on 3.12 as well. It was updated on master to use the newer signature at some point and than copied to _websocket_py.py

I think we should keep the signature as-is for 3.12/3.11 but remove the quotes. So a PR to 3.12 and than backport to 3.11 is likely the path here.

bdraco added a commit that referenced this pull request May 19, 2025
bdraco added a commit that referenced this pull request May 19, 2025
closes #10849

(cherry picked from commit 6ea542e)
@bdraco
Copy link
Member

bdraco commented May 19, 2025

Thanks for the PR. I went ahead and made the changes in #10849

@bdraco bdraco closed this May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants