imp.load_module error in Python 3.3

Discussion in 'Python' started by Iuri, Feb 11, 2013.

  1. Iuri

    Iuri Guest

    I want to load a file with an invalid module name (with a dash).

    filename = '...' # something like /my/path/to/ejtp-crypto
    with open(filename, 'rb') as fp:
    my_module = imp.load_module('crypto', fp, 'ejtp-crypto', ('.py',
    'rb', imp.PY_SOURCE))

    It works to all Python >= 2.5, except 3.3. Some behaviour changed to break
    it or is it a regression bug?

    I know imp.load_module is deprecated in 3.3, but I didn't found anything
    related with behaviour changes.

    Also, I didn't understanded how exactly change my code to use importlib,
    can you help me with this change?

    Thanks!
     
    Iuri, Feb 11, 2013
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abs
    Replies:
    6
    Views:
    2,096
  2. SMG
    Replies:
    1
    Views:
    1,611
    John Saunders
    Jul 26, 2004
  3. Luis Esteban Valencia
    Replies:
    1
    Views:
    1,605
    Carl Prothman [MVP]
    Jan 12, 2005
  4. David Hirschfield

    Help: Trouble with imp.load_module

    David Hirschfield, Dec 11, 2007, in forum: Python
    Replies:
    0
    Views:
    379
    David Hirschfield
    Dec 11, 2007
  5. Paul Sijben
    Replies:
    1
    Views:
    496
    Christian Heimes
    Feb 1, 2008
  6. Replies:
    2
    Views:
    1,309
  7. Sergey
    Replies:
    3
    Views:
    220
    Sergey
    Dec 13, 2013
  8. Sergey
    Replies:
    0
    Views:
    117
    Sergey
    Dec 11, 2013
Loading...