--- Lib/test/test_bool.py (revision 3403) +++ Lib/test/test_bool.py Thu Aug 09 00:04:51 MSD 2007 @@ -341,11 +341,6 @@ check(Baz()) # Jython transition 2.3 -# pickle doesn't work on bool -# http://jython.org/bugs/1758317 -del BoolTest.test_picklevalues -del BoolTest.test_mixedpickle -del BoolTest.test_cpickle #operator missing is function # http://jython.org/bugs/1758315 del BoolTest.test_operator --- src/org/python/modules/cPickle.java (revision 3403) +++ src/org/python/modules/cPickle.java Thu Aug 09 00:24:14 MSD 2007 @@ -439,6 +439,8 @@ PyType.fromClass(PyTuple.class); private static PyType FileType = PyType.fromClass(PyFile.class); + private static PyType BoolType = + PyType.fromClass(PyBoolean.class); private static PyObject dict; @@ -1030,6 +1032,8 @@ save_global(object); else if (type == BuiltinFunctionType) save_global(object); + else if (type == BoolType) + save_bool(object); else return false; return true; @@ -1072,7 +1076,14 @@ } } + private void save_bool(PyObject object) { + int value = ((PyBoolean) object).getValue(); + file.write(INT); + file.write(value != 0 ? "01" : "00"); + file.write("\n"); + } + final private void save_long(PyObject object) { file.write(LONG); file.write(object.toString()); @@ -1654,15 +1665,23 @@ PyObject value; // The following could be abstracted into a common string // -> int/long method. + if (line.equals("01")) { + value = Py.newBoolean(true); + } + else if (line.equals("00")) { + value = Py.newBoolean(false); + } + else { - try { - value = Py.newInteger(Integer.parseInt(line)); - } catch(NumberFormatException e) { - try { - value = Py.newLong(line); - } catch(NumberFormatException e2) { - throw Py.ValueError("could not convert string to int"); - } - } + try { + value = Py.newInteger(Integer.parseInt(line)); + } catch(NumberFormatException e) { + try { + value = Py.newLong(line); + } catch(NumberFormatException e2) { + throw Py.ValueError("could not convert string to int"); + } + } + } push(value); }