Message37180
I'm not sure a PEP is required for this patch, but these functions are pre-requisiste for two other
PEP in the pipe...
I have not always had easy access to news posting, so I'll be the happier this can go through
without all the PEP overhead, otherwise, I'll try to follow up the PEP.
I'm submitting this as a PEP in the same time, to the Director of PEP Affairs, as indicated in the
PEP
meta PEP 000 (barry), with a reference to this patch (file attached).
Frederic Giacometti
---------------------------
PEP XXX: Additions to the C API
fred@arakne.com (Frederic Giacometti)
Abstract
This PEP defines a couple of C functions.
The first two functions are for raising exceptions with multiple arguments;
the third one is for calling a method when an arg tuple is given;
and the other ones programmatically define sys.path
and the optimization level in embedded python context,
before initialization of the global Python engine.
Copyright: This document is published under the Open Publication License.
Specification:
PyObject* PyErr_RaiseArgs( PyObject* exctype, PyObject* args)
Raise the exception created by applying args to exctype.
This is equivalent to the Python expression
raise apply( exctype, args).
Always set the error state and return NULL.
PyObject* PyErr_Raise( PyObject* exctype, char const* format, ...)
This function is similar to PyErr_RaiseArgs(),
but defines the arguments using the same convention as
Py_BuildValue().
Always set the error state and return NULL.
PyObject* PyObject_CallMethodArgs( PyObject* o,
char const* method, PyObject* args)
Call the method named 'method' with arguments given by the tuple args,
using for args the same convention as PyObject_CallObject().
This is the equivalent of the Python expression
o.method( args).
Note that special method names, such as __add__(),
__getitem__(), and so on are not supported. The specific
abstract-object routines for these must be used.
void Py_SetPythonPath( char const* path)
This function should be called before
Py_Initialize()
is called for the first time, if it is called at all.
It defines the PYTHONPATH value to be used by the interpreter.
Calling Py_SetPythonPath() will override the
PYTHONPATH value from the environment.
The argument should be NULL, or point to a zero-terminated character string
which will not change for the duration of the program's execution.
char const* Py_GetPythonPath()
If Py_SetPythonPath()
was never called, getenv( "PYTHONPATH") is returned,
otherwise the argument of Py_SetPythonPath() is returned.
The returned string points into static storage.
void Py_SetOptimizeLevel( int level)
This function should be called before
Py_Initialize()
is called for the first time.
Legal optimization levels are listed below.
\begin{tableii}{c|l}{character}{Character}{Meaning}
\lineii{0}{No optimization (use \code{.pyc} files by default)}
\lineii{1}{Same as \code{python -O}}
\lineii{2}{Same as \code{python -OO}}
\end{tableii}
int Py_GetOptimizeLevel()
Return the interpreter optimization level.
Reference Implementation:
See attached patch (concatenation of 2 patch files).
|
|
Date |
User |
Action |
Args |
2007-08-23 15:06:53 | admin | link | issue448305 messages |
2007-08-23 15:06:53 | admin | create | |
|