Skip to content

WIP Python 3.14 attempts #658

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

hroncok
Copy link
Contributor

@hroncok hroncok commented Mar 12, 2025

This is not ready yet. I decided to open it in case somebody wants to follow up.

This uses private API now.

Proper fix pending discussion in python/cpython#131148
@entelligence-ai-reviews

Walkthrough

This PR improves compatibility and robustness of uvloop with various Python versions by updating imports and attribute access patterns. It introduces defensive coding techniques to handle changes in the Python standard library, ensuring uvloop continues to function correctly even if certain classes or attributes are renamed, moved, or missing in different Python releases.

Changes

File(s) Summary
uvloop/init.py Updated import of BaseDefaultEventLoopPolicy from asyncio.events to use a try-except block, falling back to _BaseDefaultEventLoopPolicy if the standard import fails, for compatibility with Python version changes.
uvloop/includes/stdlib.pxi Modified assignment of 'aio_AbstractChildWatcher' to use getattr for retrieving 'AbstractChildWatcher' from the asyncio module, with object() as a fallback if the attribute is missing, improving robustness against missing attributes.

Sequence Diagram

This diagram shows the interactions between components:

sequenceDiagram
    title Import Flow for BaseDefaultEventLoopPolicy

    participant App as "Application Code"
    participant ImportSystem as "Python Import System"
    participant AsyncioEvents as "asyncio.events Module"
    participant UvloopModule as "uvloop Module"

    App->>UvloopModule: Import uvloop
    activate UvloopModule
    
    UvloopModule->>ImportSystem: Import BaseDefaultEventLoopPolicy
    activate ImportSystem
    
    alt Primary import path
        ImportSystem->>AsyncioEvents: Try: from asyncio.events import BaseDefaultEventLoopPolicy
        AsyncioEvents-->>ImportSystem: Successfully imported
        ImportSystem-->>UvloopModule: Return BaseDefaultEventLoopPolicy
    else ImportError occurs
        ImportSystem->>AsyncioEvents: Exception: ImportError
        Note over ImportSystem,AsyncioEvents: Issue #131148 in CPython
        ImportSystem->>AsyncioEvents: Try: from asyncio.events import _BaseDefaultEventLoopPolicy
        AsyncioEvents-->>ImportSystem: Successfully imported fallback
        ImportSystem-->>UvloopModule: Return _BaseDefaultEventLoopPolicy as __BasePolicy
    end
    
    deactivate ImportSystem
    
    UvloopModule->>UvloopModule: Continue with other imports
    Note over UvloopModule: Import Loop from .loop
    
    UvloopModule-->>App: uvloop successfully imported
    deactivate UvloopModule
Loading

▶️AI Code Reviews for VS Code, Cursor, Windsurf
Install the extension

Note for Windsurf Please change the default marketplace provider to the following in the windsurf settings:

Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery

Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items

Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts below

Emoji Descriptions:

  • ⚠️ Potential Issue - May require further investigation.
  • 🔒 Security Vulnerability - Fix to ensure system safety.
  • 💻 Code Improvement - Suggestions to enhance code quality.
  • 🔨 Refactor Suggestion - Recommendations for restructuring code.
  • ℹ️ Others - General comments and information.

Interact with the Bot:

  • Send a message or request using the format:
    @entelligenceai + *your message*
Example: @entelligenceai Can you suggest improvements for this code?
  • Help the Bot learn by providing feedback on its responses.
    @entelligenceai + *feedback*
Example: @entelligenceai Do not comment on `save_auth` function !

Also you can trigger various commands with the bot by doing
@entelligenceai command

The current supported commands are

  1. config - shows the current config
  2. retrigger_review - retriggers the review

More commands to be added soon.

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