[Python-checkins] cpython (merge 3.5 -> 3.6): Issue #21903: Merge from 3.5

berker.peksag python-checkins at python.org
Wed Sep 28 10:06:12 EDT 2016


https://hg.python.org/cpython/rev/3031e4a95131
changeset:   104125:3031e4a95131
branch:      3.6
parent:      104122:08119dc47cff
parent:      104124:11c3d6a8f5fd
user:        Berker Peksag <berker.peksag at gmail.com>
date:        Wed Sep 28 17:07:40 2016 +0300
summary:
  Issue #21903: Merge from 3.5

files:
  Doc/library/ctypes.rst |  22 ++++++++++------------
  1 files changed, 10 insertions(+), 12 deletions(-)


diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1672,32 +1672,30 @@
 
    The optional third item is the default value for this parameter.
 
-This example demonstrates how to wrap the Windows ``MessageBoxA`` function so
+This example demonstrates how to wrap the Windows ``MessageBoxW`` function so
 that it supports default parameters and named arguments. The C declaration from
 the windows header file is this::
 
    WINUSERAPI int WINAPI
-   MessageBoxA(
+   MessageBoxW(
        HWND hWnd,
-       LPCSTR lpText,
-       LPCSTR lpCaption,
+       LPCWSTR lpText,
+       LPCWSTR lpCaption,
        UINT uType);
 
 Here is the wrapping with :mod:`ctypes`::
 
    >>> from ctypes import c_int, WINFUNCTYPE, windll
-   >>> from ctypes.wintypes import HWND, LPCSTR, UINT
-   >>> prototype = WINFUNCTYPE(c_int, HWND, LPCSTR, LPCSTR, UINT)
-   >>> paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", None), (1, "flags", 0)
-   >>> MessageBox = prototype(("MessageBoxA", windll.user32), paramflags)
-   >>>
-
-The MessageBox foreign function can now be called in these ways::
+   >>> from ctypes.wintypes import HWND, LPCWSTR, UINT
+   >>> prototype = WINFUNCTYPE(c_int, HWND, LPCWSTR, LPCWSTR, UINT)
+   >>> paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", "Hello from ctypes"), (1, "flags", 0)
+   >>> MessageBox = prototype(("MessageBoxW", windll.user32), paramflags)
+
+The ``MessageBox`` foreign function can now be called in these ways::
 
    >>> MessageBox()
    >>> MessageBox(text="Spam, spam, spam")
    >>> MessageBox(flags=2, text="foo bar")
-   >>>
 
 A second example demonstrates output parameters.  The win32 ``GetWindowRect``
 function retrieves the dimensions of a specified window by copying them into

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list