[Python-Dev] file open in python interpreter (original) (raw)

Nick Coghlan ncoghlan at gmail.com
Mon Nov 3 14:57:07 CET 2008


Benjamin Peterson wrote:

On Mon, Nov 3, 2008 at 7:25 AM, Benjamin Peterson <musiccomposition at gmail.com> wrote:

On Mon, Nov 3, 2008 at 1:04 AM, adrian golding <adriangolding at gmail.com> wrote:

hi all, i am trying to find out where is the part of the code in the python interpreter that opens up the .py file and parses it. in particular, i am trying to find the file open command in that file. I greped and i just want to make sure this is it: /Python-2.6/Parser/pgenmain.c i am intending to take a hash measurement of the .py file just before i open it to run the script. is the above file the right place to call for the measurement before the file open function? You want Parser/tokenizer.c. Sorry, that's not correct. opening of modules happens in Python/import.c. There's also a case in Modules/main.c.

And some indirect ones from runpy.py (via pkgutils) if you use the -m switch, or are executing a zipfile or directory.

But for the specific case of an exact filename being provided on the command line, then main.c is the one the original poster will want to look at (line 567 to be exact).

Cheers, Nick.

-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia



More information about the Python-Dev mailing list