Being a bit confused after hacking Python

Wolfgang Draxinger wdraxinger at darkstargames.de
Tue Jul 16 12:50:35 EDT 2002


Pete Shinners wrote:
> as for reloading sys resetting stdout, why do you ever need to reload 
> it? if you just want to reset the stdout variables, just set sys.stdout 
> to sys.__stdout__. the __stdout__ is the "original" stdout object.

No, the reloas is not a real problem, since the engine internally 
redirects the stdlib file pointers stdin and stdout to a internal pipe, 
so I still get the output. I expected that behaviour and wondered if I 
could bypass it, so hacked the pythoncore sources and found that somehow 
PyImport_ReloadModule() is reloading sys somehow, but I didn't found out 
  how it does this. It more a question out of interest. If I'd really 
need certain builtin modules in a specific state after a reload I'd just 
hook that to and watch for these modules reloaded to change them 
thereafter back to my engine's stuff.

-- 
+------------------------------------------------+
| +----------------+ WOLFGANG DRAXINGER          |
| | ,-.   DARKSTAR | lead programmer             |
| |(   ) +---------+ wdraxinger at darkstargames.de |
| | `-' / GAMES /                                |
| +----+''''''''     http://www.darkstargames.de |
+------------------------------------------------+




More information about the Python-list mailing list