Skip to content

Commit 49308c7

Browse files
committed
Fixed JavaImportHelper#getFromListAsStrings, which was assuming that
the PyTuple it was iterating over would contain String, not PyString. Now allow both, just in case, since either should be applicable anyway.
1 parent c453e1b commit 49308c7

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/org/python/core/JavaImportHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ private static final List getFromListAsStrings(PyObject fromlist) {
120120
Iterator iterator = ((PyTuple) fromlist).iterator();
121121
while (iterator.hasNext()) {
122122
Object obj = iterator.next();
123+
if (obj instanceof PyString) {
124+
obj = ((PyString)obj).string;
125+
}
123126
if (obj instanceof String) {
124127
String fromName = (String) obj;
125128
if (!"*".equals(fromName)) {

src/org/python/core/PyList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected void setslice(int start, int stop, int step, PyObject value) {
142142
value = new PyList(value);
143143
setsliceIterator(start, stop, step, value.asIterable().iterator());
144144
} else {
145-
System.err.println("List");
145+
// System.err.println("List");
146146
List valueList = (List) value.__tojava__(List.class);
147147
if (valueList != null && valueList != Py.NoConversion) {
148148
setsliceList(start, stop, step, valueList);

src/org/python/core/packagecache/PackageManager.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,9 @@ protected PyList basicDoDir(PyJavaPackage jpkg, boolean instantiate,
8888

8989
if (!instantiate) {
9090
PyList ret = cls.keys();
91-
9291
PyList dictKeys = dict.keys();
9392

94-
for (int i = 0; i < dictKeys.__len__(); i++) {
95-
PyObject name = dictKeys.pyget(i);
93+
for (PyObject name : dictKeys.asIterable()) {
9694
if (!cls.has_key(name)) {
9795
if (exclpkgs && dict.get(name) instanceof PyJavaPackage)
9896
continue;
@@ -103,7 +101,6 @@ protected PyList basicDoDir(PyJavaPackage jpkg, boolean instantiate,
103101
return ret;
104102
}
105103

106-
107104
for (PyObject pyname : cls.keys().asIterable()) {
108105
if (!dict.has_key(pyname)) {
109106
String name = pyname.toString();
@@ -118,8 +115,7 @@ protected PyList basicDoDir(PyJavaPackage jpkg, boolean instantiate,
118115
* Helper merging list2 into list1. Returns list1.
119116
*/
120117
protected PyList merge(PyList list1, PyList list2) {
121-
for (int i = 0; i < list2.__len__(); i++) {
122-
PyObject name = list2.pyget(i);
118+
for (PyObject name : list2.asIterable()) {
123119
list1.append(name);
124120
}
125121

0 commit comments

Comments
 (0)