shizmob / pydle

An IRCv3-compliant Python 3 IRC library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python 3.8 depricated methods

theunkn0wn1 opened this issue · comments

There is a couple places in pydle that still call asyncio.coroutine, left over from the Asyncio migration.
I had initially left them in because replacing them with async def had somehow changed their behavior and caused bugs.

Unfortunately, asyncio.coroutine is deprecated as of 3.8 and and will be removed as of 3.10, so these holdouts need to be revisited.

A quick grep shows 5 remaining holdouts:
https://github.com/Shizmob/pydle/blob/790b8a10d5d0fc57e2adde1a19eabe02b18b8ceb/pydle/features/account.py#L25-L30
https://github.com/Shizmob/pydle/blob/790b8a10d5d0fc57e2adde1a19eabe02b18b8ceb/pydle/utils/irccat.py#L21-L50

Superficially, I've made the following change so far: ZeroKnight@1c86881 and it seems to work without any regressions after some manual testing. I'm unsure of the proper testing procedure currently since it seems that the test suite is still being worked on.

I'm unsure of how to proceed with irccat, as this line calls a method that doesn't exist, and that I can't find any documentation for:
https://github.com/Shizmob/pydle/blob/790b8a10d5d0fc57e2adde1a19eabe02b18b8ceb/pydle/utils/irccat.py#L60
It was introduced in db6cdfb. I'm assuming it's a deprecated and since-removed method in asyncio, but I can't seem to find any reference to it after light googling.

The test suite is unfortunately FUBAR and I haven't had enough uninterrupted time to attempt to rewrite it as of late.
My test strategy has been to apply the changes to my downstream Pydle bot and do systems testing against it.
When ive added new features, i have written tests to go with them, but the majority of Pydle's test suite is legacy and doesn't work properly.

I distinctly recall fixing these holdouts caused a lot of subtle issues; rather than hard crashes. Stuff like callbacks not being fired and functionality not behaving correctly though inheritance. This was a while ago, Il have a look at your branch and see if the above issues still manifest.

My test strategy has been to apply the changes to my downstream Pydle bot and do systems testing against it.

This is what I've been doing so far, but don't quite have all of pydle's interface touched yet, so it's certainly possible that I'm missing something somewhere.

On another note, it occurred to me that in addition to looking for uses of @asyncio.coroutine, we should also be looking on the flip side for instances of yield from used with coroutines, replacing them with await. For the sake of keeping track of this as well, it shows up in ircv3/monitor:
https://github.com/Shizmob/pydle/blob/790b8a10d5d0fc57e2adde1a19eabe02b18b8ceb/pydle/features/ircv3/monitor.py#L39-L55
And in the irccat coroutines mentioned already. monitor and unmonitor also need to be marked as async, and any documentation updated accordingly. This of course means that client code will need to be modified to await (un)monitor(...).

Looks like def monitor wasn't marked with an @coroutine marker; which is a problem in its own right.
This means that function is just a synchronous generator; and not a old-style asynchronous coroutine. This is a bug, since self.rawmsg is a coroutine. Calling asynchronous code from a synchronous context, in the context of a running event loop, requires the use of asyncio.create_task.

We would be better off porting this interface to asyncio (which is a breaking interface change) and scheduling it for the next major release.

It looks to me like this issue has been fully resolved w/ ea48213, and could probably be closed.

Closed by #163