[Twisted-Python] Twisted on Jython

Tobias Oberstein tobias.oberstein at tavendo.de
Fri Mar 8 06:10:51 MST 2013


it seems that a way to identify the actual OS on which Jython is running can be determined using

Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0
Type "help", "copyright", "credits" or "license" for more information.
>>> import java.lang.System
>>> java.lang.System.getProperty('os.name')
u'Windows 7'
>>>




Mit freundlichen Grüßen,

Tobias Oberstein
Geschäftsführer

+49(0)9131 940 3574
+49(0)176 23 752 055
tobias.oberstein at tavendo.de<mailto:tobias.oberstein at tavendo.de>
Skype: toberstein<skype:toberstein?call>
Twitter: @oberstet<https://twitter.com/oberstet>
Xing: Tobias Oberstein<https://www.xing.com/profile/Tobias_Oberstein>

[cid:image001.png at 01CE1C06.BD7E36F0]

Tavendo GmbH · Am Weihersbach 13 · 91074 Herzogenaurach · Deutschland
Office / Postanschrift : Waldstrasse 18 · 91054 Erlangen · Deutschland
+49(+)700 GO TAVENDO · +49(0)700 46 828 36 36 · www.tavendo.de<http://www.tavendo.de/>
Amtsgericht Fürth · HRB 10365 · USt-Id.Nr DE246462916 · Geschäftsführer Tobias Oberstein

Von: twisted-python-bounces at twistedmatrix.com [mailto:twisted-python-bounces at twistedmatrix.com] Im Auftrag von Tobias Oberstein
Gesendet: Freitag, 8. März 2013 12:18
An: Twisted general discussion (twisted-python at twistedmatrix.com)
Betreff: [Twisted-Python] Twisted on Jython

Hi,

we've been asked if Autobahn runs under Jython. Since there is an upcoming Jython version that supports 2.7 Python API, I thought I'd give it a try.

To my astonishment, I was able to get Autobahn working with minor efforts ...

Tested: Twisted 12.3 under Jython from sources (together with zope.interface 4.05 and setuptools from sources) after applying the following patches. Stock AutobahnPython 0.6 from source.

1) Missing __builtin__.buffer

The following is a workaround due to http://bugs.jython.org/issue1521

Include

# workaround for Jython, see: http://bugs.jython.org/issue1521
import __builtin__
if not hasattr(__builtin__, 'buffer'):
    def _buffer(object, offset = None, size = None):
       if offset is None:
          offset = 0
       if size is None:
          size = len(object)
       return object[offset:offset+size]
    __builtin__.buffer = _buffer

at the beginning of "twisted/python/compat.py".

2) Weird platform ident

Jython identifies itself as "Java" .. I was testing on Windows.

twisted/python/runtime.py

Line 36

    #'java': 'java',
    'java': 'win32',

This is necessary on Windows since otherwise Posix API is assumed.

Of course above is just a quick hack.

C:\Users\oberstet>jython
Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, os
>>> sys.platform
'java1.7.0'
>>> os.name
'java'

IMHO, os.name should return the real underlying OS on Jython, not "java" .. what do you think?

===

Where should those issue be adressed? Should Twisted include workarounds or should I lobby at Jython to "do the right" thing?

Cheers,
Tobias


Mit freundlichen Grüßen,

Tobias Oberstein
Geschäftsführer

+49(0)9131 940 3574
+49(0)176 23 752 055
tobias.oberstein at tavendo.de<mailto:tobias.oberstein at tavendo.de>
Skype: toberstein<skype:toberstein?call>
Twitter: @oberstet<https://twitter.com/oberstet>
Xing: Tobias Oberstein<https://www.xing.com/profile/Tobias_Oberstein>

[cid:image002.png at 01CE1C06.BD7E36F0]

Tavendo GmbH · Am Weihersbach 13 · 91074 Herzogenaurach · Deutschland
Office / Postanschrift : Waldstrasse 18 · 91054 Erlangen · Deutschland
+49(+)700 GO TAVENDO · +49(0)700 46 828 36 36 · www.tavendo.de<http://www.tavendo.de/>
Amtsgericht Fürth · HRB 10365 · USt-Id.Nr DE246462916 · Geschäftsführer Tobias Oberstein

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20130308/fe862392/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 12131 bytes
Desc: image001.png
URL: </pipermail/twisted-python/attachments/20130308/fe862392/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 12131 bytes
Desc: image002.png
URL: </pipermail/twisted-python/attachments/20130308/fe862392/attachment-0005.png>


More information about the Twisted-Python mailing list