Index: src/org/python/modules/cPickle.java =================================================================== --- src/org/python/modules/cPickle.java (revision 2942) +++ src/org/python/modules/cPickle.java (working copy) @@ -409,6 +409,8 @@ PyType.fromClass(PyMethod.class); private static PyType ClassType = PyType.fromClass(PyClass.class); + private static PyType TypeType = + PyType.fromClass(PyType.class); private static PyType DictionaryType = PyType.fromClass(PyDictionary.class); private static PyType StringMapType = @@ -1009,6 +1011,8 @@ save_inst((PyInstance)object); else if (type == ClassType) save_global(object); + else if (type == TypeType) + save_global(object); else if (type == FunctionType) save_global(object); else if (type == BuiltinFunctionType) @@ -1317,6 +1321,16 @@ } list.append(obj); } + + /** + * The undocumented attribute, fast, of the C version of + * cPickle is used in the test_cpickle.py. By not having it we + * fail the tests. + */ + + final public void setFast(PyObject ignore_value) { + } + } @@ -1634,8 +1648,19 @@ final private void load_int() { String line = file.readlineNoNl(); - // XXX: use strop instead? - push(new PyInteger(Integer.parseInt(line))); + PyObject value; + // The following could be abstracted into a common string + // -> int/long method. + 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); } @@ -1865,7 +1890,7 @@ final private void load_reduce() { PyObject arg_tup = pop(); PyObject callable = pop(); - if (!(callable instanceof PyClass)) { + if (!((callable instanceof PyClass) || (callable instanceof PyType))) { if (safe_constructors.__finditem__(callable) == null) { if (callable.__findattr__("__safe_for_unpickling__") == null)