Jython bugs or features?

Dinu Gherman gherman at europemail.com
Mon Feb 25 10:34:24 EST 2002


Hi,

I'm trying to get a little more familiar with Jython, but after having
just installed the 2.1 final release on OS X I find the following
rather surprising differences between Jython and CPython (2.1 and 2.2
respectively, but that doesn't matter here):

  1. cStringIO.StringIO.reset() is missing in Jython
  2. list() doesn't perform as expected in Jython

See sample sessions below... 

Are these bugs and if so: how many people are actually using Jython,
then, especially as books start to come out for it from O'Reilly and 
New Riders...?

Best regards,

Dinu





###
### list() in CPython
###

[localhost:~] dinu% python
Python 2.2 (#1, Feb 13 2002, 11:18:45) 
[GCC 2.95.2 19991024 (release)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> L = [1, 2, 3]
>>> L2 = list(L)
>>> L2
[1, 2, 3]
>>> L2.insert(0, 4)
>>> L2
[4, 1, 2, 3]
>>> L
[1, 2, 3]    ### as expected, same on CPython 2.1


###
### list() in Jython
###

[localhost:~] dinu% jython 
Jython 2.1 on java1.3.1 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> 
>>> L = [1, 2, 3]    
>>> L2 = list(L)
>>> L2
[1, 2, 3]
>>> L2.insert(0, 4)
>>> L2
[4, 1, 2, 3]
>>> L
[4, 1, 2, 3]    ### unexpected
>>> 
>>> 
>>> import copy 
>>> L = [1, 2, 3]
>>> L3 = copy.copy(L) # instead of list() (use only for this snippet)
>>> L3.insert(0, 4)
>>> L3
[4, 1, 2, 3]
>>> L
[1, 2, 3]    ### as expected


###
### cStringIO in CPython
###

[localhost:~] dinu% python
Python 2.2 (#1, Feb 13 2002, 11:18:45) 
[GCC 2.95.2 19991024 (release)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> from cStringIO import StringIO
>>> s = StringIO()
>>> s.reset()    # does also work on CPython 2.1


###
### cStringIO in Jython
###

[localhost:~] dinu% jython
Jython 2.1 on java1.3.1 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> 
>>> from cStringIO import StringIO
>>> s = StringIO()
>>> s.reset()
Traceback (innermost last):
  File "<console>", line 1, in ?
AttributeError: instance of 'org.python.modules.cStringIO.StringIO' has 
no attribute 'reset'



More information about the Python-list mailing list