Skip to content

Detect the size of wchar_t (aka Runtime.UCS) at runtime using PyUnicode_GetMax #1298

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

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

lostmsu
Copy link
Member

@lostmsu lostmsu commented Nov 30, 2020

What does this implement/fix? Explain your changes.

This determines the value for Runtime.UCS at runtime instead of using compile-time defines, removing the need for separate builds of Python.Runtime.

Does this close any currently open issues?

N/A

Any other comments?

PyUnicode_GetMax is deprecated, but preserved for compatibility.

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

@lostmsu lostmsu requested a review from filmor November 30, 2020 02:41
@codecov-io
Copy link

codecov-io commented Nov 30, 2020

Codecov Report

Merging #1298 (4d43b54) into master (182faed) will decrease coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1298      +/-   ##
==========================================
- Coverage   87.97%   87.88%   -0.09%     
==========================================
  Files           1        1              
  Lines         291      289       -2     
==========================================
- Hits          256      254       -2     
  Misses         35       35              
Flag Coverage Δ
setup_linux 65.05% <ø> (-0.25%) ⬇️
setup_windows 74.04% <ø> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
setup.py 87.88% <ø> (-0.09%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 182faed...4d43b54. Read the comment docs.

@markuspalme
Copy link

This could possibly solve #114.

@filmor
Copy link
Member

filmor commented Nov 30, 2020

Great, I wasn't aware of PyUnicode_GetMax. We should probably find a more sustainable solution at some point (as the function is explicitly deprecated), but this will do nicely for now :)

@lostmsu lostmsu merged commit 67c6d11 into pythonnet:master Nov 30, 2020
@lostmsu lostmsu deleted the features/RuntimeUcsSize branch November 30, 2020 17:50
@sekkit
Copy link

sekkit commented Oct 10, 2021

ctypes.sizeof(ctypes.c_wchar) would do the trick

@filmor
Copy link
Member

filmor commented Oct 10, 2021

@lostmsu It looks like the symbol is scheduled for removal for Python 3.10, I'll look into this s.t. we can start supporting 3.10 earlier than we could with 3.9 :)

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.

5 participants