X Tutup
The Wayback Machine - https://web.archive.org/web/20260215120803/https://github.com/python/cpython/pull/1160
Skip to content

bpo-28698: Fix c_wchar_p doc example#1160

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

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

Conversation

@louisom
Copy link
Contributor

@louisom louisom commented Apr 16, 2017

No description provided.

@mention-bot
Copy link

@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)
Copy link
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.

c_wchar_p('Hello, World')
c_wchar_p(140018365411392)
>>> c_s.value = "Hi, there"
>>> print(c_s)
Copy link
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
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.

c_wchar_p('Hi, there')
>>> print(s) # first object is unchanged
>>> print(c_s.value)
c_wchar_p(139966783348904) Hi, there
Copy link
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
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
Copy link
Contributor Author

louisom commented Apr 26, 2017

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

>>> c_s = c_wchar_p(s)
>>> print(c_s)
c_wchar_p('Hello, World')
>>> print(c_s, c_s.value)
Copy link
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

Copy link
Contributor Author

@louisom louisom Apr 26, 2017

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.

>>> print(c_s)
c_wchar_p('Hi, there')
>>> print(s) # first object is unchanged
>>> print(c_s) # the memory location have changed
Copy link
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
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

X Tutup