Index: PyFile.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyFile.java,v retrieving revision 2.32 diff -u -r2.32 PyFile.java --- PyFile.java 7 Jun 2005 18:59:29 -0000 2.32 +++ PyFile.java 11 Jun 2005 19:27:25 -0000 @@ -1371,9 +1371,26 @@ public PyObject new_impl(boolean init,PyType subtype,PyObject[]args,String[]keywords) { PyFile newobj; if (for_type==subtype) { - newobj=new PyFile(); - if (init) - newobj.file_init(args,keywords); + newobj=null; + if (init) { + if (args.length == 0) { + newobj = new PyFile(); + newobj.file_init(args, keywords); + } else if ( args[0] instanceof PyString || + (args[0] instanceof PyJavaInstance && + ((PyJavaInstance)args[0]).javaProxy == String.class)) { + // // If first arg is a PyString or String, assume its being + // called as a builtin. + newobj = new PyFile(); + newobj.file_init(args,keywords); + } else { + // assume it's being called as a java class + PyJavaClass pjc = new PyJavaClass(PyFile.class); + newobj = (PyFile)pjc.__call__(args, keywords); + } + } else { + newobj = new PyFile(); + } } else { newobj=new PyFileDerived(subtype); }