On Mon, 2009-01-12 at 00:28 +0100, Adam Williamson wrote:
> On Sun, 2009-01-11 at 15:21 -0800, Adam Williamson wrote:
> > On Sun, 2009-01-11 at 22:42 +0300, Ilya Bakulin wrote:
> > > Hi!
> > > SynCE 0.13 is out, it's time to update Ports Collection... Unfortunately, 
> > > I've discovered that python bindings for librapi2 don't compile any more. 
> > > Yet another problem with damned pyrexc...
> > > Pyrexc version used at my system is 0.9.8.5. It's the latest version 
> > > available in ports.
> >
> > Confirmed here, same problem with Mandriva Cooker...let me poke about
> > and see if I can fix it...
> 
> Bah, no, I'm no coder.
> 
> I mean, you could just take out the "with nogil:" lines in the relevant
> places, but presumably they're there for a reason.
> 
> This is a discussion of what it's doing wrong:
> 
> http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/Manual/external.html#Acquiring_and_Releasing_the_GIL
> 
> but I can't make much of it. Presumably either the code shouldn't
> release the gil (in which case I guess other modifications may be
> needed), or what it does after releasing the gil should be adjusted to
> be within the rules.
> --

I hope this gets through, my ISP appears to be having mail problems.

This is caused by additional checking being done in later versions of
pyrex, bah !

I use 0.9.7, which leaves it to the developer to check all functions
called in a nogil sections are nogil safe. It would seem at some point
checks were added so only functions declared as nogil safe are accepted
in a nogil section. Of course the nice way to declare a group of
external functions nogil safe is a relatively recent addition as well,
so I can't use that without requiring a later version.

That's all beside the point. The attached patch should fix the problem.
I've tested it with pyrex 0.9.6, 0.9.7 and 0.9.8.5. Can you guys double
check it works for me, and when confirmed I'll do a 0.13.1 release.

Ta
Mark



--- librapi2-0.13.orig/python/pyrapi2.pyx	2009-01-05 17:59:53.000000000 +0000
+++ librapi2-0.13/python/pyrapi2.pyx	2009-01-12 08:18:46.000000000 +0000
@@ -10,10 +10,10 @@
     void free(void *ptr)
 
 cdef extern from "synce.h":
-    char *wstr_to_utf8(LPCWSTR unicode)
-    LPWSTR wstr_from_utf8(char *utf8)
-    void wstr_free_string(void *str)
-    char* synce_strerror(DWORD error)
+    char *wstr_to_utf8(LPCWSTR unicode) nogil
+    LPWSTR wstr_from_utf8(char *utf8) nogil
+    void wstr_free_string(void *str) nogil
+    char* synce_strerror(DWORD error) nogil
 
 cdef extern from "synce_log.h":
     void synce_log_set_level(int level)
@@ -22,7 +22,7 @@
     void *rapi_connection_from_name(char *device_name)
     void rapi_connection_select(void *connection)
     HRESULT CeRapiInit()
-    HRESULT CeProcessConfig(LPCWSTR config, DWORD flags, LPWSTR* reply)
+    HRESULT CeProcessConfig(LPCWSTR config, DWORD flags, LPWSTR* reply) nogil
     LONG CeRegCreateKeyEx(HKEY hKey, LPCWSTR lpszSubKey, DWORD Reserved, LPWSTR lpszClass, DWORD ulOptions, REGSAM samDesired, LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition)
     LONG CeRegOpenKeyEx(HKEY hKey, LPCWSTR lpszSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
     LONG CeRegCloseKey(HKEY hKey)
@@ -35,13 +35,13 @@
     HRESULT CeSyncResume()
     HRESULT CeSyncPause()
     HRESULT CeSyncTimeToPc()
-    BOOL CeGetSystemPowerStatusEx(PSYSTEM_POWER_STATUS_EX pSystemPowerStatus, BOOL refresh)
+    BOOL CeGetSystemPowerStatusEx(PSYSTEM_POWER_STATUS_EX pSystemPowerStatus, BOOL refresh) nogil
     DWORD CeGetDiskFreeSpaceEx( LPCTSTR _lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes)
     BOOL CeFindAllFiles( LPCWSTR szPath, DWORD dwFlags, LPDWORD lpdwFoundCount, LPLPCE_FIND_DATA ppFindDataArray)
 
     BOOL CeCloseHandle(HANDLE hObject)
     HANDLE CeCreateFile( LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
-    BOOL CeWriteFile( HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
+    BOOL CeWriteFile( HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped) nogil
     BOOL CeReadFile( HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
 
     BOOL CeCreateProcess( LPCWSTR lpApplicationName, LPCWSTR lpCommandLine, void* lpProcessAttributes, void* lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPWSTR lpCurrentDirectory, void* lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)

Attachment: signature.asc
Description: This is a digitally signed message part

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
SynCE-Devel mailing list
SynCE-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synce-devel

Reply via email to