giving imp.load_module not a real file, HOW?

Discussion in 'Python' started by Paul Sijben, Feb 1, 2008.

  1. Paul Sijben

    Paul Sijben Guest

    I am running into a problem with the python interpreter's internals.

    For some reason imp.load_module insists on getting a real open file as
    the second parameter. I have not able to fool it with stringIO or
    overloaded file objects.

    So now I have two questions:
    1) why does load_module insist on a real file
    2) is there a way around it that does not involve (say) tempfile?

    Paul
    Paul Sijben, Feb 1, 2008
    #1
    1. Advertising

  2. Paul Sijben wrote:
    > For some reason imp.load_module insists on getting a real open file as
    > the second parameter. I have not able to fool it with stringIO or
    > overloaded file objects.
    >
    > So now I have two questions:
    > 1) why does load_module insist on a real file
    > 2) is there a way around it that does not involve (say) tempfile?


    imp.load_module is implemented in C. The API expects a file object or a
    file descriptor number. Internally the code creates a file pointer *FILE
    from a file descriptor. You have to create a temporary file.

    Christian
    Christian Heimes, Feb 1, 2008
    #2
    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:
    275
    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:
    376
    Gabriel Genellina
    Dec 17, 2007
  3. Replies:
    2
    Views:
    1,049
  4. MRAB
    Replies:
    0
    Views:
    411
  5. Iuri
    Replies:
    0
    Views:
    171
Loading...

Share This Page