DelphiVCL4Python icon indicating copy to clipboard operation
DelphiVCL4Python copied to clipboard

Doc strings are not Utf8 encoded

Open pyscripter opened this issue 2 years ago • 8 comments

The doc strings are not utf8 encoded as python expects them to be and this causes issues when doing introspection.

For example this causes https://github.com/pyscripter/pyscripter/issues/1288.

Please make sure that all doc strings are utf8 encoded.

pyscripter avatar Jan 19 '24 15:01 pyscripter

Hello @pyscripter, are you still facing this issue?

lmbelo avatar Jan 22 '24 12:01 lmbelo

Hello @pyscripter, are you still facing this issue?

It is present in 1.0.5

pyscripter avatar Jan 22 '24 12:01 pyscripter

Can you explain where to modify it and how to modify it? I want to try to modify it myself. : )

fansxs avatar Jun 23 '24 07:06 fansxs

In version 1.05 the culprit is Screen.Realign

Run the following script:

from delphivcl import Screen
print(Screen.Realign.__doc__)

Output:

Traceback (most recent call last):
  File "<module1>", line 2, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 37: invalid start byte

Workaround for PyScripter:

from delphivcl import *
del(Screen)

pyscripter avatar Jun 23 '24 10:06 pyscripter

It works fine, thank you very much!

fansxs avatar Jun 23 '24 15:06 fansxs

Now I can debug delphivcl using debug function normally.

fansxs avatar Jun 23 '24 15:06 fansxs

In WrapVclForms.pas in P4D, remove the quotes in the doc string PythonType.AddMethod('Realign', @TPyDelphiScreen.Realign_Wrapper, PAnsiChar('TScreen.Realign()'#10 + 'Realigns the screens forms according to their Align properties.')); // screen’s -> screens, it is work!

You solved a problem that has been bothering me for a long time, thank you and the delphivcl4python team very much!

fansxs avatar Jun 23 '24 15:06 fansxs

Already fixed in PyScripter/python4delphi.

pyscripter avatar Jun 23 '24 15:06 pyscripter