Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_builtin_casters.py test_string_view: Python 2 c++17, c++2a compa… #2314

Merged
merged 1 commit into from
Jul 22, 2020

Conversation

rwgk
Copy link
Collaborator

@rwgk rwgk commented Jul 22, 2020

…tibility.

Tested with 2.7.18rc1, built with Py_UNICODE_SIZE 4.
Change also tested with Python 3.8.

…tibility.

Tested with 2.7.18rc1, built with Py_UNICODE_SIZE 4.
Change also tested with Python 3.8.
Copy link
Collaborator

@YannickJadoul YannickJadoul left a comment

Choose a reason for hiding this comment

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

Same is done here:

assert m.ord_char16(u'a') == 0x61
assert m.ord_char16(u'é') == 0xE9
assert m.ord_char16_lv(u'ê') == 0xEA
assert m.ord_char16(u'Ā') == 0x100
assert m.ord_char16(u'‽') == 0x203d
assert m.ord_char16(u'♥') == 0x2665
assert m.ord_char16_lv(u'♡') == 0x2661
with pytest.raises(ValueError) as excinfo:
assert m.ord_char16(u'🎂') == 0x1F382 # requires surrogate pair
assert str(excinfo.value) == toobig_message(0x10000)
with pytest.raises(ValueError) as excinfo:
assert m.ord_char16(u'aa')
assert str(excinfo.value) == toolong_message
assert m.ord_char32(u'a') == 0x61
assert m.ord_char32(u'é') == 0xE9
assert m.ord_char32(u'Ā') == 0x100
assert m.ord_char32(u'‽') == 0x203d
assert m.ord_char32(u'♥') == 0x2665
assert m.ord_char32(u'🎂') == 0x1F382
with pytest.raises(ValueError) as excinfo:
assert m.ord_char32(u'aa')
assert str(excinfo.value) == toolong_message

So seems great to me! :-)

@rwgk
Copy link
Collaborator Author

rwgk commented Jul 22, 2020

Thanks a lot Yannick for pointing out the other test using the same approach, I missed that. Since there is a precedence for what I'm doing I'll merge this PR now, to get a baseline for my work on PR #2256.

@rwgk rwgk merged commit 96c6763 into pybind:master Jul 22, 2020
@rwgk rwgk deleted the py2_cxx17_fix branch July 22, 2020 19:05
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.

None yet

2 participants