-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix compatibility with Twisted 25 #13502
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
Fix compatibility with Twisted 25 #13502
Conversation
Happy to see a fix developed so quickly and I hope this can land in a release soon. That said, this is very fragile and likely to break again soon. turning Failure into a dataclass, making it frozen, giving it |
Hmmm |
e30e0a0
to
d12b29a
Compare
As soon as we merge this and #13495 I will make a new release. 👍
I definitely agree this is fragile. This workaround seems to be due to the fact that twisted calls I guess we can mitigate the problem a bit by storing the
Well noted: I'm reducing the chances of a memory leak now by removing the attribute created by pytest. But all this is definitely hacky. PS: I'm a big fan of your blog. 😁 |
d3d4600
to
36c57ab
Compare
36c57ab
to
96f0319
Compare
Sounds great, thanks.
I probably need to wait for a less hectic day to reflect on this but can
Ah, awesome, glad to hear it. I didn't catch that. It's possible that this is less common with coroutines as it was with manually-managed Deferreds, but i guess it depends if there's a hard reference to the
Yeah, I look forward to figuring out some better strategy for this, and I'm happy for twisted & trial to help out here.
Thanks! Remember to like and subscribe 🙃 |
That's a good idea, I will try it out later. |
Meanwhile this is ready for review @pytest-dev/core |
c48c810
to
f519098
Compare
That approach did not work, because This change significantly simplified the code:
The code is much simpler and more isolated. However, it has two downsides:
Because of the above, I see two options (@pytest-dev/core):
|
I weakly prefer option (2); breaking compat with older versions is usually a larger impact on users than picking up a fragile workaround - at least when there are active maintainers on all sides, which we have in this case. |
Agree with Zac. And longterm we could switch to the simpler implementation when twisted download are for version > 25 for ~= 90% of users if twisted according to pypistats. |
Por que no los dos? Specifically: add a toggle at runtime that chooses the simpler implementation when possible (i.e. when Twisted is new enough), and then by the time the old implementation gets deleted, it's just removing dead code, rather than transitioning everyone to a new, as-yet untested implementation all at once? |
Good call, will do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to support pre 25. Else this is a breaking change?
Indeed, but as @glyph suggested, will implement separate fixes depending on the Twisted version. |
Should we use the version metadata from importlib? |
Hopefully. 😁 |
a14c94b
to
169f9ff
Compare
Both patches in place now. 👍 |
b330044
to
16b7074
Compare
Ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work !
As discussed in pytest-dev#13502, the fix for compatibility with Twisted 25+ is simpler. Therefore, it makes sense to implement both fixes (for Twisted 24 and Twisted 25) in parallel. This way, we can eventually drop support for Twisted <25 and keep only the simpler workaround. In addition, the `unittestextras` tox environment has been replaced with dedicated test environments for `asynctest`, `Twisted 24`, and `Twisted 25`. Fixes pytest-dev#13497
c8a3842
to
4e533f7
Compare
I'm having trouble understanding why Codecov is reporting missing coverage. Their diff indicates that the code related to Twisted 24 isn't executing: However, the log files from the
Indeed, lines Also it is clear that coverage is being uploaded. Given that this fix is long overdue, I'll proceed with merging it. |
Backport to 8.4.x: 💚 backport PR created✅ Backport PR branch: Backported as #13531 🤖 @patchback |
As discussed in #13502, the fix for compatibility with Twisted 25+ is simpler. Therefore, it makes sense to implement both fixes (for Twisted 24 and Twisted 25) in parallel. This way, we can eventually drop support for Twisted <25 and keep only the simpler workaround. In addition, the `unittestextras` tox environment has been replaced with dedicated test environments for `asynctest`, `Twisted 24`, and `Twisted 25`. Fixes #13497 (cherry picked from commit 01dce85)
As discussed in #13502, the fix for compatibility with Twisted 25+ is simpler. Therefore, it makes sense to implement both fixes (for Twisted 24 and Twisted 25) in parallel. This way, we can eventually drop support for Twisted <25 and keep only the simpler workaround. In addition, the `unittestextras` tox environment has been replaced with dedicated test environments for `asynctest`, `Twisted 24`, and `Twisted 25`. Fixes #13497 (cherry picked from commit 01dce85) Co-authored-by: Bruno Oliveira <[email protected]>
The issue arises because
Failure.__init__
in Twisted 25 can receive a non-Noneexc_value
whileexc_tb
isNone
. In such cases,ExceptionInfo[BaseException].from_exc_info
fails, as it expects a traceback to be present whensys.exc_info()
returns a tuple. This leads to the error message'NoneType' object is not iterable
.Implemented separate workarounds for Twisted 24 and Twisted 25, the later one being simpler and less intrusive in the long run, as it does not require monkeypatching
Failure.__init__
.We can drop suppor for Twisted 24 and keep the simpler patch in a later release.
Fixes #13497