I like this PEP, everything is well explained and makes totally sense.
Regarding getopt
and optparse
: Iâd like to remind you all that theyâre not just âdeprecated but too widely used to removeâ. argparse
uses a nonstandard reinterpretation of Unix command line grammars that makes certain arguments impossible to express. See issue 9334 which I filed nine years ago. Since apparently it canât or wonât be fixed with the current argparse
architecture, optparse
should be un-deprecated.
Great PEP. Iâd tweak âTSR-80â to âTRS-80â to satisfy the history buffs.
Have to disagree with some of these removals. Many of them are very small, and do not cause harm by being included in the standard library. I think that things should be removed if and only if there is good reason to (it is dangerous, there is a much better alternative, it takes up a lot of space and is not used a lot, etcâŠ), not just because it is old.
I donât agree with the removal of the audioop
module and its removal feels out of place in this PEP. Most of these deprecation and removals tend to revolve around 3 distinct reasons as far as I can tell:
- Theyâre pure python and can be easily shipped via PyPI or copy pasted into the project.
- Theyâre antique formats that are seldom used so their maintenance is a burden
- Theyâve been replaced by something much better or have been deprecated for a long time.
I believe audioop
falls in neither of these.
-
audioop
is a C extension library with no external dependencies - C extensions are difficult for beginners and many people to ship out and requires constant maintenance when providing wheels since the Python ABI changes every major release.
- There is no replacement to
audioop
anywhere as far as I can tell whether it be in PyPI or in the standard library and is used in other modules within the standard library.
In my own personal projects I use audioop
for working with raw PCM data when sending this data over the wire (e.g. VoIP and the like). The nature of this module means that itâs performance sensitive and cannot be written in pure python and since this battery is included in the standard library there is no need for me (and my library users) to fiddle with extension modules to get something that used to be in the standard library.
As the maintainer of WebOb, I am unhappy to see the deprecation/removal of cgi
, especially since it seems that there has been a complete disregard for functionality that is still used by others. cgi.FieldStorage
is used to parse POST data, and backs all file storage inside WebOb.
As I understand it there are other frameworks that use it as well, such as Bottle.
cgi.parse_header
is also used by Django and WebOb.
cgi.parse_multipart
is used by Twisted.
I already carry a fix for cgi.FieldStorage
in WebOb due to a bug that has not yet been fixed in Python, but I would really prefer not to carry the whole of cgi.FieldStorage
by vendoring it into WebOb, and then having multiple people implement the same standards. If this PEP goes through and cgi.FieldStorage
are not moved then anyone that is parsing multipart
POST bodies will have to write their own, or copy an older version and hope they can get patches from other projects that have done the same.
And one more point: The schedule doesnât really make any sense. Why would you break compatibility in such a major way while staying in the same major version? If youâre going to make such breaking changes, shouldnât you be waiting for 4.0? Iâm sorry, but this PEP seems pretty reactionary, and not pragmatic.
Removing AIFF support because itâs âan old audio format from 1988â is⊠wow.
Itâs an established, standard audio format, which is in wide use professionally. Itâs not at all uncommon for e.g. sample libraries to be distributed as AIFF files. Anecdotally, the last time I used the aifc module was three weeks ago â I understand thatâs not a âstatisticâ by any stretch, but hey.
This feels so misguided I donât even. Please reconsider.
Not sure about other BSDs, but OSS is the sound API in FreeBSD - and itâs not going away anytime soon.
That doesnât necessarily mean this library has to be bundled with the Python distribution, though. One point Christian makes is that with the current state of Pythonâs dependency management and installation tools (via setuptools
, wheel
and pip
) there no longer is a need to bundle everything.
Instead, youâd add aifc
to your requirements.txt
, Pipfile
or pyproject.toml
file, or the install_requires
list of your package setuptools
configuration.
The advantage of that setup is that it makes it easier to roll out new releases, as releases are no longer tied to the much more cumbersome Python release process.
That would be great, but the PEP says âSubstitute: noneâ. If this will be repackaged, then sure, everyone will just install from PyPI as needed, no issue with that.
Then again, keeping WAV support while dropping AIFF is just inconsistent.
(And the cost of just keeping both, and having backward compatibility with the existing code, is literally zero â itâs not like the aifc module needs, or indeed sees, any maintenance.)
I note that Werkzeug doesnât use FieldStorage
(or any other part of cgi
, really). Django doesnât use FieldStorage
either, but do use cgi.parse_header
and cgi.valid_boundary
.
Both of these functions should really be provided by the email
package. There is an implementation of parse_header()
in email.message.Message()
, actually, so this functionality is duplicated across two different libraries in the standard lib:
>>> from cgi import parse_header
>>> from email.message import Message
>>> parse_header(h)
('application/json', {'charset': 'utf8'})
>>> m = Message()
>>> m['content-type'] = h
>>> m.get_params()
[('application/json', ''), ('charset', 'utf8')]
>>> m.get_param('charset')
'utf8'
cgi.parse_multipart()
can likewise be handled by email.message
; itâs all the same MIME RFC.
Or someone creates a canonical package that everyone uses, just like they rely on Pythonâs cgi
module. Thatâs not really an argument for or against removing cgi
from the standard library. Moving it to PyPI does have the advantage that the fix you carry in WebOb could be upstreamed faster, you donât have to wait for everyone to upgrade their Python installation first.
Note that both Werkzeug and Django already wrote their own POST data handling.
The Substitute entries are there to note if there are other standard library packages that can cover the functionality, not if the package wonât see a release on PyPI or doesnât already have alternatives there. Iâm not sure what argument you are making with that.
I can see your point there; I think Christian was simply not aware that AIFF is still widely used. Personally, I see that as an argument to drop WAV support too!
Yes, itâs inconsistent.
But itâs inconsistent for good reasons. The reasons are spelled out in the PEP text two times.
- The module is pretty much unmaintained and have not seen any improvements, e.g. OSSv4 support. Almost all commits in the last 8 years are related to project wide code cleanups. Serhiy and Victor have spent time on the module although they are not FreeBSD users.
- CPython contains no bindings for Windows and ALSA. IMHO OSS is not special enough to have it in the core.
It would be more beneficial for everybody if the module would be picked up and maintained by the FreeBSD community. It would free resources for CPython devs and get actual users a better experience.
Add zeep to the list of projects that depend on cgi.parse_header.
Python versioning schema does not work like this.
Thanks for you feedback, but itâs slightly off topic. Could you please look for an existing bug on our bug tracker for de-deprecation of the optparse module and creaet a new one in case there is none? Thanks
Makes sense, thank you.