diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-10-31 17:36:21 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-10-31 17:36:21 (GMT) |
commit | a28cf6fef927dce1d7ab21c322a959b835674e78 (patch) | |
tree | 8f1c5274907eac249d685a49e4c856411669fc46 /Doc | |
parent | 742b2f8d7a6b728e925ad83f704af0ff5fb06848 (diff) | |
parent | 0a4dfc3db93120581d15d70885ad76789963082b (diff) | |
download | cpython-a28cf6fef927dce1d7ab21c322a959b835674e78.zip cpython-a28cf6fef927dce1d7ab21c322a959b835674e78.tar.gz cpython-a28cf6fef927dce1d7ab21c322a959b835674e78.tar.bz2 |
merge heads
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/sys.rst | 6 | ||||
-rw-r--r-- | Doc/data/refcounts.dat | 4 | ||||
-rw-r--r-- | Doc/extending/embedding.rst | 21 | ||||
-rw-r--r-- | Doc/library/ctypes.rst | 4 | ||||
-rw-r--r-- | Doc/library/unittest.mock.rst | 3 | ||||
-rw-r--r-- | Doc/library/winreg.rst | 49 |
6 files changed, 43 insertions, 44 deletions
diff --git a/Doc/c-api/sys.rst b/Doc/c-api/sys.rst index 252bd1a..9760dca 100644 --- a/Doc/c-api/sys.rst +++ b/Doc/c-api/sys.rst @@ -61,12 +61,6 @@ accessible to C code. They all work with the current interpreter thread's Return the object *name* from the :mod:`sys` module or *NULL* if it does not exist, without setting an exception. -.. c:function:: FILE *PySys_GetFile(char *name, FILE *def) - - Return the :c:type:`FILE*` associated with the object *name* in the - :mod:`sys` module, or *def* if *name* is not in the module or is not associated - with a :c:type:`FILE*`. - .. c:function:: int PySys_SetObject(char *name, PyObject *v) Set *name* in the :mod:`sys` module to *v* unless *v* is *NULL*, in which diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index a1004ad..fac89af 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -1315,10 +1315,6 @@ PySys_AddWarnOption:char*:s:: PySys_AddXOption:void::: PySys_AddXOption:const wchar_t*:s:: -PySys_GetFile:FILE*::: -PySys_GetFile:char*:name:: -PySys_GetFile:FILE*:def:: - PySys_GetObject:PyObject*::0: PySys_GetObject:char*:name:: diff --git a/Doc/extending/embedding.rst b/Doc/extending/embedding.rst index d004d24..ccbe681 100644 --- a/Doc/extending/embedding.rst +++ b/Doc/extending/embedding.rst @@ -58,6 +58,7 @@ perform some operation on a file. :: int main(int argc, char *argv[]) { + Py_SetProgramName(argv[0]); /* optional but recommended */ Py_Initialize(); PyRun_SimpleString("from time import time,ctime\n" "print('Today is', ctime(time()))\n"); @@ -65,14 +66,18 @@ perform some operation on a file. :: return 0; } -The above code first initializes the Python interpreter with -:c:func:`Py_Initialize`, followed by the execution of a hard-coded Python script -that print the date and time. Afterwards, the :c:func:`Py_Finalize` call shuts -the interpreter down, followed by the end of the program. In a real program, -you may want to get the Python script from another source, perhaps a text-editor -routine, a file, or a database. Getting the Python code from a file can better -be done by using the :c:func:`PyRun_SimpleFile` function, which saves you the -trouble of allocating memory space and loading the file contents. +Function :c:func:`Py_SetProgramName` should be called before +:c:func:`Py_Initialize` to inform the interpreter about paths to +Python run-time libraries. Next initialize the Python interpreter +with :c:func:`Py_Initialize`, followed by the execution of a +hard-coded Python script that prints the date and time. Afterwards, +the :c:func:`Py_Finalize` call shuts the interpreter down, followed by +the end of the program. In a real program, you may want to get the +Python script from another source, perhaps a text-editor routine, a +file, or a database. Getting the Python code from a file can better +be done by using the :c:func:`PyRun_SimpleFile` function, which saves +you the trouble of allocating memory space and loading the file +contents. .. _lower-level-embedding: diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 3e4afd1..e848723 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1094,8 +1094,8 @@ testing. Try it out with ``import __hello__`` for example. Surprises ^^^^^^^^^ -There are some edges in :mod:`ctypes` where you may be expect something else than -what actually happens. +There are some edges in :mod:`ctypes` where you might expect something other +than what actually happens. Consider the following example:: diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index 3e50031..8e72696 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -1,3 +1,4 @@ + :mod:`unittest.mock` --- mock object library ============================================ @@ -646,7 +647,7 @@ the `new_callable` argument to `patch`. which have no meaning on a non-callable mock. Mock objects that use a class or an instance as a `spec` or `spec_set` are able -to pass `isintance` tests: +to pass `isinstance` tests: >>> mock = Mock(spec=SomeClass) >>> isinstance(mock, SomeClass) diff --git a/Doc/library/winreg.rst b/Doc/library/winreg.rst index c05ee2c..60f3bd9 100644 --- a/Doc/library/winreg.rst +++ b/Doc/library/winreg.rst @@ -12,6 +12,17 @@ integer as the registry handle, a :ref:`handle object <handle-object>` is used to ensure that the handles are closed correctly, even if the programmer neglects to explicitly close them. +.. _exception-changed: + +.. versionchanged:: 3.3 + Several functions in this module used to raise a + :exc:`WindowsError`, which is now an alias of :exc:`OSError`. + +.. _functions: + +Functions +------------------ + This module offers the following functions: @@ -37,12 +48,11 @@ This module offers the following functions: *key* is the predefined handle to connect to. - The return value is the handle of the opened key. If the function fails, a + The return value is the handle of the opened key. If the function fails, an :exc:`OSError` exception is raised. .. versionchanged:: 3.3 - This function used to raise a :exc:`WindowsError`, which is now an - alias of :exc:`OSError`. + See :ref:`above <exception-changed>`. .. function:: CreateKey(key, sub_key) @@ -60,12 +70,11 @@ This module offers the following functions: If the key already exists, this function opens the existing key. - The return value is the handle of the opened key. If the function fails, a + The return value is the handle of the opened key. If the function fails, an :exc:`OSError` exception is raised. .. versionchanged:: 3.3 - This function used to raise a :exc:`WindowsError`, which is now an - alias of :exc:`OSError`. + See :ref:`above <exception-changed>`. .. function:: CreateKeyEx(key, sub_key, reserved=0, access=KEY_WRITE) @@ -89,14 +98,13 @@ This module offers the following functions: If the key already exists, this function opens the existing key. - The return value is the handle of the opened key. If the function fails, a + The return value is the handle of the opened key. If the function fails, an :exc:`OSError` exception is raised. .. versionadded:: 3.2 .. versionchanged:: 3.3 - This function used to raise a :exc:`WindowsError`, which is now an - alias of :exc:`OSError`. + See :ref:`above <exception-changed>`. .. function:: DeleteKey(key, sub_key) @@ -112,11 +120,10 @@ This module offers the following functions: *This method can not delete keys with subkeys.* If the method succeeds, the entire key, including all of its values, is removed. - If the method fails, a :exc:`OSError` exception is raised. + If the method fails, an :exc:`OSError` exception is raised. .. versionchanged:: 3.3 - This function used to raise a :exc:`WindowsError`, which is now an - alias of :exc:`OSError`. + See :ref:`above <exception-changed>`. .. function:: DeleteKeyEx(key, sub_key, access=KEY_WOW64_64KEY, reserved=0) @@ -145,15 +152,14 @@ This module offers the following functions: *This method can not delete keys with subkeys.* If the method succeeds, the entire key, including all of its values, is - removed. If the method fails, a :exc:`OSError` exception is raised. + removed. If the method fails, an :exc:`OSError` exception is raised. On unsupported Windows versions, :exc:`NotImplementedError` is raised. .. versionadded:: 3.2 .. versionchanged:: 3.3 - This function used to raise a :exc:`WindowsError`, which is now an - alias of :exc:`OSError`. + See :ref:`above <exception-changed>`. .. function:: DeleteValue(key, value) @@ -176,12 +182,11 @@ This module offers the following functions: *index* is an integer that identifies the index of the key to retrieve. The function retrieves the name of one subkey each time it is called. It is - typically called repeatedly until a :exc:`OSError` exception is + typically called repeatedly until an :exc:`OSError` exception is raised, indicating, no more values are available. .. versionchanged:: 3.3 - This function used to raise a :exc:`WindowsError`, which is now an - alias of :exc:`OSError`. + See :ref:`above <exception-changed>`. .. function:: EnumValue(key, index) @@ -194,7 +199,7 @@ This module offers the following functions: *index* is an integer that identifies the index of the value to retrieve. The function retrieves the name of one subkey each time it is called. It is - typically called repeatedly, until a :exc:`OSError` exception is + typically called repeatedly, until an :exc:`OSError` exception is raised, indicating no more values. The result is a tuple of 3 items: @@ -214,8 +219,7 @@ This module offers the following functions: +-------+--------------------------------------------+ .. versionchanged:: 3.3 - This function used to raise a :exc:`WindowsError`, which is now an - alias of :exc:`OSError`. + See :ref:`above <exception-changed>`. .. function:: ExpandEnvironmentStrings(str) @@ -295,8 +299,7 @@ This module offers the following functions: Allow the use of named arguments. .. versionchanged:: 3.3 - This function used to raise a :exc:`WindowsError`, which is now an - alias of :exc:`OSError`. + See :ref:`above <exception-changed>`. .. function:: QueryInfoKey(key) |