beeware / rubicon-objc

A bridge interface between Python and Objective-C.
https://rubicon-objc.readthedocs.io
Other
265 stars 50 forks source link

`SafeChildWatcher` is deprecated in Python 3.14 #497

Open rmartin16 opened 1 month ago

rmartin16 commented 1 month ago

Describe the bug

It appears the whole concept of "child watchers" was removed from Python.

    from rubicon.objc.eventloop import CocoaLifecycle, EventLoopPolicy
  File "/Users/user/.pyenv/versions/briefcase-3.14-dev/lib/python3.14/site-packages/rubicon/objc/eventloop.py", line 5, in <module>
    from asyncio import (
    ...<6 lines>...
    )
ImportError: cannot import name 'SafeChildWatcher' from 'asyncio' (/Users/user/.pyenv/versions/3.14-dev/lib/python3.14/asyncio/__init__.py)

Steps to reproduce

Attempt to start the event loop using Python 3.14.

Expected behavior

Event loop can start on Python 3.14.

Screenshots

No response

Environment

Logs

No response

Additional context

This issue may more broadly capture the need to support Python 3.14 but I am not sure what else would be needed beyond resolving this child watcher issue.

RE: https://github.com/beeware/gbulb/issues/171

freakboy3742 commented 1 month ago

I'm surprised this hasn't been surfaced as a deprecation warning in 3.12 and 3.13 testing... but it's definitely something that needs to be addressed.

rmartin16 commented 1 month ago

It may just be that nothing is exercising this code in our use-cases.

EventLoopPolicy is implementing asyncio.events.AbstractEventLoopPolicy which used to require get_child_watcher() and is the only caller (AFAICT) of _init_watcher()...but neither the testing for Rubicon-ObjC nor Toga actually uses this.

At this point, AbstractEventLoopPolicy only requires get_event_loop(), set_event_loop(), and new_event_loop(); so, maybe it's reasonable to just only define methods for get_child_watcher() and set_child_watcher() on versions before 3.14.