You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When I try to use the Chinese namespace in C# #662
@charSLee013 It seems the exist of method PyString_FromString is to be compatible with python2. So for users it should not be used with unicode strings.
From only the point of view of Python3, this method should work with unicode string, so your discovery about the PyString_FromString is a bug of pythonnet.
A recommended fix is call PyUnicode_FromString instead of the faked PyString_FromStringAndSize method of Python3.
Even with this modification, Chinese namespace is not working now. The problem here is that pythonnet needs to support Python2 and Python3 at the same time. Python3 supports modules with chinese name but Python2 does not. So nobody tests this before.
Since both .net and Python3 support Chinese namespace, pythonnet with Python3 should work with Chinese namespace in theory. It seems one problem is located in the import hooks (maybe not the only one), heavily debugging work is needed.
Activity
den-run-ai commentedon Apr 18, 2018
@charSLee013 this is likely not going to be supported, but let's check with @yagweb if this makes any sense.
charSLee013 commentedon Apr 18, 2018
This bug is very big, which is also a hindrance to the globalization of Pythonnet. We need to solve this problem urgently and hope to get your help :)
den-run-ai commentedon Apr 18, 2018
Contributions are welcome!
charSLee013 commentedon Apr 19, 2018
I tried to troubleshoot the problem, when running to
moduleobject.cs1194 lines ,pynamereturns null pointerI tried to find the problem, and found it in
runtime.csline 1194 , and changed it to the following code.The exciting thing is that it does.
But in
pythonengine.csin line 191 appeared error, unable to loadclr._extrasmoduleyagweb commentedon Apr 19, 2018
@charSLee013 It seems the exist of method PyString_FromString is to be compatible with python2. So for users it should not be used with unicode strings.
From only the point of view of Python3, this method should work with unicode string, so your discovery about the PyString_FromString is a bug of pythonnet.
A recommended fix is call PyUnicode_FromString instead of the faked PyString_FromStringAndSize method of Python3.
Even with this modification, Chinese namespace is not working now. The problem here is that pythonnet needs to support Python2 and Python3 at the same time. Python3 supports modules with chinese name but Python2 does not. So nobody tests this before.
Since both .net and Python3 support Chinese namespace, pythonnet with Python3 should work with Chinese namespace in theory. It seems one problem is located in the import hooks (maybe not the only one), heavily debugging work is needed.
charSLee013 commentedon Apr 19, 2018
Looking forward to your good news, this test result is very important @yagweb
daixinwei2018 commentedon May 1, 2018
楼主你好,因为看你给出的示例,我知道你是中国人。我是刚刚接触pythonnet,对这个并不是特别熟悉,我本来想运行一下你的代码(我把中文换为了英文),但是还是报错。

如果可以的话,我想多问问您一些c#调用python相关的问题,谢谢!
den-run-ai commentedon May 1, 2018
Pinvokestackimbalance is fixed in master branch @daixinwei2018
filmor commentedon Aug 29, 2018
The fix was this has been merged to master, so I'll close this. Feel free to reopen if the version in the master branch doesn't solve the issue.