bpo-28698: Fix c_wchar_p doc example#1160
bpo-28698: Fix c_wchar_p doc example#1160berkerpeksag merged 7 commits intopython:masterfrom louisom:fix_28698
Conversation
|
@lulouie, thanks for your PR! By analyzing the history of the files in this pull request, we identified @birkenfeld, @eliben and @benjaminp to be potential reviewers. |
| @@ -309,10 +309,10 @@ bytes objects are immutable):: | |||
| >>> s = "Hello, World" | |||
| >>> c_s = c_wchar_p(s) | |||
| >>> print(c_s) | |||
There was a problem hiding this comment.
I'd change this to c_s.value.
Doc/library/ctypes.rst
Outdated
| c_wchar_p('Hello, World') | ||
| c_wchar_p(140018365411392) | ||
| >>> c_s.value = "Hi, there" | ||
| >>> print(c_s) |
There was a problem hiding this comment.
Same as above. Without using .value the whole example doesn't do a good job on explaining the subject.
There was a problem hiding this comment.
@berkerpeksag I changed to print(c_s, c_s.value), since the content says that "c_wchar_p and c_void_p changes the memory location they point to...", I think observe the memory location changed in c_s is useful, too.
Doc/library/ctypes.rst
Outdated
| c_wchar_p('Hi, there') | ||
| >>> print(s) # first object is unchanged | ||
| >>> print(c_s.value) | ||
| c_wchar_p(139966783348904) Hi, there |
There was a problem hiding this comment.
Are you sure about that one? Why does it print c_wchar_p...?
There was a problem hiding this comment.
ah, is a mistake, it should be print(c_s, c_s.value)
|
@Haypo, @berkerpeksag , commit has updated, please help for review! |
Doc/library/ctypes.rst
Outdated
| >>> c_s = c_wchar_p(s) | ||
| >>> print(c_s) | ||
| c_wchar_p('Hello, World') | ||
| >>> print(c_s, c_s.value) |
There was a problem hiding this comment.
If you really want to keep print(c_s), I'd say move c_s.value to a new line:
>>> print(c_s)
c_wchar_p(139966785747344)
>>> print(c_s.value)
Hello WorldThere was a problem hiding this comment.
Fix this problem, and add a comment to point out that memory location has changed.
Doc/library/ctypes.rst
Outdated
| >>> print(c_s) | ||
| c_wchar_p('Hi, there') | ||
| >>> print(s) # first object is unchanged | ||
| >>> print(c_s) # the memory location have changed |
|
Thanks! |


No description provided.