Bug#638166: ImportError: cannot import name SHA256

2011-08-17 Thread GODART Christophe (MORPHO)
Package: python-crypto
Version: 2.1.0-2
Severity: important


Shared library SHA256.so from python-crypto can't be imported; I first saw it 
when using pythoon-paramiko: 

$ python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.
 import paramiko
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/share/pyshared/paramiko/__init__.py, line 69, in module
from transport import randpool, SecurityOptions, Transport
  File /usr/share/pyshared/paramiko/transport.py, line 32, in module
from paramiko import util
  File /usr/share/pyshared/paramiko/util.py, line 32, in module
from paramiko.common import *
  File /usr/share/pyshared/paramiko/common.py, line 98, in module
from rng import StrongLockingRandomPool
  File /usr/share/pyshared/paramiko/rng.py, line 23, in module
from Crypto.Util.randpool import RandomPool as _RandomPool
  File /usr/share/pyshared/Crypto/Util/randpool.py, line 30, in module
import Crypto.Random
  File /usr/share/pyshared/Crypto/Random/__init__.py, line 29, in module
import _UserFriendlyRNG
  File /usr/share/pyshared/Crypto/Random/_UserFriendlyRNG.py, line 36, in 
module
from Crypto.Random.Fortuna import FortunaAccumulator
  File /usr/share/pyshared/Crypto/Random/Fortuna/FortunaAccumulator.py, line 
34, in module
import SHAd256
  File /usr/share/pyshared/Crypto/Random/Fortuna/SHAd256.py, line 38, in 
module
from Crypto.Hash import SHA256
ImportError: cannot import name SHA256


New try with just python-crypto:

 from Crypto.Hash import SHA256
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: cannot import name SHA256


Then, trying to import just the SHA256 module from its directory:

$ cd /usr/lib/python2.6/dist-packages/Crypto/Hash
$ python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.
 import SHA256
Traceback (most recent call last):
  File stdin, line 1, in module
SystemError: dynamic module not initialized properly


My system is an up-to-date Squeeze 6.0.2.
#
 Ce courriel et les documents qui lui sont joints peuvent contenir des 
informations confidentielles ou ayant un caractère privé. S'ils ne vous sont 
pas destinés, nous vous signalons qu'il est strictement interdit de les 
divulguer, de les reproduire ou d'en utiliser de quelque manière que ce soit le 
contenu. Si ce message vous a été transmis par erreur, merci d'en informer 
l'expéditeur et de supprimer immédiatement de votre système informatique ce 
courriel ainsi que tous les documents qui y sont attachés.
**
 This e-mail and any attached documents may contain confidential or 
proprietary information. If you are not the intended recipient, you are 
notified that any dissemination, copying of this e-mail and any attachments 
thereto or use of their contents by any means whatsoever is strictly 
prohibited. If you have received this e-mail in error, please advise the sender 
immediately and delete this e-mail and all attached documents from your 
computer system.
#


Bug#638166: ImportError: cannot import name SHA256

2011-08-17 Thread Sebastian Ramacher
tag 638166 + moreinfo
thanks

On 08/17/2011 11:13 AM, GODART Christophe (MORPHO) wrote:
 $ python
 Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
 [GCC 4.4.5] on linux2
 Type help, copyright, credits or license for more information.
 import paramiko
 Traceback (most recent call last):
   File stdin, line 1, in module
   File /usr/share/pyshared/paramiko/__init__.py, line 69, in module
 from transport import randpool, SecurityOptions, Transport
   File /usr/share/pyshared/paramiko/transport.py, line 32, in module
 from paramiko import util
   File /usr/share/pyshared/paramiko/util.py, line 32, in module
 from paramiko.common import *
   File /usr/share/pyshared/paramiko/common.py, line 98, in module
 from rng import StrongLockingRandomPool
   File /usr/share/pyshared/paramiko/rng.py, line 23, in module
 from Crypto.Util.randpool import RandomPool as _RandomPool
   File /usr/share/pyshared/Crypto/Util/randpool.py, line 30, in module
 import Crypto.Random
   File /usr/share/pyshared/Crypto/Random/__init__.py, line 29, in module
 import _UserFriendlyRNG
   File /usr/share/pyshared/Crypto/Random/_UserFriendlyRNG.py, line 36, in 
 module
 from Crypto.Random.Fortuna import FortunaAccumulator
   File /usr/share/pyshared/Crypto/Random/Fortuna/FortunaAccumulator.py, 
 line 34, in module
 import SHAd256
   File /usr/share/pyshared/Crypto/Random/Fortuna/SHAd256.py, line 38, in 
 module
 from Crypto.Hash import SHA256
 ImportError: cannot import name SHA256

Works for me.

 New try with just python-crypto:
 
 from Crypto.Hash import SHA256
 Traceback (most recent call last):
   File stdin, line 1, in module
 ImportError: cannot import name SHA256

Works again.

So I need some more information. It seems that your sys.path doesn't include
/usr/lib/python2.6/dist-packages. Otherwise the module should be found. How does
your sys.path look like?

 Then, trying to import just the SHA256 module from its directory:
 
 $ cd /usr/lib/python2.6/dist-packages/Crypto/Hash
 $ python
 Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
 [GCC 4.4.5] on linux2
 Type help, copyright, credits or license for more information.
 import SHA256
 Traceback (most recent call last):
   File stdin, line 1, in module
 SystemError: dynamic module not initialized properly

That's expected as the module is named Crypto.Hash.SHA256 so you can't just
import it as SHA256.

Kind regards,
-- 
Sebastian Ramacher



signature.asc
Description: OpenPGP digital signature