[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

giving imp.load_module not a real file, HOW?

Paul Sijben

2/1/2008 8:14:00 AM

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
1 Answer

Christian Heimes

2/1/2008 3:46:00 PM

0

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