Apache OpenOffice (AOO) Bugzilla – Issue 122829
python ctypes library fails to import
Last modified: 2013-12-18 09:19:17 UTC
The following example Python code demonstrates the problem: #!/usr/bin/python import ctypes def test(): pass g_exportedScripts = test, Running this from "Tools -> My Macros" gives an ImportError: type_ctypes.Union is unknown. I have AOO 4.0 (just upgraded from AOO 3.4.1) and LO 4.0 installed on my Win8 machine. Until the upgrade, there was no problem using the ctypes library. The full error message: A Scripting Framework error occurred while running the Python script vnd.sun.star.script:1.py$test?language=Python&location=user. Message:<type 'exceptions.ImportError'>: type_ctypes.Union is unknown C:\Program Files\OpenOffice 4\program\uno.py:282 in function _uno_import() [raise ImportError("type "+ name + "." + x + " is unknown")] C:\Program Files\OpenOffice 4\program\python-core-2.7.5\lib\ctypes\__init__.py:10 in function <module>() [from _ctypes import Union, Structure, Array] C:\Program Files\OpenOffice 4\program\uno.py:244 in function _uno_import() [return _g_delegatee(name, *optargs, **kwargs)] C:\Users\Jim\AppData\Roaming\OpenOffice\4\user\Scripts\python\1.py:2 in function <module>() [import ctypes] C:\Program Files\OpenOffice 4\program\pythonscript.py:440 in function getModuleByUrl() [exec(code, entry.module.__dict__)] C:\Program Files\OpenOffice 4\program\pythonscript.py:981 in function getScript() [mod = self.provCtx.getModuleByUrl(fileUri)] Does anyone else experience this error? If it is a problem unique to my installation then this is only an annoyance. If not, then my extension will no longer work for other people to use, which would be a bigger problem.
No _ctypes.pyd found. It is not built because the part to build _ctypes is commented.
This is reproducible in 3.4.1: C:\Documents and Settings\ariel>"C:\Archivos de programa\OpenOffice.org 3\program\python.exe" Python 2.6.1 (r261:67515, Aug 10 2012, 14:01:41) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import ctype Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named ctype >>>
(In reply to Ariel Constenla-Haile from comment #2) > This is reproducible in 3.4.1: Obviously the module is ctypes. Forget the previous comment. Setting regression keyword.
Created attachment 81265 [details] Patch to be back ctypes To remove commented part from the patch for pcbuild.
"hdu" committed SVN revision 1513112 into trunk: #i122829# re-enable python ctypes for Windows build
Fixed with Hanya's patch above. Thank you very much!
approve as showstopper
"hdu" committed SVN revision 1514238 into branches/AOO401: #i122829# re-enable python ctypes for Windows build
Now also merge into the AOO 4.0.1 branch. Why SVN 1.6.17 decided to also record svn:mergeinfo changes (regarding the main/python only change in revision 1512298) in completely unrelated code such as main/cui is a mystery. Interestingly it recorded svnprop changes for the same unrelated code parts in revision 1513510 or revision 1513506. As it is not planned to use the svn mergeinfo in the AOO401 branch these artifacts are uncritical though.
(In reply to hdu@apache.org from comment #9) > (regarding the main/python only change in revision 1512298) typo: should have been revision 1513112 instead of 1512298
It turns out that the mergeinfo changes in unrelated parts were a known problem of svn versions smaller than 1.7: http://subversion.apache.org/docs/release-notes/1.7.html#subtree-mergeinfo-recording Though this info is unrelated to the ctypes issue knowing about these SVN artifacts is important for reviewing changes in our precious release branch.