Issue 122829 - python ctypes library fails to import
Summary: python ctypes library fails to import
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 4.0.0
Hardware: All Windows, all
: P3 Normal
Target Milestone: 4.0.1
Assignee: hdu@apache.org
QA Contact:
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2013-07-24 21:47 UTC by Jim
Modified: 2013-12-18 09:19 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---
jsc: 4.0.1_release_blocker+


Attachments
Patch to be back ctypes (2.17 KB, patch)
2013-08-07 15:46 UTC, hanya
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description Jim 2013-07-24 21:47:52 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.
Comment 1 hanya 2013-07-25 08:44:00 UTC
No _ctypes.pyd found. It is not built because the part to build _ctypes is commented.
Comment 2 Ariel Constenla-Haile 2013-07-27 18:08:49 UTC
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
>>>
Comment 3 Ariel Constenla-Haile 2013-07-27 18:13:46 UTC
(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.
Comment 4 hanya 2013-08-07 15:46:40 UTC
Created attachment 81265 [details]
Patch to be back ctypes

To remove commented part from the patch for pcbuild.
Comment 5 SVN Robot 2013-08-12 11:41:09 UTC
"hdu" committed SVN revision 1513112 into trunk:
#i122829# re-enable python ctypes for Windows build
Comment 6 hdu@apache.org 2013-08-12 11:42:59 UTC
Fixed with Hanya's patch above. Thank you very much!
Comment 7 jsc 2013-08-15 08:52:20 UTC
approve as showstopper
Comment 8 SVN Robot 2013-08-15 11:37:40 UTC
"hdu" committed SVN revision 1514238 into branches/AOO401:
#i122829# re-enable python ctypes for Windows build
Comment 9 hdu@apache.org 2013-08-15 12:00:24 UTC
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.
Comment 10 hdu@apache.org 2013-08-15 12:07:07 UTC
(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
Comment 11 hdu@apache.org 2013-08-15 12:17:56 UTC
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.