Issue2279
Created on 2015-03-04.03:13:09 by zyasoft, last changed 2016-01-14.02:53:52 by zyasoft.
msg9582 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-03-04.03:13:08 |
|
Missing currently in https://github.com/jythontools/jython/blob/master/src/org/python/core/PyIterator.java#L70 - we have coercion to Iterator, Iterable, and Collection, but not to a Java array
|
msg9583 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-03-04.03:23:05 |
|
We likely should consider other iterable classes, such as PySequence, BaseSet, etc.
|
msg10507 (view) |
Author: Jim Baker (zyasoft) |
Date: 2015-11-24.16:29:01 |
|
Various examples:
$ dist/bin/jython
Jython 2.7.1b2 (default:f528d540f4b3, Nov 24 2015, 08:25:24)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_75
Type "help", "copyright", "credits" or "license" for more information.
>>> import java
>>> java.util.Arrays.asList(xrange(10))
[<org.python.core.JavaIterator object at 0x2>]
>>> java.util.Arrays.asList(list(xrange(10)))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Perhaps more important is support in varargs:
>>> java.lang.String.format("arg0=%d arg1=%d arg2=%d", 6, 7, 8)
u'arg0=6 arg1=7 arg2=8'
>>> java.lang.String.format("arg0=%d arg1=%d arg2=%d", [6, 7, 8])
u'arg0=6 arg1=7 arg2=8'
>>> java.lang.String.format("arg0=%d arg1=%d arg2=%d", xrange(3))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4045)
at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2748)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2702)
at java.util.Formatter.format(Formatter.java:2488)
at java.util.Formatter.format(Formatter.java:2423)
at java.lang.String.format(String.java:2790)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
java.util.IllegalFormatConversionException: java.util.IllegalFormatConversionException: d != org.python.core.JavaIterator
But of course if we take the list of the iterator, it works:
>>> java.lang.String.format("arg0=%d arg1=%d arg2=%d", list(xrange(3)))
u'arg0=0 arg1=1 arg2=2'
|
msg10598 (view) |
Author: Jim Baker (zyasoft) |
Date: 2016-01-07.01:42:58 |
|
Fixed as of https://hg.python.org/jython/rev/1e7c082d089d
|
|
Date |
User |
Action |
Args |
2016-01-14 02:53:52 | zyasoft | set | status: pending -> closed |
2016-01-07 01:42:59 | zyasoft | set | status: open -> pending assignee: zyasoft resolution: fixed messages:
+ msg10598 milestone: Jython 2.7.1 |
2015-11-24 16:29:02 | zyasoft | set | messages:
+ msg10507 |
2015-03-04 03:23:05 | zyasoft | set | messages:
+ msg9583 |
2015-03-04 03:13:09 | zyasoft | create | |
|