[pycrypto] Inovking Depreciation warnings in Python

Oz Nahum Tiram nahumoz at gmail.com
Wed Dec 5 22:49:04 PST 2012


Hi,

I am writing a software that uses Pycrypto. The library's ebsite it says that:

> RandomPool is now deprecated

Older version would issue a depreciation warning. Now the code simply says:

    class RandomPool:
        """Deprecated.  Use Random.new() instead.

        See http://www.pycrypto.org/randpool-broken
        """
        def __init__(self, numbytes = 160, cipher=None, hash=None, file=None):
            warnings.warn("This application uses RandomPool, which is
BROKEN in older releases.  See
http://www.pycrypto.org/randpool-broken",
RandomPool_DeprecationWarning)

When I  instantiate  RandomPool I don't see any waring ...

    >>> RandomPool()
    <Crypto.Util.randpool.RandomPool instance at 0x7f498dac80e0>

If I create a Class with `RandomPool_DeprecationWarning` I also don't
see a warning:

    >>> class Test():
    ...    def __init__(self):
    ...        warnings.warn("This tests
RandomPool_DeprecationWarning", RandomPool_DeprecationWarning)
    ...
    >>> Test
    <class __main__.Test at 0x7f498daecdb8>

Compare to:

    >>> class Test2():
    ...    def __init__(self):
    ...        warnings.warn("This application uses RandomPool, which
is BROKEN in older releases.  See
http://www.pycrypto.org/randpool-broken", DeprecationWarning)
    ...
    >>> Test2()
    <__main__.Test2 instance at 0x7f498dac8098>

The code to `RandomPool_DeprecationWarning`

    class CryptoWarning(Warning):
        """Base class for PyCrypto warnings"""

    class CryptoDeprecationWarning(DeprecationWarning, CryptoWarning):
        """Base PyCrypto DeprecationWarning class"""

    class CryptoRuntimeWarning(RuntimeWarning, CryptoWarning):
        """Base PyCrypto RuntimeWarning class"""

    #
    # Warnings that we might actually use
    #

    class RandomPool_DeprecationWarning(CryptoDeprecationWarning):
        """Issued when Crypto.Util.randpool.RandomPool is instantiated."""

So my question is:
Why is `RandomPool_DeprecationWarning` quietly passing while
`DeprecationWarning` is not?

(I am using Debian  Wheezy, and Python 2.7.3)


Thanks,
Oz


More information about the pycrypto mailing list