You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(107) |
Dec
(67) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(76) |
Feb
(125) |
Mar
(72) |
Apr
(13) |
May
(18) |
Jun
(12) |
Jul
(129) |
Aug
(47) |
Sep
(1) |
Oct
(36) |
Nov
(128) |
Dec
(124) |
2002 |
Jan
(59) |
Feb
|
Mar
(14) |
Apr
(14) |
May
(72) |
Jun
(9) |
Jul
(3) |
Aug
(5) |
Sep
(18) |
Oct
(65) |
Nov
(28) |
Dec
(12) |
2003 |
Jan
(10) |
Feb
(2) |
Mar
(4) |
Apr
(33) |
May
(21) |
Jun
(9) |
Jul
(29) |
Aug
(34) |
Sep
(4) |
Oct
(8) |
Nov
(15) |
Dec
(4) |
2004 |
Jan
(26) |
Feb
(12) |
Mar
(11) |
Apr
(9) |
May
(7) |
Jun
|
Jul
(5) |
Aug
|
Sep
(3) |
Oct
(7) |
Nov
(1) |
Dec
(10) |
2005 |
Jan
(2) |
Feb
(72) |
Mar
(16) |
Apr
(39) |
May
(48) |
Jun
(97) |
Jul
(57) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(100) |
Dec
(24) |
2006 |
Jan
(15) |
Feb
(34) |
Mar
(33) |
Apr
(31) |
May
(79) |
Jun
(64) |
Jul
(41) |
Aug
(64) |
Sep
(31) |
Oct
(46) |
Nov
(55) |
Dec
(37) |
2007 |
Jan
(32) |
Feb
(61) |
Mar
(11) |
Apr
(58) |
May
(46) |
Jun
(30) |
Jul
(94) |
Aug
(93) |
Sep
(86) |
Oct
(69) |
Nov
(125) |
Dec
(177) |
2008 |
Jan
(169) |
Feb
(97) |
Mar
(74) |
Apr
(113) |
May
(120) |
Jun
(334) |
Jul
(215) |
Aug
(237) |
Sep
(72) |
Oct
(189) |
Nov
(126) |
Dec
(160) |
2009 |
Jan
(180) |
Feb
(45) |
Mar
(98) |
Apr
(140) |
May
(151) |
Jun
(71) |
Jul
(107) |
Aug
(119) |
Sep
(73) |
Oct
(121) |
Nov
(14) |
Dec
(6) |
2010 |
Jan
(13) |
Feb
(9) |
Mar
(10) |
Apr
(64) |
May
(3) |
Jun
(16) |
Jul
(7) |
Aug
(23) |
Sep
(17) |
Oct
(37) |
Nov
(5) |
Dec
(8) |
2011 |
Jan
(10) |
Feb
(11) |
Mar
(77) |
Apr
(11) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <pj...@us...> - 2009-06-08 07:06:09
|
Revision: 6469 http://jython.svn.sourceforge.net/jython/?rev=6469&view=rev Author: pjenvey Date: 2009-06-08 07:06:07 +0000 (Mon, 08 Jun 2009) Log Message: ----------- rename to test_nt_paths_jy and add to skips Modified Paths: -------------- trunk/jython/Lib/test/regrtest.py Added Paths: ----------- trunk/jython/Lib/test/test_nt_paths_jy.py Removed Paths: ------------- trunk/jython/Lib/test/test_nt_paths.py Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2009-06-08 06:41:36 UTC (rev 6468) +++ trunk/jython/Lib/test/regrtest.py 2009-06-08 07:06:07 UTC (rev 6469) @@ -1538,6 +1538,8 @@ self.expected.update([ 'test_grp', 'test_mhlib', 'test_posix', 'test_pwd', 'test_signal']) + if os._name != 'nt': + self.expected.add('test_nt_paths_jy') self.valid = True Deleted: trunk/jython/Lib/test/test_nt_paths.py =================================================================== --- trunk/jython/Lib/test/test_nt_paths.py 2009-06-08 06:41:36 UTC (rev 6468) +++ trunk/jython/Lib/test/test_nt_paths.py 2009-06-08 07:06:07 UTC (rev 6469) @@ -1,40 +0,0 @@ -"""Test path handling on Windows - -Made for Jython. -""" -from __future__ import with_statement -import os -import unittest -from test import test_support - -class NTAbspathTestCase(unittest.TestCase): - - def setUp(self): - with open(test_support.TESTFN, 'w') as fp: - fp.write('foo') - - # Move to the same drive as TESTFN - drive, self.path = os.path.splitdrive(os.path.abspath( - test_support.TESTFN)) - self.orig_cwd = os.getcwd() - os.chdir(os.path.join(drive, os.sep)) - - def tearDown(self): - os.chdir(self.orig_cwd) - os.remove(test_support.TESTFN) - - def test_abspaths(self): - # Ensure r'\TESTFN' and '/TESTFN' are handled as absolute - for path in self.path, self.path.replace('\\', '/'): - with open(path) as fp: - self.assertEqual(fp.read(), 'foo') - - -def test_main(): - if (os._name if test_support.is_jython else os.name) != 'nt': - raise test_support.TestSkipped('NT specific test') - test_support.run_unittest(NTAbspathTestCase) - - -if __name__ == '__main__': - test_main() Copied: trunk/jython/Lib/test/test_nt_paths_jy.py (from rev 6468, trunk/jython/Lib/test/test_nt_paths.py) =================================================================== --- trunk/jython/Lib/test/test_nt_paths_jy.py (rev 0) +++ trunk/jython/Lib/test/test_nt_paths_jy.py 2009-06-08 07:06:07 UTC (rev 6469) @@ -0,0 +1,40 @@ +"""Test path handling on Windows + +Made for Jython. +""" +from __future__ import with_statement +import os +import unittest +from test import test_support + +class NTAbspathTestCase(unittest.TestCase): + + def setUp(self): + with open(test_support.TESTFN, 'w') as fp: + fp.write('foo') + + # Move to the same drive as TESTFN + drive, self.path = os.path.splitdrive(os.path.abspath( + test_support.TESTFN)) + self.orig_cwd = os.getcwd() + os.chdir(os.path.join(drive, os.sep)) + + def tearDown(self): + os.chdir(self.orig_cwd) + os.remove(test_support.TESTFN) + + def test_abspaths(self): + # Ensure r'\TESTFN' and '/TESTFN' are handled as absolute + for path in self.path, self.path.replace('\\', '/'): + with open(path) as fp: + self.assertEqual(fp.read(), 'foo') + + +def test_main(): + if (os._name if test_support.is_jython else os.name) != 'nt': + raise test_support.TestSkipped('NT specific test') + test_support.run_unittest(NTAbspathTestCase) + + +if __name__ == '__main__': + test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-08 06:41:39
|
Revision: 6468 http://jython.svn.sourceforge.net/jython/?rev=6468&view=rev Author: pjenvey Date: 2009-06-08 06:41:36 +0000 (Mon, 08 Jun 2009) Log Message: ----------- also special case paths with a single leading '/' (e.g. '/Jython25') as absolute on Windows. add test case for this and leading r'\' (r6413) fixes #1372 Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/core/PySystemState.java Added Paths: ----------- trunk/jython/Lib/test/test_nt_paths.py Added: trunk/jython/Lib/test/test_nt_paths.py =================================================================== --- trunk/jython/Lib/test/test_nt_paths.py (rev 0) +++ trunk/jython/Lib/test/test_nt_paths.py 2009-06-08 06:41:36 UTC (rev 6468) @@ -0,0 +1,40 @@ +"""Test path handling on Windows + +Made for Jython. +""" +from __future__ import with_statement +import os +import unittest +from test import test_support + +class NTAbspathTestCase(unittest.TestCase): + + def setUp(self): + with open(test_support.TESTFN, 'w') as fp: + fp.write('foo') + + # Move to the same drive as TESTFN + drive, self.path = os.path.splitdrive(os.path.abspath( + test_support.TESTFN)) + self.orig_cwd = os.getcwd() + os.chdir(os.path.join(drive, os.sep)) + + def tearDown(self): + os.chdir(self.orig_cwd) + os.remove(test_support.TESTFN) + + def test_abspaths(self): + # Ensure r'\TESTFN' and '/TESTFN' are handled as absolute + for path in self.path, self.path.replace('\\', '/'): + with open(path) as fp: + self.assertEqual(fp.read(), 'foo') + + +def test_main(): + if (os._name if test_support.is_jython else os.name) != 'nt': + raise test_support.TestSkipped('NT specific test') + test_support.run_unittest(NTAbspathTestCase) + + +if __name__ == '__main__': + test_main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-06-08 00:30:12 UTC (rev 6467) +++ trunk/jython/NEWS 2009-06-08 06:41:36 UTC (rev 6468) @@ -11,6 +11,7 @@ - [ 1364 ] SimpleHTTPServer.py contains call to missing os.fstat - [ 1367 ] PIpes (popen2) do not flush their buffer - [ 1368 ] '\xe4'.decode('utf-8') does not raise UnicodeDecodeError but returns u'' + - [ 1372 ] No default drive in Windows file paths - Fix file's repr with Windows paths - Fix urllib and urllib2 path handling on Windows - Fix r'\Jython25' not considered an abspath on Windows Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-06-08 00:30:12 UTC (rev 6467) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-06-08 06:41:36 UTC (rev 6468) @@ -508,8 +508,10 @@ } File file = new File(path); - // Python considers r'\Jython25' an abspath on Windows, unlike java.io.File - if (!file.isAbsolute() && (!Platform.IS_WINDOWS || !path.startsWith("\\"))) { + // Python considers r'\Jython25' and '/Jython25' abspaths on Windows, unlike + // java.io.File + if (!file.isAbsolute() && (!Platform.IS_WINDOWS + || !(path.startsWith("\\") || path.startsWith("/")))) { if (sys == null) { sys = Py.getSystemState(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-08 00:54:16
|
Revision: 6467 http://jython.svn.sourceforge.net/jython/?rev=6467&view=rev Author: pjenvey Date: 2009-06-08 00:30:12 +0000 (Mon, 08 Jun 2009) Log Message: ----------- don't reference the APIVersion field directly so it's not hardcoded into the .class Modified Paths: -------------- trunk/jython/src/org/python/compiler/ClassFile.java trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/src/org/python/compiler/ClassFile.java =================================================================== --- trunk/jython/src/org/python/compiler/ClassFile.java 2009-06-07 23:36:06 UTC (rev 6466) +++ trunk/jython/src/org/python/compiler/ClassFile.java 2009-06-08 00:30:12 UTC (rev 6467) @@ -1,6 +1,6 @@ // Copyright (c) Corporation for National Research Initiatives - package org.python.compiler; + import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -15,6 +15,8 @@ import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; +import org.python.core.imp; + public class ClassFile { ClassWriter cw; @@ -53,8 +55,8 @@ this.mtime = mtime; cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); - methodVisitors = Collections.synchronizedList(new ArrayList()); - fieldVisitors = Collections.synchronizedList(new ArrayList()); + methodVisitors = Collections.synchronizedList(new ArrayList<MethodVisitor>()); + fieldVisitors = Collections.synchronizedList(new ArrayList<FieldVisitor>()); } public void setSource(String name) { @@ -96,7 +98,7 @@ throws IOException { for (int i=0; i<methodVisitors.size(); i++) { - MethodVisitor mv = (MethodVisitor)methodVisitors.get(i); + MethodVisitor mv = methodVisitors.get(i); mv.visitMaxs(0,0); mv.visitEnd(); } @@ -105,8 +107,9 @@ public void write(OutputStream stream) throws IOException { cw.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, this.name, null, this.superclass, interfaces); AnnotationVisitor av = cw.visitAnnotation("Lorg/python/compiler/APIVersion;", true); - //XXX: should imp.java really house this value or should imp.java point into org.python.compiler? - av.visit("value", new Integer(org.python.core.imp.APIVersion)); + // XXX: should imp.java really house this value or should imp.java point into + // org.python.compiler? + av.visit("value", new Integer(imp.getAPIVersion())); av.visitEnd(); av = cw.visitAnnotation("Lorg/python/compiler/MTime;", true); @@ -127,11 +130,4 @@ //debug(baos); baos.close(); } - - //XXX: this should go away when things stabilize. - private void debug(ByteArrayOutputStream baos) throws IOException { - FileOutputStream fos = new FileOutputStream("DEBUG.class"); - baos.writeTo(fos); - fos.close(); - } } Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-06-07 23:36:06 UTC (rev 6466) +++ trunk/jython/src/org/python/core/imp.java 2009-06-08 00:30:12 UTC (rev 6467) @@ -20,7 +20,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - public static final int APIVersion = 22; + private static final int APIVersion = 22; public static final int NO_MTIME = -1; @@ -990,4 +990,8 @@ modules.__setitem__(modName, ret); return ret; } + + public static int getAPIVersion() { + return APIVersion; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-07 23:36:25
|
Revision: 6466 http://jython.svn.sourceforge.net/jython/?rev=6466&view=rev Author: pjenvey Date: 2009-06-07 23:36:06 +0000 (Sun, 07 Jun 2009) Log Message: ----------- javadoc corrections Modified Paths: -------------- trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyException.java trunk/jython/src/org/python/core/PyFile.java trunk/jython/src/org/python/core/PyObject.java Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-06-07 23:13:56 UTC (rev 6465) +++ trunk/jython/src/org/python/core/Py.java 2009-06-07 23:36:06 UTC (rev 6466) @@ -866,7 +866,7 @@ * Initializes a default PythonInterpreter and runs the code from * {@link PyRunnable#getMain} as __main__ * - * Called by the code generated in {@link Module#addMain()} + * Called by the code generated in {@link org.python.compiler.Module#addMain()} */ public static void runMain(PyRunnable main, String[] args) throws Exception { runMain(new PyRunnableBootstrap(main), args); @@ -875,7 +875,7 @@ /** * Initializes a default PythonInterpreter and runs the code loaded from the * {@link CodeBootstrap} as __main__ Called by the code generated in - * {@link Module#addMain()} + * {@link org.python.compiler.Module#addMain()} */ public static void runMain(CodeBootstrap main, String[] args) throws Exception { @@ -1628,18 +1628,6 @@ boolean linenumbers, boolean printResults, CompilerFlags cflags) { return CompilerFacade.compile(node, name, filename, linenumbers, printResults, cflags); - /* - try { - ByteArrayOutputStream ostream = new ByteArrayOutputStream(); - Module.compile(node, ostream, name, filename, linenumbers, printResults, cflags); - - saveClassFile(name, ostream); - - return BytecodeLoader.makeCode(name, ostream.toByteArray(), filename); - } catch (Throwable t) { - throw ParserFacade.fixParseError(null, t, filename); - } - */ } public static PyCode compile_flags(mod node, String filename, @@ -1658,10 +1646,10 @@ } /** - * Compiles python source code coming from decoded Strings. + * Compiles python source code coming from String (raw bytes) data. * - * DO NOT use this for PyString input. Use - * {@link #compile_flags(byte[], String, String, CompilerFlags)} instead. + * If the String is properly decoded (from PyUnicode) the PyCF_SOURCE_IS_UTF8 flag + * should be specified. */ public static PyCode compile_flags(String data, String filename, CompileMode kind, CompilerFlags cflags) { Modified: trunk/jython/src/org/python/core/PyException.java =================================================================== --- trunk/jython/src/org/python/core/PyException.java 2009-06-07 23:13:56 UTC (rev 6465) +++ trunk/jython/src/org/python/core/PyException.java 2009-06-07 23:36:06 UTC (rev 6466) @@ -166,9 +166,9 @@ * Logic for the raise statement * * @param type the first arg to raise, a type or an instance - * @param value the second arg, the instance of the class or - * arguments to its constructor - * @param tb a traceback object + * @param value the second arg, the instance of the class or arguments to its + * constructor + * @param traceback a traceback object * @return a PyException wrapper */ public static PyException doRaise(PyObject type, PyObject value, PyObject traceback) { Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2009-06-07 23:13:56 UTC (rev 6465) +++ trunk/jython/src/org/python/core/PyFile.java 2009-06-07 23:36:06 UTC (rev 6466) @@ -103,8 +103,8 @@ * method <code>file</code> doesn't expose this functionality (<code>open</code> does * albeit deprecated) as it isn't available to regular Python code. To wrap an * InputStream in a file from Python, use - * {@link FileUtil#wrap(InputStream, int)} - * {@link FileUtil#wrap(InputStream)} + * {@link util.FileUtil#wrap(InputStream, int)} + * {@link util.FileUtil#wrap(InputStream)} */ public PyFile(InputStream istream, int bufsize) { this(istream, "<Java InputStream '" + istream + "' as file>", "r", bufsize, true); @@ -124,8 +124,8 @@ * method <code>file</code> doesn't expose this functionality (<code>open</code> does * albeit deprecated) as it isn't available to regular Python code. To wrap an * OutputStream in a file from Python, use - * {@link FileUtil#wrap(OutputStream, int)} - * {@link FileUtil#wrap(OutputStream)} + * {@link util.FileUtil#wrap(OutputStream, int)} + * {@link util.FileUtil#wrap(OutputStream)} */ public PyFile(OutputStream ostream, int bufsize) { this(ostream, "<Java OutputStream '" + ostream + "' as file>", "w", bufsize, true); Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2009-06-07 23:13:56 UTC (rev 6465) +++ trunk/jython/src/org/python/core/PyObject.java 2009-06-07 23:36:06 UTC (rev 6466) @@ -904,7 +904,7 @@ * @return the value corresponding to name * @exception Py.AttributeError if the name is not found. * - * @see #__findattr_ex__(PyString) + * @see #__findattr_ex__(String) **/ public final PyObject __getattr__(PyString name) { return __getattr__(name.internedString()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-07 23:14:09
|
Revision: 6465 http://jython.svn.sourceforge.net/jython/?rev=6465&view=rev Author: pjenvey Date: 2009-06-07 23:13:56 +0000 (Sun, 07 Jun 2009) Log Message: ----------- ensure the ZipFile is immediately closed when there's a problem reading it Modified Paths: -------------- trunk/jython/src/org/python/modules/zipimport/zipimporter.java Modified: trunk/jython/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-06-07 00:10:28 UTC (rev 6464) +++ trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-06-07 23:13:56 UTC (rev 6465) @@ -329,23 +329,9 @@ * Given a path to a Zip archive, build a dict, mapping file names * (local to the archive, using SEP as a separator) to toc entries. * - * A tocEntry is a tuple: - * - * (__file__, # value to use for __file__, available for all files - * compress, # compression kind; 0 for uncompressed - * data_size, # size of compressed data on disk - * file_size, # size of decompressed data - * file_offset, # offset of file header from start of archive (or -1 in Jython) - * time, # mod time of file (in dos format) - * date, # mod data of file (in dos format) - * crc, # crc checksum of the data - * ) - * - * Directories can be recognized by the trailing SEP in the name, - * data_size and file_offset are 0. - * * @param archive PyString path to the archive * @return a PyDictionary of tocEntrys + * @see #readZipFile(ZipFile, PyObject) */ private PyObject readDirectory(String archive) { File file = new File(sys.getPath(archive)); @@ -361,19 +347,53 @@ } PyObject files = new PyDictionary(); + try { + readZipFile(zipFile, files); + } finally { + try { + zipFile.close(); + } catch (IOException ioe) { + throw Py.IOError(ioe); + } + } + return files; + } + + /** + * Read ZipFile metadata into a dict of toc entries. + * + * A tocEntry is a tuple: + * + * (__file__, # value to use for __file__, available for all files + * compress, # compression kind; 0 for uncompressed + * data_size, # size of compressed data on disk + * file_size, # size of decompressed data + * file_offset, # offset of file header from start of archive (or -1 in Jython) + * time, # mod time of file (in dos format) + * date, # mod data of file (in dos format) + * crc, # crc checksum of the data + * ) + * + * Directories can be recognized by the trailing SEP in the name, data_size and + * file_offset are 0. + * + * @param zipFile ZipFile to read + * @param files a dict-like PyObject + */ + private void readZipFile(ZipFile zipFile, PyObject files) { for (Enumeration<? extends ZipEntry> zipEntries = zipFile.entries(); zipEntries.hasMoreElements();) { ZipEntry zipEntry = zipEntries.nextElement(); String name = zipEntry.getName().replace('/', File.separatorChar); PyObject __file__ = new PyString(archive + File.separator + name); - PyObject compress = new PyInteger(zipEntry.getMethod()); + PyObject compress = Py.newInteger(zipEntry.getMethod()); PyObject data_size = new PyLong(zipEntry.getCompressedSize()); PyObject file_size = new PyLong(zipEntry.getSize()); - // file_offset is a CPython optimization; it's used to - // seek directly to the file when reading it later. Jython - // doesn't do this nor is the offset available - PyObject file_offset = new PyInteger(-1); + // file_offset is a CPython optimization; it's used to seek directly to the + // file when reading it later. Jython doesn't do this nor is the offset + // available + PyObject file_offset = Py.newInteger(-1); PyObject time = new PyInteger(epochToDosTime(zipEntry.getTime())); PyObject date = new PyInteger(epochToDosDate(zipEntry.getTime())); PyObject crc = new PyLong(zipEntry.getCrc()); @@ -382,14 +402,6 @@ time, date, crc); files.__setitem__(new PyString(name), entry); } - - try { - zipFile.close(); - } catch (IOException ioe) { - throw Py.IOError(ioe); - } - - return files; } @Override @@ -397,13 +409,6 @@ return File.separator; } - /** - * Given a full module name, return the potential file path in the archive (without extension). - * - * @param prefix a String value - * @param name a String modulename value - * @return the file path String value - */ @Override protected String makeFilename(String fullname) { return prefix + getSubname(fullname).replace('.', File.separatorChar); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-07 00:11:08
|
Revision: 6464 http://jython.svn.sourceforge.net/jython/?rev=6464&view=rev Author: pjenvey Date: 2009-06-07 00:10:28 +0000 (Sun, 07 Jun 2009) Log Message: ----------- make cmdline2list private Modified Paths: -------------- trunk/jython/Lib/subprocess.py trunk/jython/Lib/test/test_subprocess_jy.py Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2009-06-06 21:41:26 UTC (rev 6463) +++ trunk/jython/Lib/subprocess.py 2009-06-07 00:10:28 UTC (rev 6464) @@ -547,11 +547,11 @@ # Parse command line arguments for Windows _win_oses = ['nt'] - _cmdline2list = None + _cmdline2listimpl = None _escape_args = None _shell_command = None - def cmdline2list(cmdline): + def _cmdline2list(cmdline): """Build an argv list from a Microsoft shell style cmdline str The reverse of list2cmdline that follows the same MS C runtime @@ -611,13 +611,13 @@ """Setup the shell command and the command line argument escape function depending on the underlying platform """ - global _cmdline2list, _escape_args, _shell_command + global _cmdline2listimpl, _escape_args, _shell_command if os._name in _win_oses: - _cmdline2list = cmdline2list + _cmdline2listimpl = _cmdline2list _escape_args = lambda args: [list2cmdline([arg]) for arg in args] else: - _cmdline2list = lambda args: [args] + _cmdline2listimpl = lambda args: [args] _escape_args = lambda args: args os_info = os._os_map.get(os._name) @@ -1226,7 +1226,7 @@ """Execute program (Java version)""" if isinstance(args, types.StringTypes): - args = _cmdline2list(args) + args = _cmdline2listimpl(args) else: args = list(args) # NOTE: CPython posix (execv) will str() any unicode Modified: trunk/jython/Lib/test/test_subprocess_jy.py =================================================================== --- trunk/jython/Lib/test/test_subprocess_jy.py 2009-06-06 21:41:26 UTC (rev 6463) +++ trunk/jython/Lib/test/test_subprocess_jy.py 2009-06-07 00:10:28 UTC (rev 6464) @@ -3,7 +3,7 @@ import os import sys from test import test_support -from subprocess import PIPE, Popen, cmdline2list +from subprocess import PIPE, Popen, _cmdline2list class EnvironmentInheritanceTest(unittest.TestCase): @@ -65,7 +65,7 @@ def test_cmdline2list(self): for cmdline, argv in self.cmdlines.iteritems(): - self.assertEqual(cmdline2list(cmdline), argv) + self.assertEqual(_cmdline2list(cmdline), argv) def test_main(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 21:42:26
|
Revision: 6463 http://jython.svn.sourceforge.net/jython/?rev=6463&view=rev Author: pjenvey Date: 2009-06-06 21:41:26 +0000 (Sat, 06 Jun 2009) Log Message: ----------- revert the standalone jar workaround for now, we'll revisit this post 2.5 Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java Modified: trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java =================================================================== --- trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java 2009-06-06 21:40:48 UTC (rev 6462) +++ trunk/installer/src/java/org/python/util/install/driver/NormalVerifier.java 2009-06-06 21:41:26 UTC (rev 6463) @@ -23,8 +23,7 @@ private static final String BAT_EXTENSION = ".bat"; - //TODO:Oti re-add an exclamation mark as soon subprocess/jython.bat can handle it - private static final String JYTHON_UP = "jython up and running"; + private static final String JYTHON_UP = "jython up and running!"; private static final String JYTHON = "jython"; @@ -270,23 +269,6 @@ b.append("print '"); b.append(JYTHON_UP); b.append("'\n"); - b.append("# test subprocess if present\n"); - b.append("try:\n"); - b.append(" import subprocess\n"); - b.append(" proceed=True\n"); - b.append("except:\n"); - b.append(" proceed=False\n"); - b.append("if proceed:\n"); - b.append(" print '"); - b.append(VERIFYING); - b.append(" subprocess"); - b.append("'\n"); - b.append(" exitCode = subprocess.call([sys.executable, '-c', 'print "); - b.append('"'); - b.append(JYTHON_UP); - b.append('"'); - b.append("'])\n"); - b.append(" assert exitCode==0\n"); return b.toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 21:41:50
|
Revision: 6462 http://jython.svn.sourceforge.net/jython/?rev=6462&view=rev Author: pjenvey Date: 2009-06-06 21:40:48 +0000 (Sat, 06 Jun 2009) Log Message: ----------- revert the standalone jar workaround for now, we'll revisit this post 2.5 Modified Paths: -------------- trunk/jython/Lib/subprocess.py trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2009-06-06 20:56:01 UTC (rev 6461) +++ trunk/jython/Lib/subprocess.py 2009-06-06 21:40:48 UTC (rev 6462) @@ -547,9 +547,7 @@ # Parse command line arguments for Windows _win_oses = ['nt'] - _JYTHON_JAR = 'jython.jar' _cmdline2list = None - _forcecmdline2list = None _escape_args = None _shell_command = None @@ -613,19 +611,13 @@ """Setup the shell command and the command line argument escape function depending on the underlying platform """ - global _cmdline2list, _forcecmdline2list, _escape_args, _shell_command + global _cmdline2list, _escape_args, _shell_command if os._name in _win_oses: - _cmdline2list = _forcecmdline2list = cmdline2list + _cmdline2list = cmdline2list _escape_args = lambda args: [list2cmdline([arg]) for arg in args] else: - _cmdline2list = lambda arg: [arg] - def _forcecmdline2list(arg): - import shlex - try: - return shlex.split(arg) - except ValueError: - return [arg] + _cmdline2list = lambda args: [args] _escape_args = lambda args: args os_info = os._os_map.get(os._name) @@ -1225,28 +1217,6 @@ builder_env.putAll(merge_env) - def _should_run_jar(self, args): - """Determine if command should be run via jar -jar. - - When running the standalone Jython jar without the official - command line script runner (e.g. java -jar jython.jar) - sys.executable cannot be determined, so Jython sets it to - the path to jython.jar. - - This detects when a subprocess command executable is that - special sys.executable value. - """ - if not sys.executable or not sys.executable.endswith(_JYTHON_JAR): - # Not applicable - return False - - args = (_forcecmdline2list(args) - if isinstance(args, types.StringTypes) else list(args)) - if not args: - return False - return args[0] == sys.executable - - def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, @@ -1255,10 +1225,7 @@ errread, errwrite): """Execute program (Java version)""" - run_jar = self._should_run_jar(args) if isinstance(args, types.StringTypes): - if run_jar: - args = 'java -jar ' + args args = _cmdline2list(args) else: args = list(args) @@ -1267,8 +1234,6 @@ # posix. Windows passes unicode through, however if any(not isinstance(arg, (str, unicode)) for arg in args): raise TypeError('args must contain only strings') - if run_jar: - args = ['java', '-jar'] + args args = _escape_args(args) if shell: Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-06-06 20:56:01 UTC (rev 6461) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-06-06 21:40:48 UTC (rev 6462) @@ -858,7 +858,7 @@ // Initialize the path (and add system defaults) defaultPath = initPath(registry, standalone, jarFileName); defaultArgv = initArgv(argv); - defaultExecutable = initExecutable(registry, jarFileName); + defaultExecutable = initExecutable(registry); // Set up the known Java packages initPackages(registry); // Finish up standard Python initialization... @@ -961,23 +961,16 @@ } /** - * Determine the default sys.executable value from the registry. Returns Py.None is no - * executable can be found. - * - * @param props - * a Properties registry - * @param jarFileName - * used as executable if python.executable not otherwise specified + * Determine the default sys.executable value from the + * registry. Returns Py.None is no executable can be found. + * + * @param props a Properties registry * @return a PyObject path string or Py.None */ - private static PyObject initExecutable(Properties props, String jarFileName) { + private static PyObject initExecutable(Properties props) { String executable = props.getProperty("python.executable"); if (executable == null) { - if (jarFileName != null) { - executable = jarFileName; - } else { - return Py.None; - } + return Py.None; } File executableFile = new File(executable); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 20:57:02
|
Revision: 6461 http://jython.svn.sourceforge.net/jython/?rev=6461&view=rev Author: pjenvey Date: 2009-06-06 20:56:01 +0000 (Sat, 06 Jun 2009) Log Message: ----------- updates Modified Paths: -------------- trunk/jython/NEWS Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-06-06 20:50:29 UTC (rev 6460) +++ trunk/jython/NEWS 2009-06-06 20:56:01 UTC (rev 6461) @@ -9,10 +9,16 @@ - [ 1363 ] Deep inheritance from a Java class causes MRO problems - [ 1333 ] attribute wrongly deemed 'write-only' if setter comes from an interface - [ 1364 ] SimpleHTTPServer.py contains call to missing os.fstat - Fix file's repr with Windows paths - Fix urllib and urllib2 path handling on Windows - Fix r'\Jython25' not considered an abspath on Windows - Fix handling of raw unicode escapes + - [ 1367 ] PIpes (popen2) do not flush their buffer + - [ 1368 ] '\xe4'.decode('utf-8') does not raise UnicodeDecodeError but returns u'' + - Fix file's repr with Windows paths + - Fix urllib and urllib2 path handling on Windows + - Fix r'\Jython25' not considered an abspath on Windows + - Fix handling of raw unicode escapes + - Fix mishandling of the bytecode's tagged mtime in zipimport and when + recompiling due to stale bytecode + - Fixed minor short term memory leaks in functions on some lists allocated + inline Jython 2.5.0 rc3 Bugs fixed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 20:51:41
|
Revision: 6460 http://jython.svn.sourceforge.net/jython/?rev=6460&view=rev Author: pjenvey Date: 2009-06-06 20:50:29 +0000 (Sat, 06 Jun 2009) Log Message: ----------- fix utf8/utf16 decoders stateful mode argument being switched around fixes #1368 Modified Paths: -------------- trunk/jython/Lib/test/test_unicode_jy.py trunk/jython/src/org/python/modules/_codecs.java Modified: trunk/jython/Lib/test/test_unicode_jy.py =================================================================== --- trunk/jython/Lib/test/test_unicode_jy.py 2009-06-06 13:07:39 UTC (rev 6459) +++ trunk/jython/Lib/test/test_unicode_jy.py 2009-06-06 20:50:29 UTC (rev 6460) @@ -82,6 +82,11 @@ self.assertEqual(float(u'\u0663.\u0661'), 3.1) self.assertEqual(complex(u'\u0663.\u0661'), 3.1+0j) + def test_unstateful_end_of_data(self): + # http://bugs.jython.org/issue1368 + for encoding in 'utf-8', 'utf-16', 'utf-16-be', 'utf-16-le': + self.assertRaises(UnicodeDecodeError, '\xe4'.decode, encoding) + def test_formatchar(self): self.assertEqual('%c' % 255, '\xff') self.assertRaises(OverflowError, '%c'.__mod__, 256) Modified: trunk/jython/src/org/python/modules/_codecs.java =================================================================== --- trunk/jython/src/org/python/modules/_codecs.java 2009-06-06 13:07:39 UTC (rev 6459) +++ trunk/jython/src/org/python/modules/_codecs.java 2009-06-06 20:50:29 UTC (rev 6460) @@ -67,9 +67,9 @@ } public static PyTuple utf_8_decode(String str, String errors, boolean final_) { - int[] consumed = final_ ? new int[1] : null; + int[] consumed = final_ ? null : new int[1]; return decode_tuple(codecs.PyUnicode_DecodeUTF8Stateful(str, errors, consumed), - final_ ? consumed[0] : str.length()); + final_ ? str.length() : consumed[0]); } public static PyTuple utf_8_encode(String str) { @@ -431,9 +431,9 @@ public static PyTuple utf_16_decode(String str, String errors, boolean final_) { int[] bo = new int[] { 0 }; - int[] consumed = final_ ? new int[1] : null; + int[] consumed = final_ ? null : new int[1]; return decode_tuple(decode_UTF16(str, errors, bo, consumed), - final_ ? consumed[0] : str.length()); + final_ ? str.length() : consumed[0]); } public static PyTuple utf_16_le_decode(String str) { @@ -446,9 +446,9 @@ public static PyTuple utf_16_le_decode(String str, String errors, boolean final_) { int[] bo = new int[] { -1 }; - int[] consumed = final_ ? new int[1] : null; + int[] consumed = final_ ? null : new int[1]; return decode_tuple(decode_UTF16(str, errors, bo, consumed), - final_ ? consumed[0] : str.length()); + final_ ? str.length() : consumed[0]); } public static PyTuple utf_16_be_decode(String str) { @@ -461,9 +461,9 @@ public static PyTuple utf_16_be_decode(String str, String errors, boolean final_) { int[] bo = new int[] { 1 }; - int[] consumed = final_ ? new int[1] : null; + int[] consumed = final_ ? null : new int[1]; return decode_tuple(decode_UTF16(str, errors, bo, consumed), - final_ ? consumed[0] : str.length()); + final_ ? str.length() : consumed[0]); } public static PyTuple utf_16_ex_decode(String str) { @@ -481,10 +481,10 @@ public static PyTuple utf_16_ex_decode(String str, String errors, int byteorder, boolean final_) { int[] bo = new int[] { 0 }; - int[] consumed = final_ ? new int[1] : null; + int[] consumed = final_ ? null : new int[1]; String decoded = decode_UTF16(str, errors, bo, consumed); return new PyTuple(Py.newString(decoded), - Py.newInteger(final_ ? consumed[0] : str.length()), + Py.newInteger(final_ ? str.length() : consumed[0]), Py.newInteger(bo[0])); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2009-06-06 13:07:41
|
Revision: 6459 http://jython.svn.sourceforge.net/jython/?rev=6459&view=rev Author: zyasoft Date: 2009-06-06 13:07:39 +0000 (Sat, 06 Jun 2009) Log Message: ----------- Now nulls out arrays allocated by CodeCompiler#makeArray where it will be not be potentially kept (__call__ is the one case where this is not definitively known at the callsite, in certain corner cases). This allows for more immediate GC and fixes weakref issues seen in the commit for r6450. Bumped bytecode magic. Modified Paths: -------------- trunk/jython/Lib/test/test_weakref.py trunk/jython/src/org/python/compiler/CodeCompiler.java trunk/jython/src/org/python/core/imp.java Modified: trunk/jython/Lib/test/test_weakref.py =================================================================== --- trunk/jython/Lib/test/test_weakref.py 2009-06-06 07:20:33 UTC (rev 6458) +++ trunk/jython/Lib/test/test_weakref.py 2009-06-06 13:07:39 UTC (rev 6459) @@ -337,19 +337,8 @@ ref2 = weakref.ref(o, self.callback) del ref2 extra_collect() - if test_support.is_jython: - # XXX: Jython bug: the compiler creates a hard reference to - # the following inline declared [ref1] during - # 'weakref.getweakrefs(o) == [ref1]'. See - # CodeCompiler.makeArray for more info - ref1_list = [ref1] - self.assert_(weakref.getweakrefs(o) == ref1_list, - #self.assert_(weakref.getweakrefs(o) == [ref1], - "list of refs does not match") - del ref1_list - else: - self.assert_(weakref.getweakrefs(o) == [ref1], - "list of refs does not match") + self.assert_(weakref.getweakrefs(o) == [ref1], + "list of refs does not match") del ref1 extra_collect() Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-06-06 07:20:33 UTC (rev 6458) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-06-06 13:07:39 UTC (rev 6459) @@ -356,6 +356,14 @@ return array; } + // nulls out an array of references + public void freeArray(int array) { + code.aload(array); + code.aconst_null(); + code.invokestatic("java/util/Arrays", "fill", "(" + $objArr + $obj + ")V"); + code.freeLocal(array); + } + public void getDocString(java.util.List<stmt> suite) throws Exception { if (suite.size() > 0 && suite.get(0) instanceof Expr && ((Expr) suite.get(0)).getInternalValue() instanceof Str) @@ -403,6 +411,8 @@ ScopeInfo scope = module.getScopeInfo(node); + // NOTE: this is attached to the constructed PyFunction, so it cannot be nulled out + // with freeArray, unlike other usages of makeArray here int defaults = makeArray(scope.ac.getDefaults()); code.new_("org/python/core/PyFunction"); @@ -429,7 +439,6 @@ applyDecorators(node.getInternalDecorator_list()); set(new Name(node,node.getInternalName(), expr_contextType.Store)); - //doDecorators(node,node.getInternalDecorator_list(), node.getInternalName()); return null; } @@ -1668,7 +1677,7 @@ code.aload(argArray); code.freeLocal(argArray); stackConsume(2); // target + ts - code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $threadState + $pyObjArr + ")" + $pyObj); + code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $threadState + $pyObjArr + ")" + $pyObj);// freeArray(argArray); break; } } @@ -1774,8 +1783,8 @@ code.new_("org/python/core/PyTuple"); code.dup(); code.aload(dims); - code.freeLocal(dims); code.invokespecial("org/python/core/PyTuple", "<init>", "(" + $pyObjArr + ")V"); + freeArray(dims); return null; } @@ -1852,8 +1861,8 @@ code.dup(); code.aload(content); - code.freeLocal(content); code.invokespecial("org/python/core/PyTuple", "<init>", "(" + $pyObjArr + ")V"); + freeArray(content); return null; } @@ -1867,8 +1876,8 @@ code.new_("org/python/core/PyList"); code.dup(); code.aload(content); - code.freeLocal(content); code.invokespecial("org/python/core/PyList", "<init>", "(" + $pyObjArr + ")V"); + freeArray(content); return null; } @@ -1926,8 +1935,8 @@ code.new_("org/python/core/PyDictionary"); code.dup(); code.aload(content); - code.freeLocal(content); code.invokespecial("org/python/core/PyDictionary", "<init>", "(" + $pyObjArr + ")V"); + freeArray(content); return null; } @@ -1974,7 +1983,6 @@ } else { code.invokespecial("org/python/core/PyFunction", "<init>", "(" + $pyObj + $pyObjArr + $pyCode + $pyObjArr + ")V"); } - return null; } @@ -2016,7 +2024,6 @@ code.ldc(name); code.aload(baseArray); - code.freeLocal(baseArray); ScopeInfo scope = module.getScopeInfo(node); @@ -2041,6 +2048,7 @@ //Assign this new class to the given name set(new Name(node,node.getInternalName(), expr_contextType.Store)); //doDecorators(node,node.getInternalDecorator_list(), node.getInternalName()); + freeArray(baseArray); return null; } @@ -2207,8 +2215,6 @@ int emptyArray = makeArray(new ArrayList<expr>()); code.aload(emptyArray); - code.freeLocal(emptyArray); - scope.setup_closure(); scope.dump(); @@ -2254,6 +2260,7 @@ loadThreadState(); code.swap(); code.invokevirtual("org/python/core/PyObject", "__call__", "(" + $threadState + $pyObj + ")" + $pyObj); + freeArray(emptyArray); return null; } Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-06-06 07:20:33 UTC (rev 6458) +++ trunk/jython/src/org/python/core/imp.java 2009-06-06 13:07:39 UTC (rev 6459) @@ -20,7 +20,7 @@ private static final String UNKNOWN_SOURCEFILE = "<unknown>"; - public static final int APIVersion = 21; + public static final int APIVersion = 22; public static final int NO_MTIME = -1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 07:20:34
|
Revision: 6458 http://jython.svn.sourceforge.net/jython/?rev=6458&view=rev Author: pjenvey Date: 2009-06-06 07:20:33 +0000 (Sat, 06 Jun 2009) Log Message: ----------- remove redundant null check, use Java style names Modified Paths: -------------- trunk/jython/src/org/python/core/util/importer.java Modified: trunk/jython/src/org/python/core/util/importer.java =================================================================== --- trunk/jython/src/org/python/core/util/importer.java 2009-06-06 07:06:19 UTC (rev 6457) +++ trunk/jython/src/org/python/core/util/importer.java 2009-06-06 07:20:33 UTC (rev 6458) @@ -100,7 +100,7 @@ // module code may (directly or indirectly) import itself PyModule mod = imp.addModule(fullname); mod.__dict__.__setitem__("__loader__", this); - if (moduleCodeData.ispackage) { + if (moduleCodeData.isPackage) { // add __path__ to the module *before* the code gets executed PyList pkgpath = new PyList(); pkgpath.add(makePackagePath(fullname)); @@ -187,17 +187,17 @@ continue; } - boolean ispackage = entry.type.contains(EntryType.IS_PACKAGE); - boolean isbytecode = entry.type.contains(EntryType.IS_BYTECODE); + boolean isPackage = entry.type.contains(EntryType.IS_PACKAGE); + boolean isBytecode = entry.type.contains(EntryType.IS_BYTECODE); long mtime = -1; - if (isbytecode) { + if (isBytecode) { mtime = getSourceMtime(searchPath); } Bundle bundle = makeBundle(searchPath, tocEntry); byte[] codeBytes; try { - if (isbytecode) { + if (isBytecode) { try { codeBytes = imp.readCode(fullname, bundle.inputStream, true, mtime); } catch (IOException ioe) { @@ -214,13 +214,8 @@ bundle.close(); } - if (codeBytes == null) { - // bad magic number or non-matching mtime in byte code, try next - continue; - } - PyCode code = BytecodeLoader.makeCode(fullname + "$py", codeBytes, fullSearchPath); - return new ModuleCodeData(code, ispackage, fullSearchPath); + return new ModuleCodeData(code, isPackage, fullSearchPath); } return null; } @@ -230,12 +225,12 @@ */ protected class ModuleCodeData { public PyCode code; - public boolean ispackage; + public boolean isPackage; public String path; - public ModuleCodeData(PyCode code, boolean ispackage, String path) { + public ModuleCodeData(PyCode code, boolean isPackage, String path) { this.code = code; - this.ispackage = ispackage; + this.isPackage = isPackage; this.path = path; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 07:06:32
|
Revision: 6457 http://jython.svn.sourceforge.net/jython/?rev=6457&view=rev Author: pjenvey Date: 2009-06-06 07:06:19 +0000 (Sat, 06 Jun 2009) Log Message: ----------- o fix recompiling due to stale byte code not tagging an mtime on the new code o change importer isAcceptableBytecode -> getSourceMtime to fix zipimporter to check mtime against the actual bytecode's tagged mtime Modified Paths: -------------- trunk/jython/src/org/python/core/ClasspathPyImporter.java trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/core/util/importer.java trunk/jython/src/org/python/modules/zipimport/zipimporter.java Modified: trunk/jython/src/org/python/core/ClasspathPyImporter.java =================================================================== --- trunk/jython/src/org/python/core/ClasspathPyImporter.java 2009-06-06 05:45:22 UTC (rev 6456) +++ trunk/jython/src/org/python/core/ClasspathPyImporter.java 2009-06-06 07:06:19 UTC (rev 6457) @@ -1,3 +1,4 @@ +/* Copyright (c) Jython Developers */ package org.python.core; import java.io.IOException; @@ -63,8 +64,9 @@ } @Override - protected boolean isAcceptableBytecode(String searchPath, String entry) { - return true; + protected long getSourceMtime(String path) { + // Can't determine this easily + return -1; } @Override Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-06-06 05:45:22 UTC (rev 6456) +++ trunk/jython/src/org/python/core/imp.java 2009-06-06 07:06:19 UTC (rev 6457) @@ -474,10 +474,12 @@ boolean pkg = false; try { - pkg = dir.isDirectory() && caseok(dir, name) && (sourceFile.isFile() - || compiledFile.isFile()); + pkg = dir.isDirectory() && caseok(dir, name) + && (sourceFile.isFile() || compiledFile.isFile()); } catch (SecurityException e) { + // ok } + if (!pkg) { Py.writeDebug(IMPORT_LOG, "trying source " + dir.getPath()); sourceName = name + ".py"; @@ -506,7 +508,7 @@ } } return createFromSource(modName, makeStream(sourceFile), displaySourceName, - compiledFile.getPath()); + compiledFile.getPath(), pyTime); } return createFromSource(modName, makeStream(sourceFile), displaySourceName, compiledFile.getPath(), pyTime); @@ -519,6 +521,7 @@ displayCompiledName); } } catch (SecurityException e) { + // ok } return null; } Modified: trunk/jython/src/org/python/core/util/importer.java =================================================================== --- trunk/jython/src/org/python/core/util/importer.java 2009-06-06 05:45:22 UTC (rev 6456) +++ trunk/jython/src/org/python/core/util/importer.java 2009-06-06 07:06:19 UTC (rev 6457) @@ -1,3 +1,4 @@ +/* Copyright (c) Jython Developers */ package org.python.core.util; import java.io.IOException; @@ -127,7 +128,14 @@ public abstract void close(); } - protected abstract boolean isAcceptableBytecode(String searchPath, T entry); + /** + * Given a path to a compiled file in the archive, return the modification time of the + * matching .py file. + * + * @param path to the compiled file + * @return long mtime of the .py, or -1 if no source is available + */ + protected abstract long getSourceMtime(String path); /** * Return module information for the module with the fully qualified name. @@ -181,9 +189,9 @@ boolean ispackage = entry.type.contains(EntryType.IS_PACKAGE); boolean isbytecode = entry.type.contains(EntryType.IS_BYTECODE); - - if (isbytecode && !isAcceptableBytecode(searchPath, tocEntry)) { - continue; + long mtime = -1; + if (isbytecode) { + mtime = getSourceMtime(searchPath); } Bundle bundle = makeBundle(searchPath, tocEntry); @@ -191,10 +199,14 @@ try { if (isbytecode) { try { - codeBytes = imp.readCode(fullname, bundle.inputStream, true); + codeBytes = imp.readCode(fullname, bundle.inputStream, true, mtime); } catch (IOException ioe) { throw Py.ImportError(ioe.getMessage() + "[path=" + fullSearchPath + "]"); } + if (codeBytes == null) { + // bad magic number or non-matching mtime in byte code, try next + continue; + } } else { codeBytes = imp.compileSource(fullname, bundle.inputStream, fullSearchPath); } Modified: trunk/jython/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-06-06 05:45:22 UTC (rev 6456) +++ trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-06-06 07:06:19 UTC (rev 6457) @@ -12,6 +12,7 @@ import org.python.core.ArgParser; import org.python.core.Py; import org.python.core.PyDictionary; +import org.python.core.PyException; import org.python.core.PyInteger; import org.python.core.PyLong; import org.python.core.PyObject; @@ -299,31 +300,27 @@ } } - /** - * Determine if the byte code at path with the specified toc entry has a modification time - * greater than its accompanying source code's. - * - * @param path a String path to the byte code - * @param tocEntry the byte code's PyObject toc entry - * @return boolean whether or not the byte code is older - */ @Override - protected boolean isAcceptableBytecode(String path, PyObject tocEntry) { + protected long getSourceMtime(String path) { String sourcePath = path.substring(0, path.length() - 9) + ".py"; PyObject sourceTocEntry = files.__finditem__(sourcePath); if (sourceTocEntry == null) { - return true;// If there is no source, assume the bytecode is ok + return -1; } + + int time; + int date; try { - long bytecodeTime = dosTimeToEpoch(tocEntry.__finditem__(5).asInt(0), - tocEntry.__finditem__(6).asInt(0)); - long sourceTime = dosTimeToEpoch(sourceTocEntry.__finditem__(5).asInt(0), - sourceTocEntry.__finditem__(6).asInt(0)); - return bytecodeTime < sourceTime; + time = sourceTocEntry.__finditem__(5).asInt(); + date = sourceTocEntry.__finditem__(6).asInt(); + } catch (PyException pye) { + if (!pye.match(Py.TypeError)) { + throw pye; + } + time = -1; + date = -1; } - catch (PyObject.ConversionException ce) { - return false; - } + return dosTimeToEpoch(time, date); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 05:45:24
|
Revision: 6456 http://jython.svn.sourceforge.net/jython/?rev=6456&view=rev Author: pjenvey Date: 2009-06-06 05:45:22 +0000 (Sat, 06 Jun 2009) Log Message: ----------- small cleanup Modified Paths: -------------- trunk/jython/src/org/python/modules/zipimport/zipimporter.java Modified: trunk/jython/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-06-06 05:24:44 UTC (rev 6455) +++ trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2009-06-06 05:45:22 UTC (rev 6456) @@ -97,6 +97,7 @@ break; } } catch (SecurityException se) { + // continue } // back up one path element @@ -127,10 +128,6 @@ return zipimporter_find_module(fullname, null); } - public PyObject find_module(String fullname, String path) { - return zipimporter_find_module(fullname, path); - } - /** * Find the module for the fully qualified name. * @@ -139,30 +136,30 @@ * @return a loader instance if this importer can load the module, None * otherwise */ + public PyObject find_module(String fullname, String path) { + return zipimporter_find_module(fullname, path); + } + @ExposedMethod(defaults = "null") final PyObject zipimporter_find_module(String fullname, String path) { return importer_find_module(fullname, path); } - public PyObject load_module(String fullname) { - return zipimporter_load_module(fullname); - } - /** * Load a module for the fully qualified name. * * @param fullname the fully qualified name of the module * @return a loaded PyModule */ + public PyObject load_module(String fullname) { + return zipimporter_load_module(fullname); + } + @ExposedMethod final PyObject zipimporter_load_module(String fullname) { return importer_load_module(fullname); } - public String get_data(String path) { - return zipimporter_get_data(path); - } - /** * Return the uncompressed data for the file at the specified path * as a String. @@ -170,6 +167,10 @@ * @param path a String path name within the archive * @return a String of data in binary mode (no CRLF) */ + public String get_data(String path) { + return zipimporter_get_data(path); + } + @ExposedMethod final String zipimporter_get_data(String path) { int len = archive.length(); @@ -186,20 +187,14 @@ byte[] data; try { data = FileUtil.readBytes(zipBundle.inputStream); - } - catch (IOException ioe) { + } catch (IOException ioe) { throw Py.IOError(ioe); - } - finally { + } finally { zipBundle.close(); } return StringUtil.fromBytes(data); } - public boolean is_package(String fullname) { - return zipimporter_is_package(fullname); - } - /** * Return a boolean signifying whether the module is a package or * not. @@ -207,25 +202,29 @@ * @param fullname the fully qualified name of the module * @return a boolean describing if the module is a package */ + public boolean is_package(String fullname) { + return zipimporter_is_package(fullname); + } + @ExposedMethod final boolean zipimporter_is_package(String fullname) { ModuleInfo moduleInfo = getModuleInfo(fullname); if (moduleInfo == ModuleInfo.NOT_FOUND) { - throw zipimport.ZipImportError("can't find module '" + fullname + "'"); + throw zipimport.ZipImportError(String.format("can't find module '%s'", fullname)); } return moduleInfo == ModuleInfo.PACKAGE; } - public PyObject get_code(String fullname) { - return zipimporter_get_code(fullname); - } - /** * Return the code object associated with the module. * * @param fullname the fully qualified name of the module * @return the module's PyCode object or None */ + public PyObject get_code(String fullname) { + return zipimporter_get_code(fullname); + } + @ExposedMethod final PyObject zipimporter_get_code(String fullname) { ModuleCodeData moduleCodeData = getModuleCode(fullname); @@ -235,10 +234,6 @@ return Py.None; } - public String get_source(String fullname) { - return zipimporter_get_source(fullname); - } - /** * Return the source code for the module as a string (using * newline characters for line endings) @@ -246,6 +241,10 @@ * @param fullname the fully qualified name of the module * @return a String of the module's source code or null */ + public String get_source(String fullname) { + return zipimporter_get_source(fullname); + } + @ExposedMethod final String zipimporter_get_source(String fullname) { ModuleInfo moduleInfo = getModuleInfo(fullname); @@ -254,14 +253,13 @@ return null; } if (moduleInfo == ModuleInfo.NOT_FOUND) { - throw zipimport.ZipImportError("can't find module '" + fullname + "'"); + throw zipimport.ZipImportError(String.format("can't find module '%s'", fullname)); } String path = makeFilename(fullname); if (moduleInfo == ModuleInfo.PACKAGE) { path += File.separator + "__init__.py"; - } - else { + } else { path += ".py"; } @@ -282,21 +280,20 @@ * @return a ZipBundle with an InputStream to the file's * uncompressed data */ + @Override public ZipBundle makeBundle(String datapath, PyObject entry) { datapath = datapath.replace(File.separatorChar, '/'); ZipFile zipArchive; try { zipArchive = new ZipFile(new File(sys.getPath(archive))); - } - catch (IOException ioe) { + } catch (IOException ioe) { throw zipimport.ZipImportError("zipimport: can not open file: " + archive); } ZipEntry dataEntry = zipArchive.getEntry(datapath); try { return new ZipBundle(zipArchive, zipArchive.getInputStream(dataEntry)); - } - catch (IOException ioe) { + } catch (IOException ioe) { Py.writeDebug("import", "zipimporter.getDataStream exception: " + ioe.toString()); throw zipimport.ZipImportError("zipimport: can not open file: " + archive); } @@ -306,12 +303,11 @@ * Determine if the byte code at path with the specified toc entry has a modification time * greater than its accompanying source code's. * - * @param path - * a String path to the byte code - * @param tocEntry - * the byte code's PyObject toc entry + * @param path a String path to the byte code + * @param tocEntry the byte code's PyObject toc entry * @return boolean whether or not the byte code is older */ + @Override protected boolean isAcceptableBytecode(String path, PyObject tocEntry) { String sourcePath = path.substring(0, path.length() - 9) + ".py"; PyObject sourceTocEntry = files.__finditem__(sourcePath); @@ -357,16 +353,15 @@ private PyObject readDirectory(String archive) { File file = new File(sys.getPath(archive)); if (!file.canRead()) { - throw zipimport.ZipImportError("can't open Zip file: '" + archive + "'"); + throw zipimport.ZipImportError(String.format("can't open Zip file: '%s'", archive)); } ZipFile zipFile; try { zipFile = new ZipFile(file); + } catch (IOException ioe) { + throw zipimport.ZipImportError(String.format("can't read Zip file: '%s'", archive)); } - catch (IOException ioe) { - throw zipimport.ZipImportError("can't read Zip file: '" + archive + "'"); - } PyObject files = new PyDictionary(); for (Enumeration<? extends ZipEntry> zipEntries = zipFile.entries(); @@ -393,14 +388,14 @@ try { zipFile.close(); - } - catch (IOException ioe) { + } catch (IOException ioe) { throw Py.IOError(ioe); } return files; } + @Override protected String getSeparator() { return File.separator; } @@ -408,12 +403,11 @@ /** * Given a full module name, return the potential file path in the archive (without extension). * - * @param prefix - * a String value - * @param name - * a String modulename value + * @param prefix a String value + * @param name a String modulename value * @return the file path String value */ + @Override protected String makeFilename(String fullname) { return prefix + getSubname(fullname).replace('.', File.separatorChar); } @@ -497,6 +491,7 @@ return d.getTime(); } + @Override public String toString() { return zipimporter_toString(); } @@ -528,11 +523,11 @@ * * Raises an IOError if a problem occurred. */ + @Override public void close() { try { zipFile.close(); - } - catch (IOException ioe) { + } catch (IOException ioe) { throw Py.IOError(ioe); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 05:25:02
|
Revision: 6455 http://jython.svn.sourceforge.net/jython/?rev=6455&view=rev Author: pjenvey Date: 2009-06-06 05:24:44 +0000 (Sat, 06 Jun 2009) Log Message: ----------- revert r6448 and part of r6449: don't emulate CPython 2.x flush for now as we're assuming py3k style in various places Modified Paths: -------------- trunk/jython/src/org/python/core/io/FileIO.java trunk/jython/src/org/python/core/io/StreamIO.java Modified: trunk/jython/src/org/python/core/io/FileIO.java =================================================================== --- trunk/jython/src/org/python/core/io/FileIO.java 2009-06-06 02:05:42 UTC (rev 6454) +++ trunk/jython/src/org/python/core/io/FileIO.java 2009-06-06 05:24:44 UTC (rev 6455) @@ -329,12 +329,6 @@ } /** {@inheritDoc} */ - public void flush() { - checkClosed(); - checkWritable(); - } - - /** {@inheritDoc} */ public void close() { if (closed()) { return; Modified: trunk/jython/src/org/python/core/io/StreamIO.java =================================================================== --- trunk/jython/src/org/python/core/io/StreamIO.java 2009-06-06 02:05:42 UTC (rev 6454) +++ trunk/jython/src/org/python/core/io/StreamIO.java 2009-06-06 05:24:44 UTC (rev 6455) @@ -135,8 +135,6 @@ /** {@inheritDoc} */ public void flush() { - checkClosed(); - checkWritable(); if (outputStream == null) { return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-06 02:05:55
|
Revision: 6454 http://jython.svn.sourceforge.net/jython/?rev=6454&view=rev Author: pjenvey Date: 2009-06-06 02:05:42 +0000 (Sat, 06 Jun 2009) Log Message: ----------- fix the jython.jar workaround when it contains spaces Modified Paths: -------------- trunk/jython/Lib/subprocess.py Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2009-06-06 01:09:38 UTC (rev 6453) +++ trunk/jython/Lib/subprocess.py 2009-06-06 02:05:42 UTC (rev 6454) @@ -547,7 +547,9 @@ # Parse command line arguments for Windows _win_oses = ['nt'] + _JYTHON_JAR = 'jython.jar' _cmdline2list = None + _forcecmdline2list = None _escape_args = None _shell_command = None @@ -611,13 +613,19 @@ """Setup the shell command and the command line argument escape function depending on the underlying platform """ - global _cmdline2list, _escape_args, _shell_command + global _cmdline2list, _forcecmdline2list, _escape_args, _shell_command if os._name in _win_oses: - _cmdline2list = cmdline2list + _cmdline2list = _forcecmdline2list = cmdline2list _escape_args = lambda args: [list2cmdline([arg]) for arg in args] else: - _cmdline2list = lambda args: [args] + _cmdline2list = lambda arg: [arg] + def _forcecmdline2list(arg): + import shlex + try: + return shlex.split(arg) + except ValueError: + return [arg] _escape_args = lambda args: args os_info = os._os_map.get(os._name) @@ -1217,6 +1225,28 @@ builder_env.putAll(merge_env) + def _should_run_jar(self, args): + """Determine if command should be run via jar -jar. + + When running the standalone Jython jar without the official + command line script runner (e.g. java -jar jython.jar) + sys.executable cannot be determined, so Jython sets it to + the path to jython.jar. + + This detects when a subprocess command executable is that + special sys.executable value. + """ + if not sys.executable or not sys.executable.endswith(_JYTHON_JAR): + # Not applicable + return False + + args = (_forcecmdline2list(args) + if isinstance(args, types.StringTypes) else list(args)) + if not args: + return False + return args[0] == sys.executable + + def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, @@ -1225,7 +1255,10 @@ errread, errwrite): """Execute program (Java version)""" + run_jar = self._should_run_jar(args) if isinstance(args, types.StringTypes): + if run_jar: + args = 'java -jar ' + args args = _cmdline2list(args) else: args = list(args) @@ -1234,23 +1267,15 @@ # posix. Windows passes unicode through, however if any(not isinstance(arg, (str, unicode)) for arg in args): raise TypeError('args must contain only strings') + if run_jar: + args = ['java', '-jar'] + args args = _escape_args(args) - if len(args) > 0 and self.isJarExecutable(args[0]) and executable is None: - args = self.prefixJarExecutable(args) - if shell: - if len(args) == 1: - splittedArgs = args[0].split(' ') - # TODO:Oti breaks if path to jython.jar contains spaces - if self.isJarExecutable(splittedArgs[0]): - args = self.prefixJarExecutable(args, single=True) args = _shell_command + args if executable is not None: args[0] = executable - if self.isJarExecutable(args[0]): - args = self.prefixJarExecutable(args) builder = java.lang.ProcessBuilder(args) # os.environ may be inherited for compatibility with CPython @@ -1279,19 +1304,7 @@ raise OSError(e.getMessage() or e) self._child_created = True - def isJarExecutable(self, argument): - """returns true if argument is a path to jython.jar""" - return 'jython.jar' == argument[-10:] - def prefixJarExecutable(self, args, single=False): - """prepend java -jar to args - if single is True, args list is assumed to consit of one single element only""" - if not single: - args = ['java', '-jar'] + args - else: - args[0] = 'java -jar ' + args[0] - return args - def poll(self, _deadstate=None): """Check if child process has terminated. Returns returncode attribute.""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2009-06-06 01:09:40
|
Revision: 6453 http://jython.svn.sourceforge.net/jython/?rev=6453&view=rev Author: zyasoft Date: 2009-06-06 01:09:38 +0000 (Sat, 06 Jun 2009) Log Message: ----------- Relaxed timeout for thread safety tests for architectures with somewhat slower execution. Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2009-06-05 15:50:54 UTC (rev 6452) +++ trunk/jython/Lib/test/test_list_jy.py 2009-06-06 01:09:38 UTC (rev 6453) @@ -60,8 +60,10 @@ t = threading.Thread(target=f) t.start() threads.append(t) + timeout = 10. # be especially generous for t in threads: - t.join(1.) + t.join(timeout) + timeout = 0. for t in threads: self.assertFalse(t.isAlive()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2009-06-05 15:51:03
|
Revision: 6452 http://jython.svn.sourceforge.net/jython/?rev=6452&view=rev Author: zyasoft Date: 2009-06-05 15:50:54 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Minor enhancement of thread safety test case Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2009-06-05 13:13:00 UTC (rev 6451) +++ trunk/jython/Lib/test/test_list_jy.py 2009-06-05 15:50:54 UTC (rev 6452) @@ -1,4 +1,5 @@ import unittest +import random import threading import time from test import test_support @@ -53,30 +54,54 @@ class ThreadSafetyTestCase(unittest.TestCase): - def setUp(self): - self.globalList = [] - self.threads = [] + def run_threads(self, f, num=10): + threads = [] + for i in xrange(num): + t = threading.Thread(target=f) + t.start() + threads.append(t) + for t in threads: + t.join(1.) + for t in threads: + self.assertFalse(t.isAlive()) def test_append_remove(self): # derived from Itamar Shtull-Trauring's test for issue 521701 + lst = [] def tester(): ct = threading.currentThread() for i in range(1000): - self.globalList.append(ct) + lst.append(ct) time.sleep(0.0001) - self.globalList.remove(ct) - for i in range(10): - t = threading.Thread(target=tester) - t.start() - self.threads.append(t) - - for t in self.threads: - t.join(1.) - for t in self.threads: - self.assertFalse(t.isAlive()) - self.assertEqual(self.globalList, []) + lst.remove(ct) + self.run_threads(tester) + self.assertEqual(lst, []) + def test_sort(self): + lst = [] + def tester(): + ct = threading.currentThread() + for i in range(1000): + lst.append(ct) + lst.sort() + lst.remove(ct) + time.sleep(0.0001) + self.run_threads(tester) + self.assertEqual(lst, []) + def test_count_reverse(self): + lst = [0,1,2,3,4,5,6,7,8,9,10,0] + def tester(): + ct = threading.currentThread() + for i in range(1000): + self.assertEqual(lst[0], 0) + if random.random() > 0.5: + time.sleep(0.0001) + lst.reverse() + self.assertEqual(lst.count(0), 2) + self.assert_(lst[1] in (1,10)) + self.run_threads(tester) + def test_main(): test_support.run_unittest(ListTestCase, ThreadSafetyTestCase) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2009-06-05 13:13:03
|
Revision: 6451 http://jython.svn.sourceforge.net/jython/?rev=6451&view=rev Author: zyasoft Date: 2009-06-05 13:13:00 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Added basic thread safety test case for #521701 Modified Paths: -------------- trunk/jython/Lib/test/test_list_jy.py Modified: trunk/jython/Lib/test/test_list_jy.py =================================================================== --- trunk/jython/Lib/test/test_list_jy.py 2009-06-05 04:39:58 UTC (rev 6450) +++ trunk/jython/Lib/test/test_list_jy.py 2009-06-05 13:13:00 UTC (rev 6451) @@ -1,5 +1,8 @@ import unittest +import threading +import time from test import test_support + if test_support.is_jython: from java.util import ArrayList from java.lang import String @@ -48,8 +51,34 @@ def test_tuple_equality(self): self.assertEqual([(1,), [1]].count([1]), 1) # http://bugs.jython.org/issue1317 +class ThreadSafetyTestCase(unittest.TestCase): + + def setUp(self): + self.globalList = [] + self.threads = [] + + def test_append_remove(self): + # derived from Itamar Shtull-Trauring's test for issue 521701 + def tester(): + ct = threading.currentThread() + for i in range(1000): + self.globalList.append(ct) + time.sleep(0.0001) + self.globalList.remove(ct) + for i in range(10): + t = threading.Thread(target=tester) + t.start() + self.threads.append(t) + + for t in self.threads: + t.join(1.) + for t in self.threads: + self.assertFalse(t.isAlive()) + self.assertEqual(self.globalList, []) + + def test_main(): - test_support.run_unittest(ListTestCase) + test_support.run_unittest(ListTestCase, ThreadSafetyTestCase) if __name__ == "__main__": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-05 04:40:11
|
Revision: 6450 http://jython.svn.sourceforge.net/jython/?rev=6450&view=rev Author: pjenvey Date: 2009-06-05 04:39:58 +0000 (Fri, 05 Jun 2009) Log Message: ----------- document the cause of test_getweakrefs: the compiler Modified Paths: -------------- trunk/jython/Lib/test/test_weakref.py trunk/jython/src/org/python/compiler/CodeCompiler.java Modified: trunk/jython/Lib/test/test_weakref.py =================================================================== --- trunk/jython/Lib/test/test_weakref.py 2009-06-04 07:29:23 UTC (rev 6449) +++ trunk/jython/Lib/test/test_weakref.py 2009-06-05 04:39:58 UTC (rev 6450) @@ -338,11 +338,10 @@ del ref2 extra_collect() if test_support.is_jython: - # XXX: Likely a Jython bug: the following inline declared - # [ref1] list isn't garbage collected no matter how many - # times we force gc.collect(), which prevents ref1 from - # being garbage collected after it's del'd below. So we - # explicitly delete our list + # XXX: Jython bug: the compiler creates a hard reference to + # the following inline declared [ref1] during + # 'weakref.getweakrefs(o) == [ref1]'. See + # CodeCompiler.makeArray for more info ref1_list = [ref1] self.assert_(weakref.getweakrefs(o) == ref1_list, #self.assert_(weakref.getweakrefs(o) == [ref1], Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-06-04 07:29:23 UTC (rev 6449) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2009-06-05 04:39:58 UTC (rev 6450) @@ -323,6 +323,11 @@ } public int makeArray(java.util.List<? extends PythonTree> nodes) throws Exception { + // XXX: This should produce an array on the stack (if possible) instead of a local + // the caller is responsible for freeing. All callers are incorrectly freeing the + // array reference -- they do call freeLocal, but without nullifying the reference + // in the local. This is causing short term memory leaks + // (e.g. test_weakref.test_getweakrefs) int n; if (nodes == null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-04 07:29:24
|
Revision: 6449 http://jython.svn.sourceforge.net/jython/?rev=6449&view=rev Author: pjenvey Date: 2009-06-04 07:29:23 +0000 (Thu, 04 Jun 2009) Log Message: ----------- enable flushing of StreamIOs' associated OutputStreams thanks Marcelo Taube refs #1367 Modified Paths: -------------- trunk/jython/src/org/python/core/io/StreamIO.java Modified: trunk/jython/src/org/python/core/io/StreamIO.java =================================================================== --- trunk/jython/src/org/python/core/io/StreamIO.java 2009-06-04 07:24:35 UTC (rev 6448) +++ trunk/jython/src/org/python/core/io/StreamIO.java 2009-06-04 07:29:23 UTC (rev 6449) @@ -17,7 +17,6 @@ import java.nio.channels.WritableByteChannel; import org.python.core.Py; -import org.python.core.imp; import org.python.core.util.FileUtil; /** @@ -135,6 +134,20 @@ } /** {@inheritDoc} */ + public void flush() { + checkClosed(); + checkWritable(); + if (outputStream == null) { + return; + } + try { + outputStream.flush(); + } catch (IOException ioe) { + throw Py.IOError(ioe); + } + } + + /** {@inheritDoc} */ public void close() { if (closed()) { return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-04 07:24:36
|
Revision: 6448 http://jython.svn.sourceforge.net/jython/?rev=6448&view=rev Author: pjenvey Date: 2009-06-04 07:24:35 +0000 (Thu, 04 Jun 2009) Log Message: ----------- emulate CPython flush on closed and unwritable files Modified Paths: -------------- trunk/jython/src/org/python/core/io/FileIO.java Modified: trunk/jython/src/org/python/core/io/FileIO.java =================================================================== --- trunk/jython/src/org/python/core/io/FileIO.java 2009-06-04 02:52:11 UTC (rev 6447) +++ trunk/jython/src/org/python/core/io/FileIO.java 2009-06-04 07:24:35 UTC (rev 6448) @@ -329,6 +329,12 @@ } /** {@inheritDoc} */ + public void flush() { + checkClosed(); + checkWritable(); + } + + /** {@inheritDoc} */ public void close() { if (closed()) { return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-04 02:52:17
|
Revision: 6447 http://jython.svn.sourceforge.net/jython/?rev=6447&view=rev Author: pjenvey Date: 2009-06-04 02:52:11 +0000 (Thu, 04 Jun 2009) Log Message: ----------- recent updates Modified Paths: -------------- trunk/jython/NEWS Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-06-04 02:50:50 UTC (rev 6446) +++ trunk/jython/NEWS 2009-06-04 02:52:11 UTC (rev 6447) @@ -1,11 +1,14 @@ Jython NEWS -Jython 2.5.0 +Jython 2.5.0 rc4 Bugs fixed - [ 1354 ] core language failures in interactive interpreter - [ 1358 ] Simple pogram fails to parse in Jython 2.5rc3, but parses OK with CPython - [ 1357 ] no sys.executable when script runner is a relative link - [ 1338 ] Comparing Java objects to each other fails when classes of values do not match + - [ 1363 ] Deep inheritance from a Java class causes MRO problems + - [ 1333 ] attribute wrongly deemed 'write-only' if setter comes from an interface + - [ 1364 ] SimpleHTTPServer.py contains call to missing os.fstat Fix file's repr with Windows paths Fix urllib and urllib2 path handling on Windows Fix r'\Jython25' not considered an abspath on Windows This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-04 02:50:55
|
Revision: 6446 http://jython.svn.sourceforge.net/jython/?rev=6446&view=rev Author: pjenvey Date: 2009-06-04 02:50:50 +0000 (Thu, 04 Jun 2009) Log Message: ----------- workaround lack of os.fstat Modified Paths: -------------- trunk/jython/Lib/SimpleHTTPServer.py trunk/jython/Lib/posixpath.py trunk/jython/Lib/tarfile.py trunk/jython/Lib/test/test_largefile.py Modified: trunk/jython/Lib/SimpleHTTPServer.py =================================================================== --- trunk/jython/Lib/SimpleHTTPServer.py 2009-06-04 02:38:34 UTC (rev 6445) +++ trunk/jython/Lib/SimpleHTTPServer.py 2009-06-04 02:50:50 UTC (rev 6446) @@ -91,7 +91,7 @@ return None self.send_response(200) self.send_header("Content-type", ctype) - fs = os.fstat(f.fileno()) + fs = os.fstat(f.fileno()) if hasattr(os, 'fstat') else os.stat(path) self.send_header("Content-Length", str(fs[6])) self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) self.end_headers() Modified: trunk/jython/Lib/posixpath.py =================================================================== --- trunk/jython/Lib/posixpath.py 2009-06-04 02:38:34 UTC (rev 6445) +++ trunk/jython/Lib/posixpath.py 2009-06-04 02:50:50 UTC (rev 6446) @@ -230,8 +230,8 @@ return samestat(s1, s2) -# XXX: Plain Jython lacks fstat and st_ino/st_dev -if os.name != 'java': +# XXX: Jython currently lacks fstat +if hasattr(os, 'fstat'): # Are two open files really referencing the same file? # (Not necessarily the same file descriptor!) @@ -244,6 +244,7 @@ __all__.append("sameopenfile") +# XXX: Pure Java stat lacks st_ino/st_dev if os._native_posix: # Are two stat buffers (obtained from stat, fstat or lstat) # describing the same file? Modified: trunk/jython/Lib/tarfile.py =================================================================== --- trunk/jython/Lib/tarfile.py 2009-06-04 02:38:34 UTC (rev 6445) +++ trunk/jython/Lib/tarfile.py 2009-06-04 02:50:50 UTC (rev 6446) @@ -1336,8 +1336,11 @@ statres = os.lstat(name) else: statres = os.stat(name) + elif hasattr(os, 'fstat'): + statres = os.fstat(fileobj.fileno()) else: - statres = os.fstat(fileobj.fileno()) + raise NotImplementedError('fileobj argument not supported on this ' + 'platform (no os.fstat)') linkname = "" stmd = statres.st_mode Modified: trunk/jython/Lib/test/test_largefile.py =================================================================== --- trunk/jython/Lib/test/test_largefile.py 2009-06-04 02:38:34 UTC (rev 6445) +++ trunk/jython/Lib/test/test_largefile.py 2009-06-04 02:50:50 UTC (rev 6446) @@ -75,7 +75,7 @@ f.seek(size) f.write('a') f.flush() - if not test_support.is_jython: + if hasattr(os, 'fstat'): if test_support.verbose: print 'check file size with os.fstat' expect(os.fstat(f.fileno())[stat.ST_SIZE], size+1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-04 02:38:39
|
Revision: 6445 http://jython.svn.sourceforge.net/jython/?rev=6445&view=rev Author: pjenvey Date: 2009-06-04 02:38:34 +0000 (Thu, 04 Jun 2009) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/SimpleHTTPServer.py@53148 Added Paths: ----------- trunk/jython/Lib/SimpleHTTPServer.py Added: trunk/jython/Lib/SimpleHTTPServer.py =================================================================== --- trunk/jython/Lib/SimpleHTTPServer.py (rev 0) +++ trunk/jython/Lib/SimpleHTTPServer.py 2009-06-04 02:38:34 UTC (rev 6445) @@ -0,0 +1,218 @@ +"""Simple HTTP Server. + +This module builds on BaseHTTPServer by implementing the standard GET +and HEAD requests in a fairly straightforward manner. + +""" + + +__version__ = "0.6" + +__all__ = ["SimpleHTTPRequestHandler"] + +import os +import posixpath +import BaseHTTPServer +import urllib +import urlparse +import cgi +import shutil +import mimetypes +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO + + +class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): + + """Simple HTTP request handler with GET and HEAD commands. + + This serves files from the current directory and any of its + subdirectories. The MIME type for files is determined by + calling the .guess_type() method. + + The GET and HEAD requests are identical except that the HEAD + request omits the actual contents of the file. + + """ + + server_version = "SimpleHTTP/" + __version__ + + def do_GET(self): + """Serve a GET request.""" + f = self.send_head() + if f: + self.copyfile(f, self.wfile) + f.close() + + def do_HEAD(self): + """Serve a HEAD request.""" + f = self.send_head() + if f: + f.close() + + def send_head(self): + """Common code for GET and HEAD commands. + + This sends the response code and MIME headers. + + Return value is either a file object (which has to be copied + to the outputfile by the caller unless the command was HEAD, + and must be closed by the caller under all circumstances), or + None, in which case the caller has nothing further to do. + + """ + path = self.translate_path(self.path) + f = None + if os.path.isdir(path): + if not self.path.endswith('/'): + # redirect browser - doing basically what apache does + self.send_response(301) + self.send_header("Location", self.path + "/") + self.end_headers() + return None + for index in "index.html", "index.htm": + index = os.path.join(path, index) + if os.path.exists(index): + path = index + break + else: + return self.list_directory(path) + ctype = self.guess_type(path) + if ctype.startswith('text/'): + mode = 'r' + else: + mode = 'rb' + try: + f = open(path, mode) + except IOError: + self.send_error(404, "File not found") + return None + self.send_response(200) + self.send_header("Content-type", ctype) + fs = os.fstat(f.fileno()) + self.send_header("Content-Length", str(fs[6])) + self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) + self.end_headers() + return f + + def list_directory(self, path): + """Helper to produce a directory listing (absent index.html). + + Return value is either a file object, or None (indicating an + error). In either case, the headers are sent, making the + interface the same as for send_head(). + + """ + try: + list = os.listdir(path) + except os.error: + self.send_error(404, "No permission to list directory") + return None + list.sort(key=lambda a: a.lower()) + f = StringIO() + displaypath = cgi.escape(urllib.unquote(self.path)) + f.write("<title>Directory listing for %s</title>\n" % displaypath) + f.write("<h2>Directory listing for %s</h2>\n" % displaypath) + f.write("<hr>\n<ul>\n") + for name in list: + fullname = os.path.join(path, name) + displayname = linkname = name + # Append / for directories or @ for symbolic links + if os.path.isdir(fullname): + displayname = name + "/" + linkname = name + "/" + if os.path.islink(fullname): + displayname = name + "@" + # Note: a link to a directory displays with @ and links with / + f.write('<li><a href="%s">%s</a>\n' + % (urllib.quote(linkname), cgi.escape(displayname))) + f.write("</ul>\n<hr>\n") + length = f.tell() + f.seek(0) + self.send_response(200) + self.send_header("Content-type", "text/html") + self.send_header("Content-Length", str(length)) + self.end_headers() + return f + + def translate_path(self, path): + """Translate a /-separated PATH to the local filename syntax. + + Components that mean special things to the local file system + (e.g. drive or directory names) are ignored. (XXX They should + probably be diagnosed.) + + """ + # abandon query parameters + path = urlparse.urlparse(path)[2] + path = posixpath.normpath(urllib.unquote(path)) + words = path.split('/') + words = filter(None, words) + path = os.getcwd() + for word in words: + drive, word = os.path.splitdrive(word) + head, word = os.path.split(word) + if word in (os.curdir, os.pardir): continue + path = os.path.join(path, word) + return path + + def copyfile(self, source, outputfile): + """Copy all data between two file objects. + + The SOURCE argument is a file object open for reading + (or anything with a read() method) and the DESTINATION + argument is a file object open for writing (or + anything with a write() method). + + The only reason for overriding this would be to change + the block size or perhaps to replace newlines by CRLF + -- note however that this the default server uses this + to copy binary data as well. + + """ + shutil.copyfileobj(source, outputfile) + + def guess_type(self, path): + """Guess the type of a file. + + Argument is a PATH (a filename). + + Return value is a string of the form type/subtype, + usable for a MIME Content-type header. + + The default implementation looks the file's extension + up in the table self.extensions_map, using application/octet-stream + as a default; however it would be permissible (if + slow) to look inside the data to make a better guess. + + """ + + base, ext = posixpath.splitext(path) + if ext in self.extensions_map: + return self.extensions_map[ext] + ext = ext.lower() + if ext in self.extensions_map: + return self.extensions_map[ext] + else: + return self.extensions_map[''] + + if not mimetypes.inited: + mimetypes.init() # try to read system mime.types + extensions_map = mimetypes.types_map.copy() + extensions_map.update({ + '': 'application/octet-stream', # Default + '.py': 'text/plain', + '.c': 'text/plain', + '.h': 'text/plain', + }) + + +def test(HandlerClass = SimpleHTTPRequestHandler, + ServerClass = BaseHTTPServer.HTTPServer): + BaseHTTPServer.test(HandlerClass, ServerClass) + + +if __name__ == '__main__': + test() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |