bpo-31985: Deprecate aifc.openfp by briancurtin · Pull Request #4344 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation10 Commits5 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

briancurtin

aifc.openfp had pointed to aifc.open since 1993* and it was both undocumented and untested since being assigned as a matter of backwards compatibility. This change begins its formal deprecation.

* 7bc817d

https://bugs.python.org/issue31985

@briancurtin

aifc.openfp had pointed to aifc.open since 1993 and it was both undocumented and untested since being assigned as a matter of backwards compatibility. This change begins its formal deprecation.

berkerpeksag

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I just left some minor comments.

aifc.openfp(arg, mode=mode)
self.assertTrue(len(w) == 1)
self.assertTrue(issubclass(w[0].category, DeprecationWarning))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: assertIsInstance might be better option here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially thought that as well, but category isn't an instance there.

The other comments look good and I'll push a fix for them.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using assertWarns we get the behavior we needed from those two assertTrue lines, so I just removed them in ebe685d.

warnings.simplefilter("always")
aifc.openfp(arg, mode=mode)
self.assertTrue(len(w) == 1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: I'd use assertEqual instead.

arg = "arg"
mode = "mode"
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could replace those two lines with assertWarns.

@briancurtin

By using assertWarns we no longer need to check the number of warnings or the category of the warning, as assertWarns already handles that for us.

@briancurtin

This additionally moves the test to Lib/audiotests.py and has MiscTests in each module's tests inherit from the new AudioMiscTests which does the deprecation test.

serhiy-storchaka

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Brian!

Please replace wave.openfp with wave.open in sndhdr.py. Add versiondeprecated in the documentation for wave.openfp and sunau.openfp.

@@ -915,7 +915,10 @@ def open(f, mode=None):
else:
raise Error("mode must be 'r', 'rb', 'w', or 'wb'")
openfp = open # B/W compatibility
def openfp(f, mode=None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment that test_pyclbr.py should be updated after removing openfp.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added. After this merges I'm going to create an issue in Roundup and assign it to myself so it gets formally tracked.

@briancurtin

This additionally adds a TODO in test_pyclbr around using openfp, though it shouldn't be changed until after 3.7.

serhiy-storchaka

@@ -63,6 +63,8 @@ The :mod:`sunau` module defines the following functions:
A synonym for :func:`.open`, maintained for backwards compatibility.
.. versiondeprecated:: 3.7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, the correct name of this directive is deprecated! Or deprecated-removed if you have assigned the date of removing.

@briancurtin

These are being deprecated now for 3.7 and will be removed in 3.9.

serhiy-storchaka