Skip to content

Commit

Permalink
[Part]fix makeWireString for Win & Py > 3.09
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Sep 3, 2022
1 parent 46b70c7 commit 3b29cf1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Mod/Part/App/AppPartPy.cpp
Expand Up @@ -2028,17 +2028,31 @@ class Module : public Py::ExtensionModule<Module>
pysize = PyUnicode_GetLength(p);
#if PY_VERSION_HEX < 0x03090000
unichars = PyUnicode_AS_UNICODE(p);
#else
#ifdef FC_OS_WIN32
//PyUNICODE is only 16 bits on Windows (wchar_t), so passing 32 bit UCS4
//will result in unknow glyph in even positions, and wrong characters in
//odd positions.
unichars = (Py_UNICODE*)PyUnicode_AsWideCharString(p, &pysize);
#else
unichars = (Py_UNICODE *)PyUnicode_AsUCS4Copy(p);
#endif
#endif
}
else if (PyUnicode_Check(intext)) {
pysize = PyUnicode_GetLength(intext);

#if PY_VERSION_HEX < 0x03090000
unichars = PyUnicode_AS_UNICODE(intext);
#else
#ifdef FC_OS_WIN32
//PyUNICODE is only 16 bits on Windows (wchar_t), so passing 32 bit UCS4
//will result in unknow glyph in even positions, and wrong characters in
//odd positions.
unichars = (Py_UNICODE*)PyUnicode_AsWideCharString(intext, &pysize);
#else
unichars = (Py_UNICODE *)PyUnicode_AsUCS4Copy(intext);
#endif
#endif
}
else {
Expand Down

6 comments on commit 3b29cf1

@adrianinsaval
Copy link
Member

Choose a reason for hiding this comment

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

should this be backported?

@WandererFan
Copy link
Contributor Author

@WandererFan WandererFan commented on 3b29cf1 Sep 6, 2022 via email

Choose a reason for hiding this comment

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

@adrianinsaval
Copy link
Member

Choose a reason for hiding this comment

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

There are conda builds for 3.10 I think

@WandererFan
Copy link
Contributor Author

@WandererFan WandererFan commented on 3b29cf1 Sep 7, 2022 via email

Choose a reason for hiding this comment

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

@adrianinsaval
Copy link
Member

Choose a reason for hiding this comment

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

do we risk anything by backporting? I would assume it's better to backport to the official branch so anyone that might need it can get the benefits rather than relying on downstream patching. I have no strong feeling on this so I won't be insisting on it, after all I don't compile on windows.

@WandererFan
Copy link
Contributor Author

@WandererFan WandererFan commented on 3b29cf1 Oct 11, 2022 via email

Choose a reason for hiding this comment

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

Please sign in to comment.