From 7ea6f706ac38c52b822495ddeff67f24f3109d8d Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 31 Oct 2012 11:29:52 +0200 Subject: Fix typo in mock docs. --- Doc/library/unittest.mock.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) -- cgit v0.12 From 6a5c7c341ac654bda89b2d111aecb6d0a08fe6a2 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 31 Oct 2012 11:50:40 +0200 Subject: Fix docstring for deque ctor to mark iterable parameter optional --- Modules/_collectionsmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c index 314bafd..54c1343 100644 --- a/Modules/_collectionsmodule.c +++ b/Modules/_collectionsmodule.c @@ -1019,7 +1019,7 @@ static PyMethodDef deque_methods[] = { }; PyDoc_STRVAR(deque_doc, -"deque(iterable[, maxlen]) --> deque object\n\ +"deque([iterable[, maxlen]]) --> deque object\n\ \n\ Build an ordered collection with optimized access from its endpoints."); -- cgit v0.12 From 4deb16dd7585582276714cae2d98b55db7fe6568 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 31 Oct 2012 12:02:56 +0200 Subject: Remove already dropped function PySys_GetFile from documentation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Daniel Müllner from docs@ --- Doc/c-api/sys.rst | 6 ------ Doc/data/refcounts.dat | 4 ---- 2 files changed, 10 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 c7d7bd1..b5dde33 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -1310,10 +1310,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:: -- cgit v0.12 From e1fa22a8ae02f3321a0878456173d68922e78804 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 31 Oct 2012 16:03:14 +0200 Subject: Issue #16370: Mention Py_SetProgramName in example for very high level embedding. --- Doc/extending/embedding.rst | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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: -- cgit v0.12 From ec42255039d45d9da65e52c2c21c8518334c2661 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 31 Oct 2012 16:20:54 +0200 Subject: Issue #16371: fix typo in ctypes documentation. Thanks to George Yoshida. --- Doc/library/ctypes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 3c602c8..83d49bd 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1155,7 +1155,7 @@ 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 +There are some edges in :mod:`ctypes` where you may expect something else than what actually happens. Consider the following example:: -- cgit v0.12 From a2959cea3f3031ea002eaf58a75f657fdef65a1d Mon Sep 17 00:00:00 2001 From: R David Murray Date: Wed, 31 Oct 2012 10:50:27 -0400 Subject: #16371: fix up the English a bit more. --- Doc/library/ctypes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 83d49bd..3887ee1 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1155,8 +1155,8 @@ testing. Try it out with ``import __hello__`` for example. Surprises ^^^^^^^^^ -There are some edges in :mod:`ctypes` where you may 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:: -- cgit v0.12 From 64085e306495769161dc278c5c61490dc767e598 Mon Sep 17 00:00:00 2001 From: Jesus Cea Date: Wed, 31 Oct 2012 17:00:59 +0100 Subject: Closes #16369: Global PyTypeObjects not initialized with PyType_Ready(...). DOCUMENT IT! --- Misc/NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 434f221..be3b1e4 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -58,6 +58,8 @@ Core and Builtins - Issue #15368: An issue that caused bytecode generation to be non-deterministic when using randomized hashing (-R) has been fixed. +- Issue #16369: Global PyTypeObjects not initialized with PyType_Ready(...). + - Issue #15020: The program name used to search for Python's path is now "python3" under Unix, not "python". -- cgit v0.12 From 616f8035a8d7cdbb34f8a6a485d8d9d83767d207 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 31 Oct 2012 19:29:33 +0200 Subject: Issue #16197: Fix several small errors in winreg documentation. Initial patch by Zachary Ware. --- Doc/library/winreg.rst | 49 ++++++++++++++++++++++++++----------------------- PC/winreg.c | 16 ++++++++-------- 2 files changed, 34 insertions(+), 31 deletions(-) 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 ` 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 `. .. 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 `. .. 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 `. .. 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 `. .. 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 `. .. 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 `. .. 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 `. .. 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 `. .. function:: QueryInfoKey(key) diff --git a/PC/winreg.c b/PC/winreg.c index 223ca83..091b477 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -89,7 +89,7 @@ PyDoc_STRVAR(ConnectRegistry_doc, "key is the predefined handle to connect to.\n" "\n" "The return value is the handle of the opened key.\n" -"If the function fails, a WindowsError exception is raised."); +"If the function fails, an OSError exception is raised."); PyDoc_STRVAR(CreateKey_doc, "CreateKey(key, sub_key) -> key\n" @@ -104,7 +104,7 @@ PyDoc_STRVAR(CreateKey_doc, "If the key already exists, this function opens the existing key.\n" "\n" "The return value is the handle of the opened key.\n" -"If the function fails, a WindowsError exception is raised."); +"If the function fails, an OSError exception is raised."); PyDoc_STRVAR(CreateKeyEx_doc, "CreateKeyEx(key, sub_key, reserved=0, access=KEY_WRITE) -> key\n" @@ -122,7 +122,7 @@ PyDoc_STRVAR(CreateKeyEx_doc, "If the key already exists, this function opens the existing key\n" "\n" "The return value is the handle of the opened key.\n" -"If the function fails, a WindowsError exception is raised."); +"If the function fails, an OSError exception is raised."); PyDoc_STRVAR(DeleteKey_doc, "DeleteKey(key, sub_key)\n" @@ -136,7 +136,7 @@ PyDoc_STRVAR(DeleteKey_doc, "This method can not delete keys with subkeys.\n" "\n" "If the function succeeds, the entire key, including all of its values,\n" -"is removed. If the function fails, a WindowsError exception is raised."); +"is removed. If the function fails, an OSError exception is raised."); PyDoc_STRVAR(DeleteKeyEx_doc, "DeleteKeyEx(key, sub_key, access=KEY_WOW64_64KEY, reserved=0)\n" @@ -153,7 +153,7 @@ PyDoc_STRVAR(DeleteKeyEx_doc, "This method can not delete keys with subkeys.\n" "\n" "If the function succeeds, the entire key, including all of its values,\n" -"is removed. If the function fails, a WindowsError exception is raised.\n" +"is removed. If the function fails, an OSError exception is raised.\n" "On unsupported Windows versions, NotImplementedError is raised."); PyDoc_STRVAR(DeleteValue_doc, @@ -171,7 +171,7 @@ PyDoc_STRVAR(EnumKey_doc, "index is an integer that identifies the index of the key to retrieve.\n" "\n" "The function retrieves the name of one subkey each time it is called.\n" -"It is typically called repeatedly until a WindowsError exception is\n" +"It is typically called repeatedly until an OSError exception is\n" "raised, indicating no more values are available."); PyDoc_STRVAR(EnumValue_doc, @@ -181,7 +181,7 @@ PyDoc_STRVAR(EnumValue_doc, "index is an integer that identifies the index of the value to retrieve.\n" "\n" "The function retrieves the name of one subkey each time it is called.\n" -"It is typically called repeatedly, until a WindowsError exception\n" +"It is typically called repeatedly, until an OSError exception\n" "is raised, indicating no more values.\n" "\n" "The result is a tuple of 3 items:\n" @@ -240,7 +240,7 @@ PyDoc_STRVAR(OpenKey_doc, " security access for the key. Default is KEY_READ\n" "\n" "The result is a new handle to the specified key\n" -"If the function fails, a WindowsError exception is raised."); +"If the function fails, an OSError exception is raised."); PyDoc_STRVAR(OpenKeyEx_doc, "See OpenKey()"); -- cgit v0.12