[stdlib-sig] Depreciation warnings in 2.6 for removed modules in 3.x

Brett Cannon brett at python.org
Sat Mar 22 09:41:36 CET 2008


On Fri, Mar 21, 2008 at 9:44 PM, Alexandre Vassalotti
<alexandre at peadrop.com> wrote:
> Hi,
>
>  I would like to know what is the plan for the removal warnings in
>  2.6. PEP 3108 states:
>
>    For the removal of modules that are continuing to exist in the
>    Python 2.x series (i.e., not deprecated explicitly in the 2.x
>    series), a proper warning will be set that is silenced by default;
>    PendingDeprecationWarning initially, moving over to a Py3K-specific
>    warning later if one comes into existence.
>
>  So if I understand correctly, this means that modules that already are
>  depreciated won't have an extra 3.x warning, right? And for other,
>  something like the following should be added, right?
>

Yes. To be ready for Py3K no warning, no matter the type, should be
raised in your code. So only one warning is really needed.

>    from warnings import warnpy3k as _warnpy3k
>    _warnpy3k("The 'x' module is not supported in 3.x", stacklevel=2)
>
>  Finally, would it be a good idea to add tests for the added
>  warnings in test_py3kwarns? If so, what would be the best way to do it?
>  Does something like this would fit?
>
>    def test_removed_modules(self):
>        # For superseded modules, state the replacement
>        expected = "The '%s' module is not supported in 3.x, use %s instead."
>        replacements = {
>           "hotshot": "the 'profile' module",
>           "cProfile": "the 'profile' module",
>           "cPickle": "the 'pickle' module",
>           "rexec": "the exec statement",
>           ...
>        }
>        for m, r in replacements:
>            with catch_warning() as w:
>                self.assertWarning(__import__(m), w, expected % (m, r))

Yeah, more or less.

-Brett


More information about the stdlib-sig mailing list