Re: [bug] TypeError: expected pointer, got Int64

Irmen de Jong <[email protected]>
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 30-4-2012 3:33, Tim Cuthbertson wrote:
> After just installing pyro4 using easy_install (IronPython on windows 7), I get:
> 
> $ cat pyro_test.py import Pyro4 daemon=Pyro4.Daemon() 
> uri=daemon.register({'test':True}) print "Ready. Object uri =", uri 
> daemon.requestLoop()
> 
> $ ipy pyro_test.py C:\Program Files (x86)\IronPython 
> 2.7\lib\site-packages\Pyro4\core.py:1: UserWarning: HMAC_KEY not set, protocol data
> may not be secure """ Traceback (most recent call last): File "C:\Program Files
> (x86)\IronPython 2.7\lib\site-packages\Pyro4\socketutil.py", line 203, in
> createSocket File "C:\Program Files (x86)\IronPython 
> 2.7\lib\site-packages\Pyro4\socketutil.py", line 302, in setNoInherit File
> "pyro_test.py", line 2, in <module> File "C:\Program Files (x86)\IronPython 
> 2.7\lib\site-packages\Pyro4\core.py", line 759, in __init__ File "C:\Program Files
> (x86)\IronPython 2.7\lib\site-packages\Pyro4\socketserver\threadpoolserver.py",
> line 101, in init TypeError: expected pointer, got Int64
> 

Okay, I've traced this to be a problem with IronPython (or rather, .NET). It seems
that it can't get the underlying Windows handle out of the socket object. See this
issue http://ironpython.codeplex.com/workitem/20242?ProjectName=ironpython
or this mail thread
http://python.6.n6.nabble.com/IronPython-and-file-descriptors-td2197344.html

There's nothing Pyro can do about that, other than disabling the setNoInherit function
in Pyro4.socketutil when it's running on IronPython. Which is what I'm going to do
right now.

(Why ipy doesn't report that function as the cause of the error is beyond me, it seems
it's missing one stack frame. The line where it really crashes is 302 in
socketutil.py, where it calls _SetHandleInformation).



> Do I need to run a 64 or 32 bit version or something explicitly somehow?

No, the same error occurs on ipy64.exe.
What you can do in the meantime is apply the attached patch to socketutil.py.


Irmen


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPnl4bAAoJEHC9o7RHFlf2JVUIAJz69BIw5LhY2/cmA47CZXqO
fhhTA9vCgAs9Q7zf2TM9QCQ03bhBU6IVybdEBMeO0aZ1KMP0IagVCZuDyT9sUAZG
yeH9YKemJajIC5HVFm6rCvem+Vh+IA8KXOpm0/h/m3CTfDWLA/saJnDajMQfGfCN
Ww8JqURVZrPj0TUnY4nNU+gaqPfbNdOljqo5vsH6qHPzbHU05rbw9w3AI58xcc3v
6IMGV9Ui8ulq3dgELoqu9PmDIBoZ3mRY0Q4wHL4SpSEfJ48SqVvh4qWefI0OT6vx
QzLIq1HTY5FUnWdN2EbcumjZf+8ATsqdI9n2Q97nBgiPwvVLwKmYgcdVemvJdcM=
=NaU1
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
Pyro-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyro-core
ipysockfix.patch (text/x-patch, 998 B)
Index: src/Pyro4/socketutil.py
===================================================================
--- src/Pyro4/socketutil.py	(revision 707)
+++ src/Pyro4/socketutil.py	(working copy)
@@ -291,6 +291,8 @@
 except ImportError:
     # no fcntl available, try the windows version
     try:
+        if sys.platform=="cli":
+            raise NotImplementedError("IronPython can't obtain a proper HANDLE from a socket")
         from ctypes import windll, WinError, wintypes
         # help ctypes to set the proper args for this kernel32 call on 64-bit pythons
         _SetHandleInformation = windll.kernel32.SetHandleInformation
@@ -302,7 +304,7 @@
             if not _SetHandleInformation(sock.fileno(), 1, 0):
                 raise WinError()
 
-    except ImportError:
+    except (ImportError, NotImplementedError):
         # nothing available, define a dummy function
         def setNoInherit(sock):
             """Mark the given socket fd as non-inheritable to child processes (dummy)"""
ipysockfix.patch.sig (application/octet-stream, 287 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.