19 Jul 10:25
Possible Bugs in Jython 2.5a1 array
From: <boblusebob <at> aim.com>
Subject: Possible Bugs in Jython 2.5a1 array
Newsgroups: gmane.comp.lang.jython.devel
Date: 2008-07-19 08:29:43 GMT
Subject: Possible Bugs in Jython 2.5a1 array
Newsgroups: gmane.comp.lang.jython.devel
Date: 2008-07-19 08:29:43 GMT
Hi,
I have found what I think are two bugs in the Jython 2.5 Alpha code for arrays. The reason that I am writing here rather than making a bug report is that I am not positive they are bugs since arrays in Jython are a bit complicated (to me anyway).
The first question:
The following runnable short code snippet runs on both Jython and Python (I am running on Windows XP Pro) but gives slightly different results.
-----------------------------------------
import array
a = array.array("c", 'abc123')
print a
print a.tostring()
print
print repr(a.tostring())
for i in a:
print i,
print
-----------------------------------------------
In Python 2.5.2 it prints the following:
array('c', 'abc123') # this is where they are different
abc123
'abc123'
a b c 1 2 3
In Jython 2.5a1 it prints:
array('c',['a', 'b', 'c', '1', '2', '3']) # this is where they are different
abc123
'abc123'
a b c 1 2 3
Intuitively, the Jython result seems right, an array of char. But, my understanding of char in Python says that the Jython is wrong. I think a Python char is 1 or more characters, in other words a string. the Jython char array is actually several char arrays rather than one char array.
The other problem is unsigned char - using a 'B' as the type code. I receive the following error message in Jython when declaring an array with the 'B' type code ( 'b' - signed char - works ok):
Traceback (most recent call last):
File "C:\...\src\charArraysUnsigned.py", line 6, in <module>
a = array.array("B", 'abc123')
ValueError: typecode must be in [zcbhilfd]
The following very short code snippet should recreate the error in Jython:
---------------------------------
import array
a = array.array("B", 'abc123')
---------------------------------------
I'll open bug reports if someone will confirm that these are bugs and not something that needed to be done to get Java and Python working together.
Thanks,
Bob
I have found what I think are two bugs in the Jython 2.5 Alpha code for arrays. The reason that I am writing here rather than making a bug report is that I am not positive they are bugs since arrays in Jython are a bit complicated (to me anyway).
The first question:
The following runnable short code snippet runs on both Jython and Python (I am running on Windows XP Pro) but gives slightly different results.
-----------------------------------------
import array
a = array.array("c", 'abc123')
print a
print a.tostring()
print repr(a.tostring())
for i in a:
print i,
-----------------------------------------------
In Python 2.5.2 it prints the following:
array('c', 'abc123') # this is where they are different
abc123
'abc123'
a b c 1 2 3
In Jython 2.5a1 it prints:
array('c',['a', 'b', 'c', '1', '2', '3']) # this is where they are different
abc123
'abc123'
a b c 1 2 3
Intuitively, the Jython result seems right, an array of char. But, my understanding of char in Python says that the Jython is wrong. I think a Python char is 1 or more characters, in other words a string. the Jython char array is actually several char arrays rather than one char array.
The other problem is unsigned char - using a 'B' as the type code. I receive the following error message in Jython when declaring an array with the 'B' type code ( 'b' - signed char - works ok):
Traceback (most recent call last):
File "C:\...\src\charArraysUnsigned.py", line 6, in <module>
a = array.array("B", 'abc123')
ValueError: typecode must be in [zcbhilfd]
The following very short code snippet should recreate the error in Jython:
---------------------------------
import array
a = array.array("B", 'abc123')
---------------------------------------
I'll open bug reports if someone will confirm that these are bugs and not something that needed to be done to get Java and Python working together.
Thanks,
Bob
------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________ Jython-dev mailing list Jython-dev <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jython-dev
RSS Feed