pycord icon indicating copy to clipboard operation
pycord copied to clipboard

feat: ✨ Update to support python 3.14

Open Paillat-dev opened this issue 5 months ago • 7 comments

Summary

Depends on: #2645 The above pull request is required as it refactors asyncio usage in a way that does not make use of deprecated methods. See: https://docs.python.org/3.14/whatsnew/3.14.html#deprecated

⚠️ This requires testing.

Information

  • [ ] This PR fixes an issue.
  • [x] This PR adds something new (e.g. new method or parameters).
  • [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • [ ] This PR is not a code change (e.g. documentation, README, typehinting, examples, ...).

Checklist

  • [ ] I have searched the open pull requests for duplicates.
  • [ ] If code changes were made then they have been tested.
    • [ ] I have updated the documentation to reflect the changes.
  • [ ] If type: ignore comments were used, a comment is also left explaining why.
  • [ ] I have updated the changelog to include these changes.

Paillat-dev avatar Oct 09 '25 10:10 Paillat-dev

Thanks for opening this pull request! Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/2948/head:pr-2948
git checkout pr-2948

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/2948/head

pycord-app[bot] avatar Oct 09 '25 10:10 pycord-app[bot]

Does this require anything beyond #2645?

NeloBlivion avatar Oct 10 '25 22:10 NeloBlivion

Drafting

Lulalaby avatar Oct 20 '25 10:10 Lulalaby

Does this require anything beyond #2645?

Maybe stuff related to voice idk

Paillat-dev avatar Oct 21 '25 02:10 Paillat-dev

~~I put that on hold for the next release~~

Lulalaby avatar Oct 21 '25 02:10 Lulalaby

w/out #2645:

Traceback (most recent call last):
  File "/home/paillat/Documents/pycord/pycord/test_simple.py", line 11, in <module>
    bot = discord.Bot()
  File "/home/paillat/Documents/pycord/pycord/discord/bot.py", line 1171, in __init__
    super().__init__(*args, **options)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/home/paillat/Documents/pycord/pycord/discord/bot.py", line 97, in __init__
    super().__init__(*args, **kwargs)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/paillat/Documents/pycord/pycord/discord/cog.py", line 646, in __init__
    super().__init__(*args, **kwargs)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/paillat/Documents/pycord/pycord/discord/client.py", line 250, in __init__
    asyncio.get_event_loop() if loop is None else loop
    ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/paillat/.local/share/uv/python/cpython-3.14.0-linux-x86_64-gnu/lib/python3.14/asyncio/events.py", line 715, in get_event_loop
    raise RuntimeError('There is no current event loop in thread %r.'
                       % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'MainThread'.

w/ #2645:


INFO:discord.client:logging in using static token
INFO:discord.gateway:Shard ID None has sent the IDENTIFY payload.
INFO:discord.gateway:Shard ID None has connected to Gateway: ["gateway-prd-arm-us-east1-b-gdz6",{"micros":439333,"calls":["id_created",{"micros":606,"calls":[]},"session_lookup_time",{"micros":3594,"calls":[]},"session_lookup_finished",{"micros":11,"calls":[]},"discord-sessions-prd-2-124",{"micros":434230,"calls":["start_session",{"micros":419304,"calls":["discord-api-rpc-75d66748db-ltmwx",{"micros":410441,"calls":["get_user",{"micros":10603},"get_guilds",{"micros":28160},"send_scheduled_deletion_message",{"micros":16},"guild_join_requests",{"micros":32431},"authorized_ip_coro",{"micros":14},"pending_payments",{"micros":692},"apex_experiments",{"micros":5},"user_activities",{"micros":3},"played_application_ids",{"micros":3},"linked_users",{"micros":2}]}]},"starting_guild_connect",{"micros":77,"calls":[]},"presence_started",{"micros":644,"calls":[]},"guilds_started",{"micros":105,"calls":[]},"lobbies_started",{"micros":1,"calls":[]},"guilds_connect",{"micros":1,"calls":[]},"presence_connect",{"micros":14069,"calls":[]},"connect_finished",{"micros":14077,"calls":[]},"build_ready",{"micros":19,"calls":[]},"clean_ready",{"micros":1,"calls":[]},"optimize_ready",{"micros":0,"calls":[]},"split_ready",{"micros":1,"calls":[]}]}]}] (Session ID: fe1af9de6dacae0ee1ec47e85604b190).
Logged in as Test BOT 2#7657 (ID: 1175074550820634714)
------
Test Code
import discord
import os
from dotenv import load_dotenv
import logging

logging.basicConfig(level=logging.INFO)

load_dotenv()

bot = discord.Bot()


class MyCog(discord.Cog):
    @discord.Cog.listener()
    async def on_ready(self):
        print(f"Logged in as {bot.user} (ID: {bot.user.id})")
        print("------")


bot.add_cog(MyCog())

bot.run(os.getenv("TOKEN_2"))

CC @Lulalaby

Paillat-dev avatar Nov 02 '25 12:11 Paillat-dev

gotcha

Lulalaby avatar Nov 02 '25 13:11 Lulalaby