Change command line processing API to use wchar_t.

Fixes #2128.
This commit is contained in:
Martin v. Löwis 2008-04-05 20:41:37 +00:00
parent b9279bc88f
commit 790465fd90
21 changed files with 642 additions and 414 deletions

View file

@ -161,7 +161,7 @@ Initialization, Finalization, and Threads
haven't been explicitly destroyed at that point.
.. cfunction:: void Py_SetProgramName(char *name)
.. cfunction:: void Py_SetProgramName(wchar_t *name)
.. index::
single: Py_Initialize()
@ -170,11 +170,12 @@ Initialization, Finalization, and Threads
This function should be called before :cfunc:`Py_Initialize` is called for
the first time, if it is called at all. It tells the interpreter the value
of the ``argv[0]`` argument to the :cfunc:`main` function of the program.
of the ``argv[0]`` argument to the :cfunc:`main` function of the program
(converted to wide characters).
This is used by :cfunc:`Py_GetPath` and some other functions below to find
the Python run-time libraries relative to the interpreter executable. The
default value is ``'python'``. The argument should point to a
zero-terminated character string in static storage whose contents will not
zero-terminated wide character string in static storage whose contents will not
change for the duration of the program's execution. No code in the Python
interpreter will change the contents of this storage.
@ -188,7 +189,7 @@ Initialization, Finalization, and Threads
value.
.. cfunction:: char* Py_GetPrefix()
.. cfunction:: wchar_t* Py_GetPrefix()
Return the *prefix* for installed platform-independent files. This is derived
through a number of complicated rules from the program name set with
@ -201,7 +202,7 @@ Initialization, Finalization, and Threads
It is only useful on Unix. See also the next function.
.. cfunction:: char* Py_GetExecPrefix()
.. cfunction:: wchar_t* Py_GetExecPrefix()
Return the *exec-prefix* for installed platform-*dependent* files. This is
derived through a number of complicated rules from the program name set with
@ -236,7 +237,7 @@ Initialization, Finalization, and Threads
platform.
.. cfunction:: char* Py_GetProgramFullPath()
.. cfunction:: wchar_t* Py_GetProgramFullPath()
.. index::
single: Py_SetProgramName()
@ -249,7 +250,7 @@ Initialization, Finalization, and Threads
to Python code as ``sys.executable``.
.. cfunction:: char* Py_GetPath()
.. cfunction:: wchar_t* Py_GetPath()
.. index::
triple: module; search; path
@ -342,7 +343,7 @@ Initialization, Finalization, and Threads
``sys.version``.
.. cfunction:: void PySys_SetArgv(int argc, char **argv)
.. cfunction:: void PySys_SetArgv(int argc, wchar_t **argv)
.. index::
single: main()

View file

@ -84,11 +84,11 @@ accessible to C code. They all work with the current interpreter thread's
Reset :data:`sys.warnoptions` to an empty list.
.. cfunction:: void PySys_AddWarnOption(char *s)
.. cfunction:: void PySys_AddWarnOption(wchar_t *s)
Append *s* to :data:`sys.warnoptions`.
.. cfunction:: void PySys_SetPath(char *path)
.. cfunction:: void PySys_SetPath(wchar_t *path)
Set :data:`sys.path` to a list object of paths found in *path* which should
be a list of paths separated with the platform's search path delimiter

View file

@ -336,6 +336,8 @@ the system's :ctype:`wchar_t`.
.. cfunction:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size)
Create a Unicode object from the :ctype:`wchar_t` buffer *w* of the given size.
Passing -1 as the size indicates that the function must itself compute the length,
using wcslen.
Return *NULL* on failure.

View file

@ -25,16 +25,18 @@ are only passed to these functions if it is certain that they were created by
the same library that the Python runtime is using.
.. cfunction:: int Py_Main(int argc, char **argv)
.. cfunction:: int Py_Main(int argc, wchar_t **argv)
The main program for the standard interpreter. This is made available for
programs which embed Python. The *argc* and *argv* parameters should be
prepared exactly as those which are passed to a C program's :cfunc:`main`
function. It is important to note that the argument list may be modified (but
the contents of the strings pointed to by the argument list are not). The return
value will be the integer passed to the :func:`sys.exit` function, ``1`` if the
interpreter exits due to an exception, or ``2`` if the parameter list does not
represent a valid Python command line.
The main program for the standard interpreter. This is made
available for programs which embed Python. The *argc* and *argv*
parameters should be prepared exactly as those which are passed to
a C program's :cfunc:`main` function (converted to wchar_t
according to the user's locale). It is important to note that the
argument list may be modified (but the contents of the strings
pointed to by the argument list are not). The return value will be
the integer passed to the :func:`sys.exit` function, ``1`` if the
interpreter exits due to an exception, or ``2`` if the parameter
list does not represent a valid Python command line.
.. cfunction:: int PyRun_AnyFile(FILE *fp, const char *filename)