This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients ncoghlan
Date 2012-05-14.07:43:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Reading, it occurred to me that there are various tracing and profiling operations that could be cleanly handled with significantly less work on the part of the tracing/profiling tool authors if the interpreter supported a "-C" operation that was like the existing "-c" option, but *didn't* terminate the options list.

The interpreter would invoke such commands after the interpreter is fully initialised, but before it begins the processing to find and execute __main__.

Then, to use subprocess coverage with as an example, you could just run a command like:

"python -C 'import coverage; coverage.process_startup()'"

Other things you could usefully do in such an invocation is reconfigure sys.std(in|out|err) to match the settings used on the invoking side (e.g. to ensure Unicode data is tunnelled correctly), configure the logging module with a custom configuration, configure the warnings module programmatically, enable a memory profiler, etc.

Providing a function that could be called from -C and then uses an atexit() handler to do any necessary post-processing may be significantly simpler than trying to use runpy.run_(path|module) to achieve a similar effect.
Date User Action Args
2012-05-14 07:43:39ncoghlansetrecipients: + ncoghlan
2012-05-14 07:43:39ncoghlansetmessageid: <>
2012-05-14 07:43:38ncoghlanlinkissue14803 messages
2012-05-14 07:43:38ncoghlancreate