Skip to content
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

bpo-31985: Deprecate aifc.openfp #4344

Merged
merged 5 commits into from
Nov 10, 2017
Merged

Conversation

briancurtin
Copy link
Member

@briancurtin briancurtin commented Nov 8, 2017

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

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.
Copy link
Member

@berkerpeksag berkerpeksag left a comment

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))
Copy link
Member

@berkerpeksag berkerpeksag Nov 8, 2017

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.

Copy link
Member Author

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.

Copy link
Member Author

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)
Copy link
Member

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")
Copy link
Member

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.

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 briancurtin self-assigned this Nov 9, 2017
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.
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

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):
Copy link
Member

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.

Copy link
Member Author

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.

This additionally adds a TODO in test_pyclbr around using openfp, though
it shouldn't be changed until after 3.7.
@@ -63,6 +63,8 @@ The :mod:`sunau` module defines the following functions:

A synonym for :func:`.open`, maintained for backwards compatibility.

.. versiondeprecated:: 3.7
Copy link
Member

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.

These are being deprecated now for 3.7 and will be removed in 3.9.
@briancurtin briancurtin merged commit 9f914a0 into python:master Nov 10, 2017
@briancurtin briancurtin deleted the fix_31985 branch November 10, 2017 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants