Skip to content

bpo-28698: Fix c_wchar_p doc example#1160

Merged
berkerpeksag merged 7 commits into
python:masterfrom
louisom:fix_28698
Apr 26, 2017
Merged

bpo-28698: Fix c_wchar_p doc example#1160
berkerpeksag merged 7 commits into
python:masterfrom
louisom:fix_28698

Conversation

@louisom

@louisom louisom commented Apr 16, 2017

Copy link
Copy Markdown
Contributor

No description provided.

@mention-bot

Copy link
Copy Markdown

@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.

Comment thread Doc/library/ctypes.rst
@@ -309,10 +309,10 @@ bytes objects are immutable)::
>>> s = "Hello, World"
>>> c_s = c_wchar_p(s)
>>> print(c_s)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change this to c_s.value.

Comment thread Doc/library/ctypes.rst Outdated
c_wchar_p('Hello, World')
c_wchar_p(140018365411392)
>>> c_s.value = "Hi, there"
>>> print(c_s)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Without using .value the whole example doesn't do a good job on explaining the subject.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about that one? Why does it print c_wchar_p...?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, is a mistake, it should be print(c_s, c_s.value)

@louisom

louisom commented Apr 26, 2017

Copy link
Copy Markdown
Contributor Author

@Haypo, @berkerpeksag , commit has updated, please help for review!
Thanks!

Comment thread 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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 World

@louisom louisom Apr 26, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix this problem, and add a comment to point out that memory location has changed.

Comment thread 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: have -> has

@berkerpeksag

Copy link
Copy Markdown
Member

Thanks!

berkerpeksag pushed a commit that referenced this pull request Apr 26, 2017
berkerpeksag pushed a commit that referenced this pull request Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants