bpo-31985: Deprecate aifc.openfp#4344
Conversation
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
left a comment
There was a problem hiding this comment.
LGTM, I just left some minor comments.
| aifc.openfp(arg, mode=mode) | ||
|
|
||
| self.assertTrue(len(w) == 1) | ||
| self.assertTrue(issubclass(w[0].category, DeprecationWarning)) |
There was a problem hiding this comment.
Style nit: assertIsInstance might be better option here.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Style nit: I'd use assertEqual instead.
| arg = "arg" | ||
| mode = "mode" | ||
| with warnings.catch_warnings(record=True) as w: | ||
| warnings.simplefilter("always") |
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
Thank you Brian!
Please replace wave.openfp with wave.open in sndhdr.py. Add versiondeprecated in the documentation for wave.openfp and sunau.openfp.
| raise Error("mode must be 'r', 'rb', 'w', or 'wb'") | ||
|
|
||
| openfp = open # B/W compatibility | ||
| def openfp(f, mode=None): |
There was a problem hiding this comment.
Please add a comment that test_pyclbr.py should be updated after removing openfp.
There was a problem hiding this comment.
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.
|
|
||
| A synonym for :func:`.open`, maintained for backwards compatibility. | ||
|
|
||
| .. versiondeprecated:: 3.7 |
There was a problem hiding this comment.
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.
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