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

Alexandre Vassalotti alexandre at peadrop.com
Sat Mar 22 05:44:17 CET 2008


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?

   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))

Thanks,
-- Alexandre


More information about the stdlib-sig mailing list