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. Advertising

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. David Hirschfield

    Help: Trouble with imp.load_module

    David Hirschfield, Dec 11, 2007, in forum: Python
    Replies:
    0
    Views:
    300
    David Hirschfield
    Dec 11, 2007
  2. Gabriel Genellina

    Re: Help: Trouble with imp.load_module

    Gabriel Genellina, Dec 17, 2007, in forum: Python
    Replies:
    0
    Views:
    399
    Gabriel Genellina
    Dec 17, 2007
  3. Paul Sijben
    Replies:
    1
    Views:
    401
    Christian Heimes
    Feb 1, 2008
  4. Replies:
    2
    Views:
    1,101
  5. MRAB
    Replies:
    0
    Views:
    439
Loading...

Share This Page