Skip to content

Conversation

@tadeu
Copy link
Contributor

@tadeu tadeu commented Dec 13, 2016

On Windows, with Python >= 3.3, PyObject_Length cannot be used to get
the size of the wchar_t string, because it will count the number of
code points, but some characters not on the BMP will use two UTF-16
code units (surrogate pairs).
This is not a problem on Unix, since wchar_t is 32-bit.

This also fixes a problem where test_builtin_converters.py was not
being run, since the module docstring was not the first statement.

Copy link
Member

@stefanseefeld stefanseefeld left a comment

Choose a reason for hiding this comment

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

Hi Tadeu,

thanks for the patch !
May I ask for two changes:

  • please submit the fix for the test_builtin_converters.py test separately (with a message indicating the bug this fixes).

  • please add a comment to the conditional explaining why PyObject_Length doesn't work (in that case).
    (Just putting the explanation from this pull request itself is fine. The point is to let people reviewing the code understand why this is needed.)

Thanks !

On Windows, with Python >= 3.3, `PyObject_Length` cannot be used to get
the size of the `wchar_t` string, because it will count the number of
*code points*, but some characters not on the BMP will use two UTF-16
*code units* (surrogate pairs).
This is not a problem on Unix, since `wchar_t` is 32-bit.
@tadeu tadeu force-pushed the fix-wstring-conversion branch from 20b8418 to 942fb68 Compare December 14, 2016 11:26
@tadeu
Copy link
Contributor Author

tadeu commented Dec 14, 2016

@stefanseefeld Of course, I've just made the changes, thanks!

@stefanseefeld stefanseefeld merged commit 4e0b96f into boostorg:develop Dec 14, 2016
@stefanseefeld
Copy link
Member

Many thanks !

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.

2 participants