Description

​hashlib was introduced in py2.5 and twisted.python.hashlib was added in 2007 (#2763) to "allow[s] application code to transparently use APIs which existed before C{hashlib} was introduced or to use C{hashlib} if it is available."

Twisted supports Python 2.6 and up and twisted's hashlib can be deprecated, and uses of it replaced, to make it easier to support py3 and discourage users from using this module.

Initially I wanted to file a ticket for porting this module to py3 but why port it when its there for (now) unsupported versions of Python.

Don't delete the existing test. Even if people shouldn't be using the code, we don't want the code to break. The tests should only be removed when the code they are testing gets removed.

You'll want to make sure that the warning is suppressed in those tests (using the .suppress attribute and twisted.trial.util.suppress).

Similarily, the module docstring doesn't want to be completely deleted. On the other hand, it should be changed to include the deprecation information (twisted.python.deprecate._getDeprecationDocstring has the standard format for that). It probably also wants to be changed to indicate that twisted doesn't use it anymore.

There are still a couple of uses t.p.hashlib left after applying your patch. - `twisted/conch/client/knownhosts.py'

The code was structured the way it was before so it only did the import once. (Although, on further consideration, I'm not sure why the code wasn't like that to begin with.

13.0.0 was the most recent release, so 13.1.0 will be the next release. That will be the release where this will be deprecated.

Calls to .flushWarnings should include a function to blame. This is to verify that the stacklevel argument is set correctly. It should point to the function that is invoking the deprecated functionality.