giving imp.load_module not a real file, HOW?

P

Paul Sijben

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
 
C

Christian Heimes

Paul said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top