-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Remove asyncore, asynchat and smtpd modules #72719
Comments
Deprecation warning was added to asyncore in https://bugs.python.org/issue25002 asyncore is still used in several tests and should be replaced. |
Here is the list of Python files using asyncore: haypo@selma$ grep -l asyncore $(find -name "*.py") smtpd has been rewritten with asyncio: The documentation of the smtpd module already points to aiosmtpd. libregrtest/save_env.py only checks that asyncore.socket_map is not modified, we can keep it until asyncore is really removed. test_support.py only tests that it's possible to have a "clean" import of asyncore, it can be easily be replaced later. The list can reduced to: ./Lib/test/test_smtplib.py |
asyncore was modified to emit a DeprecationWarning: But then a lot of code starts with to fail -Werror. Copy of Martin Panter's msg279469: I normally run the tests with -Werror, and the failures I get are:
|
I would like to work on this issue. I think it's a good idea to split this task into few parts/PR. Let me start from ./Lib/test/test_poplib.py. What about rewriting pop3 server stub using asyncio, i think requests could be handled synchronously, there will be no benefits from asynchronous. Please let me know what you think. |
Once you have a patch, open a new issue and mention it here. |
./Lib/test/test_poplib.py |
./Lib/test/test_poplib.py Fixed issue number from previous comment |
Hi, is this still open? I'm happy to work on replacing asyncore usage in one of the other test files. |
@dankreso, the issue is still open and no one has claimed it yet. So feel free to open a pull request. |
Sounds good, just let us know which one(s) you're working on. (: |
Lib/test/test_pyclbr.py - subissue bpo-38866 |
Since this issue is now a significant blocker for PEP-594 (remove stdlib dead batteries, which includes asyncore and asynchat), I'm going to prioritize working on this and assign it to myself. |
If the tests are the only thing blocking removal, does it make sense to move asyncore and asynchat to test.support and get on with removing them from the stdlib? |
Irit:
Yes, it makes sense and it can be done right now, since asynchat/asyncore is deprecated since Python 3.6. |
There is actually one usage outside of the tests: Lib/smtpd.py There is a note in the doc saying " The aiosmtpd package is a recommended replacement for this module. It is based on asyncio and provides a more straightforward API. smtpd should be considered deprecated." |
So the first step is to decide if it's ok to remove smtpd right now. |
asyncore, asynchat and smtpd are all deprecated now, for removal in 3.12. While the tests are not blocking their removal (we can move them to test.support) it would still be better to rewrite these tests. |
I forgot about this issue and I created a duplicate: bpo-45785. Copy of my messages. I propose to remove asyncore, asynchat and smtpd modules from the Python standard library to remove the Python maintenance burden. These modules are deprecated since Python 3.6. -- The asyncore module is a very old module of the Python stdlib for asynchronous programming, usually to handle network sockets concurrently. It's a common event loop, but its design has many flaws. The asyncio module was added to Python 3.4 with a well designed architecture. Twisted developers who have like 10 to 20 years of experience in asynchronous programming helped to design the asyncio API. By design, asyncio doesn't have flaws which would be really hard to fix in asyncore and asynchat. It was decided to start deprecating the asyncore and asynchat module in Python 3.6 released in 2016, 5 years ago. Open issues in asyncore and asynchat have been closed as "wont fix" because the module is deprecated. The two modules are basically no longer maintained. Documentation: I propose to remove the two modules right now in the Python stdlib. They were removed for 4 Python releases (3.6-3.10), it's long enough to respect the PEP-387. The PEP requires 2 Python releases at least before considering removing code. Since there are still 7 tests of the Python test suite still uses asyncore and asynchat, I propose to move these modules in Lib/test/ directory and make them private:
Projects using asyncore and asynchat should use asyncio. If someone really wants to continue using asyncore and asynchat, it's trivial to copy asyncore.py and asynchat.py in their project, and maintain these files on their side. -- About the smtpd module, it is also deprecated since Python 3.6 (deprecated for 4 Python releases). It's used by a single test (test_logging). I also propose to remove it from the stdlib. I proposed to rename Lib/smtpd.py to Lib/test/support/_smtpd.py. Projects using smtpd can consider using aiosmtpd which is based on asyncio: Or again, they can copy Python 3.10 smtpd.py in their project and maintain this file on their side. -- Ah, a DeprecationWarning warning is only emitted at runtime since Python 3.10. What's New in Python 3.10: "asynchat, asyncore, smtpd: These modules have been marked as deprecated in their module documentation since Python 3.6. An import-time DeprecationWarning has now been added to all three of these modules." https://docs.python.org/dev/whatsnew/3.10.html#asynchat-asyncore-smtpd |
I wrote PR 29521 to remove the asyncore, asynchat and smtpd modules.
I chose to remove it instead of my PR.
This code has been removed in the meanwhile.
While tests using asyncore, asynchat and smtpd have been modified to catch the DeprecationWarning warning, I chose to remove this warning in my PR, since I made the 3 modules private. I don't think that test.support private modules must emit deprecation warnings.
IMO it's ok to remove it since it is deprecated since Python 3.6.
Did you see an explicit mention of Python 3.12? I only saw mention of "Python 3.6" which is the version when the 3 modules were deprecated. |
Since Christian Heimes decided to mark my issue bpo-45785 "Remove asyncore, asynchat and smtpd modules" as a duplicate of this issue, I changed this issue title to "Remove asyncore, asynchat and smtpd modules". |
I announced my plan to remove the 3 modules on python-dev: |
Oh, I reported the issue to the wrong GitHub project. I reported it again at: ansible-collections/community.general#4656 |
I notified the project upstream: https://bz.mercurial-scm.org/show_bug.cgi?id=6700 |
The suggested stmpd replacement supports Python versions up to 3.9. Python 3.10 and later is not supported. |
True, but it's still the most viable replacement for |
We should be able to un-revert this now. |
I propose to remove the |
I think that was referring to tests that need to be rewritten with asyncio. The alternative is to move these modules (or parts of them) to test.support so the tests continue to work. |
That still doesn't require pinging the asyncio experts, IMO (and my opinion counts since I'm the only active one :-). I'll remove the label. |
IMO that's a convenient way to unblock the issue. Moving away from asyncore/asynchat would be nice but nobody managed to update tests in 10 years, so maybe it's ok to not changed them until it becomes a major (blocking) issue :-) |
I've moved these modules to Tests do continue to pass! 🎉 |
Remove modules asyncore and asynchat, which were deprecated by PEP 594. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
asyncore, asynchat, smtpd are removed again in the main branch (future Python 3.12). Let's see how it goes this time. Summary of this issue. The asyncore/asynchat deprecation has a long history starting in 2015: https://bugs.python.org/issue25002 In 2020, Kyle Stanley @aeros worked on the removal in a branch: https://github.com/aeros/cpython/tree/remove-asycore-asynchat-smtpd In 2021, I already removed the 3 modules (asyncore, asynchat, smtpd) in Python 3.11, but the Steering Council asked me to revert it since these modules only emitted a DeprecationWarning in 1 Python release (Python 3.10):
After my revert, I notified Mercurial and Ansible that these 3 projects are deprecated since 2015. In 2022, these modules are removed again in Python 3.12:
The removal is now covered by PEP 594 which has been approved the SC. You can now help the remaining projects still using the removed projects to be upgrade to asyncio and aiosmptd. People can also collaborate to maintain the 3 removed modules outside Python (on PyPI) if they want. Just copy code, tests and doc from Python 3.11. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
asyncore
andasynchat
modules #96580The text was updated successfully, but these errors were encountered: