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-04 02:22:35
|
Revision: 6444 http://jython.svn.sourceforge.net/jython/?rev=6444&view=rev Author: pjenvey Date: 2009-06-04 01:41:03 +0000 (Thu, 04 Jun 2009) Log Message: ----------- fix subclasses getter properties being disabled when it has a setter and the parent only has a setter thanks doublep fixes #1333 Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/src/org/python/core/PyJavaType.java Added Paths: ----------- trunk/jython/tests/java/org/python/tests/Child2.java Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-06-04 01:35:46 UTC (rev 6443) +++ trunk/jython/Lib/test/test_java_integration.py 2009-06-04 01:41:03 UTC (rev 6444) @@ -20,7 +20,7 @@ from javax.swing.tree import TreePath from org.python.core.util import FileUtil -from org.python.tests import BeanImplementation, Child, Listenable, CustomizableMapHolder +from org.python.tests import BeanImplementation, Child, Child2, Listenable, CustomizableMapHolder from org.python.tests.mro import (ConfusedOnGetitemAdd, FirstPredefinedGetitem, GetitemAdder) class InstantiationTest(unittest.TestCase): @@ -75,6 +75,13 @@ c.id = 16 self.assertEquals(16, c.id) + def test_inheriting_half_bean_issue1333(self): + # http://bugs.jython.org/issue1333 + c = Child2() + self.assertEquals("blah", c.value) + c.value = "bleh" + self.assertEquals("Child2 bleh", c.value) + def test_awt_hack(self): # We ignore several deprecated methods in java.awt.* in favor of bean properties that were # addded in Java 1.1. This tests that one of those bean properties is visible. Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2009-06-04 01:35:46 UTC (rev 6443) +++ trunk/jython/src/org/python/core/PyJavaType.java 2009-06-04 01:41:03 UTC (rev 6444) @@ -420,10 +420,11 @@ // up, it'll be rejected below if (prop.setMethod == null) { prop.setMethod = superProp.setMethod; - } else if (superProp.myType == prop.setMethod.getParameterTypes()[0]) { - // Otherwise, we must not have a get method. Only take a get method if the type - // on it agrees with the set method we already have. The bean on this type - // overrides a conflicting one o the parent + } else if (prop.getMethod == null + && superProp.myType == prop.setMethod.getParameterTypes()[0]) { + // Only take a get method if the type on it agrees with the set method + // we already have. The bean on this type overrides a conflicting one + // of the parent prop.getMethod = superProp.getMethod; prop.myType = superProp.myType; } Added: trunk/jython/tests/java/org/python/tests/Child2.java =================================================================== --- trunk/jython/tests/java/org/python/tests/Child2.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/Child2.java 2009-06-04 01:41:03 UTC (rev 6444) @@ -0,0 +1,13 @@ +package org.python.tests; + +public class Child2 extends Parent { + + public String getValue() { + return value; + } + + @Override + public void setValue(String value) { + this.value = "Child2 " + value; + } +} 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:22:31
|
Revision: 6442 http://jython.svn.sourceforge.net/jython/?rev=6442&view=rev Author: pjenvey Date: 2009-06-04 01:34:39 +0000 (Thu, 04 Jun 2009) Log Message: ----------- more gc.collect to hopefully satisfy the solaris buildbots Modified Paths: -------------- trunk/jython/Lib/test/test_scope.py Modified: trunk/jython/Lib/test/test_scope.py =================================================================== --- trunk/jython/Lib/test/test_scope.py 2009-06-03 23:55:10 UTC (rev 6441) +++ trunk/jython/Lib/test/test_scope.py 2009-06-04 01:34:39 UTC (rev 6442) @@ -437,9 +437,9 @@ if is_jython: from test_weakref import extra_collect - extra_collect() # A lot of garbage - extra_collect() + for i in range(3): + extra_collect() vereq(Foo.count, 0) print "17. class and global" 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:22:19
|
Revision: 6443 http://jython.svn.sourceforge.net/jython/?rev=6443&view=rev Author: pjenvey Date: 2009-06-04 01:35:46 +0000 (Thu, 04 Jun 2009) Log Message: ----------- unused import Modified Paths: -------------- trunk/jython/Lib/test/test_java_subclasses.py Modified: trunk/jython/Lib/test/test_java_subclasses.py =================================================================== --- trunk/jython/Lib/test/test_java_subclasses.py 2009-06-04 01:34:39 UTC (rev 6442) +++ trunk/jython/Lib/test/test_java_subclasses.py 2009-06-04 01:35:46 UTC (rev 6443) @@ -229,7 +229,6 @@ '''Checks for http://bugs.jython.org/issue1363. Inheriting several classes deep from a Java class caused inconsistent MROs.''' - from java.lang import Object class A(Object): pass class B(A): pass class C(B): pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-06-03 23:55:13
|
Revision: 6441 http://jython.svn.sourceforge.net/jython/?rev=6441&view=rev Author: fwierzbicki Date: 2009-06-03 23:55:10 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Forgot to add a test for http://bugs.jython.org/issue1354 Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2009-06-03 07:53:04 UTC (rev 6440) +++ trunk/jython/Lib/test/test_codeop.py 2009-06-03 23:55:10 UTC (rev 6441) @@ -149,6 +149,10 @@ ai("9+ \\","eval") #ai("lambda z: \\","eval") + #Did not work in Jython 2.5rc2 see first issue in + # http://bugs.jython.org/issue1354 + ai("if True:\n if True:\n if True: \n") + def test_invalid(self): ai = self.assertInvalid ai("a b") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-06-03 07:53:06
|
Revision: 6440 http://jython.svn.sourceforge.net/jython/?rev=6440&view=rev Author: cgroves Date: 2009-06-03 07:53:04 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Only add the proxy class for a PyJavaType to the mro once. Fixes issue1363 Modified Paths: -------------- trunk/jython/Lib/test/test_java_subclasses.py trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/Lib/test/test_java_subclasses.py =================================================================== --- trunk/jython/Lib/test/test_java_subclasses.py 2009-06-02 08:23:27 UTC (rev 6439) +++ trunk/jython/Lib/test/test_java_subclasses.py 2009-06-03 07:53:04 UTC (rev 6440) @@ -225,6 +225,17 @@ self.assertEquals(10, SecondSubclass().callGetValue()) + def test_deep_subclasses(self): + '''Checks for http://bugs.jython.org/issue1363. + + Inheriting several classes deep from a Java class caused inconsistent MROs.''' + from java.lang import Object + class A(Object): pass + class B(A): pass + class C(B): pass + class D(C): pass + d = D() + """ public abstract class Abstract { public Abstract() { Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-06-02 08:23:27 UTC (rev 6439) +++ trunk/jython/src/org/python/core/PyType.java 2009-06-03 07:53:04 UTC (rev 6440) @@ -869,6 +869,7 @@ } PyObject[] computeMro(MROMergeState[] toMerge, List<PyObject> mro) { + boolean addedProxy = false; scan : for (int i = 0; i < toMerge.length; i++) { if (toMerge[i].isMerged()) { continue scan; @@ -880,7 +881,7 @@ continue scan; } } - if (!(this instanceof PyJavaType) && candidate instanceof PyJavaType + if (!addedProxy && !(this instanceof PyJavaType) && candidate instanceof PyJavaType && candidate.javaProxy != null && PyProxy.class.isAssignableFrom(((Class<?>)candidate.javaProxy)) && candidate.javaProxy != javaProxy) { @@ -889,6 +890,7 @@ // This exposes the methods from the proxy generated for this class in addition to // those generated for the superclass while allowing methods from the superclass to // remain visible from the proxies. + addedProxy = true; mro.add(PyType.fromClass(((Class<?>)javaProxy))); } mro.add(candidate); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-06-02 08:23:29
|
Revision: 6439 http://jython.svn.sourceforge.net/jython/?rev=6439&view=rev Author: otmarhumbel Date: 2009-06-02 08:23:27 +0000 (Tue, 02 Jun 2009) Log Message: ----------- - restrict jar sys.executable to our own jython.jar - pass the following tests in the java -jar case: test_subprocess, test_subprocess_jy, test_popen, test_popen2 Modified Paths: -------------- trunk/jython/Lib/subprocess.py Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2009-06-02 08:23:00 UTC (rev 6438) +++ trunk/jython/Lib/subprocess.py 2009-06-02 08:23:27 UTC (rev 6439) @@ -1236,16 +1236,21 @@ raise TypeError('args must contain only strings') args = _escape_args(args) - if len(args) > 0 and '.jar' == args[0][-4:] and executable is None: - args = ['java', '-jar'] + 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 '.jar' == executable[-4:]: - args = ['java', '-jar'] + args + if self.isJarExecutable(args[0]): + args = self.prefixJarExecutable(args) builder = java.lang.ProcessBuilder(args) # os.environ may be inherited for compatibility with CPython @@ -1274,7 +1279,19 @@ 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: <otm...@us...> - 2009-06-02 08:23:01
|
Revision: 6438 http://jython.svn.sourceforge.net/jython/?rev=6438&view=rev Author: otmarhumbel Date: 2009-06-02 08:23:00 +0000 (Tue, 02 Jun 2009) Log Message: ----------- rollback to 6418, due to a regression in hudson all Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-06-01 04:46:45 UTC (rev 6437) +++ trunk/jython/Lib/test/test_java_integration.py 2009-06-02 08:23:00 UTC (rev 6438) @@ -411,9 +411,6 @@ # script must lie within python.home for this test to work return policy = test_support.findfile("python_home.policy") - if len(policy.split(' ')) > 1: - # quote the policy file if it contains spaces - policy = '"%s"' % policy self.assertEquals(subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true", "-J-Djava.security.manager", "-J-Djava.security.policy=%s" % policy, script]), 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-01 04:47:02
|
Revision: 6437 http://jython.svn.sourceforge.net/jython/?rev=6437&view=rev Author: pjenvey Date: 2009-06-01 04:46:45 +0000 (Mon, 01 Jun 2009) Log Message: ----------- blah, revert r6435 for now as it breaks running the tests on CPython, which is too useful Modified Paths: -------------- trunk/jython/Lib/test/test_array.py trunk/jython/Lib/test/test_class.py trunk/jython/Lib/test/test_deque.py trunk/jython/Lib/test/test_descr.py trunk/jython/Lib/test/test_file.py trunk/jython/Lib/test/test_functools.py trunk/jython/Lib/test/test_generators.py trunk/jython/Lib/test/test_iter.py trunk/jython/Lib/test/test_scope.py trunk/jython/Lib/test/test_set.py trunk/jython/Lib/test/test_support.py trunk/jython/Lib/test/test_weakref.py Modified: trunk/jython/Lib/test/test_array.py =================================================================== --- trunk/jython/Lib/test/test_array.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_array.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -11,6 +11,7 @@ if test_support.is_jython: import operator + from test_weakref import extra_collect class ArraySubclass(array.array): pass @@ -703,7 +704,8 @@ p = proxy(s) self.assertEqual(p.tostring(), s.tostring()) s = None - test_support.gc_collect() + if test_support.is_jython: + extra_collect() self.assertRaises(ReferenceError, len, p) def test_bug_782369(self): Modified: trunk/jython/Lib/test/test_class.py =================================================================== --- trunk/jython/Lib/test/test_class.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_class.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -1,6 +1,6 @@ "Test the functionality of Python classes implementing operators." -from test.test_support import TestFailed, gc_collect +from test.test_support import TestFailed testmeths = [ @@ -249,7 +249,9 @@ # This test has to be last (duh.) del testme -gc_collect() +if sys.platform[:4] == 'java': + from test_weakref import extra_collect + extra_collect() # Interfering tests Modified: trunk/jython/Lib/test/test_deque.py =================================================================== --- trunk/jython/Lib/test/test_deque.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_deque.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -475,7 +475,9 @@ p = proxy(d) self.assertEqual(str(p), str(d)) d = None - test_support.gc_collect() + if test_support.is_jython: + from test_weakref import extra_collect + extra_collect() self.assertRaises(ReferenceError, str, p) def test_strange_subclass(self): Modified: trunk/jython/Lib/test/test_descr.py =================================================================== --- trunk/jython/Lib/test/test_descr.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_descr.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -1,9 +1,14 @@ # Test enhancements related to descriptors and new-style classes -from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_original_stdout, gc_collect, is_jython +from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_original_stdout, is_jython from copy import deepcopy import warnings import types +if is_jython: + from test_weakref import extra_collect +else: + def extra_collect(): + pass warnings.filterwarnings("ignore", r'complex divmod\(\), // and % are deprecated$', @@ -1261,7 +1266,7 @@ x.c = Counted() vereq(Counted.counter, 3) del x - gc_collect() + extra_collect() vereq(Counted.counter, 0) class D(C): pass @@ -1270,7 +1275,7 @@ x.z = Counted() vereq(Counted.counter, 2) del x - gc_collect() + extra_collect() vereq(Counted.counter, 0) class E(D): __slots__ = ['e'] @@ -1280,7 +1285,7 @@ x.e = Counted() vereq(Counted.counter, 3) del x - gc_collect() + extra_collect() vereq(Counted.counter, 0) # Test cyclical leaks [SF bug 519621] @@ -1293,7 +1298,7 @@ s = None import gc gc.collect() - gc_collect() + extra_collect() vereq(Counted.counter, 0) # XXX: This tests a CPython GC reference count bug and Jython lacks @@ -1326,7 +1331,7 @@ h = H() try: del h - gc_collect() + extra_collect() finally: sys.stderr = save_stderr @@ -1977,7 +1982,7 @@ r = weakref.ref(c) verify(r() is c) del c - gc_collect() + extra_collect() verify(r() is None) del r class NoWeak(object): @@ -1997,7 +2002,7 @@ r = weakref.ref(yes) verify(r() is yes) del yes - gc_collect() + extra_collect() verify(r() is None) del r @@ -3327,7 +3332,7 @@ c = C() vereq(log, []) del c - gc_collect() + extra_collect() vereq(log, [1]) class D(object): pass Modified: trunk/jython/Lib/test/test_file.py =================================================================== --- trunk/jython/Lib/test/test_file.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_file.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -5,7 +5,7 @@ from array import array from weakref import proxy -from test.test_support import TESTFN, findfile, gc_collect, is_jython, run_unittest +from test.test_support import TESTFN, findfile, is_jython, run_unittest from UserList import UserList class AutoFileTests(unittest.TestCase): @@ -26,7 +26,9 @@ self.assertEquals(self.f.tell(), p.tell()) self.f.close() self.f = None - gc_collect() + if is_jython: + from test_weakref import extra_collect + extra_collect() self.assertRaises(ReferenceError, getattr, p, 'tell') def testAttributes(self): Modified: trunk/jython/Lib/test/test_functools.py =================================================================== --- trunk/jython/Lib/test/test_functools.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_functools.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -131,7 +131,9 @@ p = proxy(f) self.assertEqual(f.func, p.func) f = None - test_support.gc_collect() + if test_support.is_jython: + from test_weakref import extra_collect + extra_collect() self.assertRaises(ReferenceError, getattr, p, 'func') def test_with_bound_and_unbound_methods(self): Modified: trunk/jython/Lib/test/test_generators.py =================================================================== --- trunk/jython/Lib/test/test_generators.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_generators.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -1653,7 +1653,7 @@ >>> g = f() >>> g.next() ->>> del g; gc_collect() +>>> del g; extra_collect() exiting @@ -1678,7 +1678,7 @@ >>> old, sys.stderr = sys.stderr, StringIO.StringIO() >>> g = f() >>> g.next() ->>> del g; gc_collect() +>>> del g; extra_collect() >>> sys.stderr.getvalue().startswith( ... "Exception RuntimeError" ... ) @@ -1795,7 +1795,7 @@ ... raise RuntimeError ... ... l = Leaker() -... del l; gc_collect() +... del l; extra_collect() ... err = sys.stderr.getvalue().strip() ... err.startswith( ... "Exception RuntimeError in <" @@ -1834,8 +1834,13 @@ from test import test_support, test_generators test_support.run_doctest(test_generators, verbose) -from test.test_support import gc_collect +def extra_collect(): + import gc + from time import sleep + gc.collect(); sleep(1); gc.collect(); sleep(0.1); gc.collect() + + # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": test_main(1) Modified: trunk/jython/Lib/test/test_iter.py =================================================================== --- trunk/jython/Lib/test/test_iter.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_iter.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -1,7 +1,7 @@ # Test iterators. import unittest -from test.test_support import gc_collect, run_unittest, TESTFN, unlink, have_unicode +from test.test_support import run_unittest, TESTFN, unlink, have_unicode # Test result of triple loop (too big to inline) TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2), @@ -781,6 +781,7 @@ # Test reference count behavior # XXX: Jython new style objects don't support __del__ yet + from test_weakref import extra_collect #class C(object): class C: count = 0 @@ -796,7 +797,7 @@ x = C() self.assertEqual(C.count, 1) del x - gc_collect() + extra_collect() self.assertEqual(C.count, 0) l = [C(), C(), C()] self.assertEqual(C.count, 3) @@ -805,7 +806,7 @@ except ValueError: pass del l - gc_collect() + extra_collect() self.assertEqual(C.count, 0) Modified: trunk/jython/Lib/test/test_scope.py =================================================================== --- trunk/jython/Lib/test/test_scope.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_scope.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -1,4 +1,4 @@ -from test.test_support import verify, TestFailed, check_syntax, vereq, gc_collect +from test.test_support import verify, TestFailed, check_syntax, vereq, is_jython import warnings warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<string>") @@ -435,9 +435,11 @@ for i in range(100): f1() -gc_collect() -# A lot of garbage -gc_collect() +if is_jython: + from test_weakref import extra_collect + extra_collect() + # A lot of garbage + extra_collect() vereq(Foo.count, 0) print "17. class and global" Modified: trunk/jython/Lib/test/test_set.py =================================================================== --- trunk/jython/Lib/test/test_set.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_set.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -1,5 +1,6 @@ import unittest from test import test_support +from test_weakref import extra_collect from weakref import proxy import operator import copy @@ -483,7 +484,7 @@ p = proxy(s) self.assertEqual(str(p), str(s)) s = None - test_support.gc_collect() + extra_collect() self.assertRaises(ReferenceError, str, p) # C API test only available in a debug build Modified: trunk/jython/Lib/test/test_support.py =================================================================== --- trunk/jython/Lib/test/test_support.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_support.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -299,22 +299,6 @@ fn, _ = urllib.urlretrieve(url, filename) return open(fn) -def gc_collect(): - """Force as many objects as possible to be collected. - - In non-CPython implementations of Python, this is needed because timely - deallocation is not guaranteed by the garbage collector. (Even in CPython - this can be the case in case of reference cycles.) This means that __del__ - methods may be called later than expected and weakrefs may remain alive for - longer than expected. This function tries its best to force all garbage - objects to disappear. - """ - import gc - gc.collect() - time.sleep(0.1) - gc.collect() - gc.collect() - #======================================================================= # Decorator for running a function in a different locale, correctly resetting # it afterwards. Modified: trunk/jython/Lib/test/test_weakref.py =================================================================== --- trunk/jython/Lib/test/test_weakref.py 2009-06-01 04:37:42 UTC (rev 6436) +++ trunk/jython/Lib/test/test_weakref.py 2009-06-01 04:46:45 UTC (rev 6437) @@ -6,6 +6,19 @@ from test import test_support +if test_support.is_jython: + import time + + def extra_collect(): + """Kick Java's GC into gear""" + gc.collect() + time.sleep(0.1) + gc.collect() + gc.collect() +else: + def extra_collect(): + pass + # Used in ReferencesTestCase.test_ref_created_during_del() . ref_from_del = None @@ -69,7 +82,7 @@ ref1 = weakref.ref(o, self.callback) ref2 = weakref.ref(o, self.callback) del o - test_support.gc_collect() + extra_collect() self.assert_(ref1() is None, "expected reference to be invalidated") self.assert_(ref2() is None, @@ -105,7 +118,7 @@ def check(proxy): proxy.bar - test_support.gc_collect() + extra_collect() self.assertRaises(weakref.ReferenceError, check, ref1) self.assertRaises(weakref.ReferenceError, check, ref2) # XXX: CPython GC collects C() immediately. use ref1 instead on @@ -130,7 +143,7 @@ o = factory() ref = weakref.ref(o, self.callback) del o - test_support.gc_collect() + extra_collect() self.assert_(self.cbcalled == 1, "callback did not properly set 'cbcalled'") self.assert_(ref() is None, @@ -155,7 +168,7 @@ self.assert_(weakref.getweakrefcount(o) == 2, "wrong weak ref count for object") del proxy - test_support.gc_collect() + extra_collect() self.assert_(weakref.getweakrefcount(o) == 1, "wrong weak ref count for object after deleting proxy") @@ -301,7 +314,7 @@ "got wrong number of weak reference objects") del ref1, ref2, proxy1, proxy2 - test_support.gc_collect() + extra_collect() self.assert_(weakref.getweakrefcount(o) == 0, "weak reference objects not unlinked from" " referent when discarded.") @@ -315,7 +328,7 @@ ref1 = weakref.ref(o, self.callback) ref2 = weakref.ref(o, self.callback) del ref1 - test_support.gc_collect() + extra_collect() self.assert_(weakref.getweakrefs(o) == [ref2], "list of refs does not match") @@ -323,7 +336,7 @@ ref1 = weakref.ref(o, self.callback) ref2 = weakref.ref(o, self.callback) del ref2 - test_support.gc_collect() + 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 @@ -340,7 +353,7 @@ "list of refs does not match") del ref1 - test_support.gc_collect() + extra_collect() self.assert_(weakref.getweakrefs(o) == [], "list of refs not cleared") @@ -619,7 +632,7 @@ del callback, c, d, C self.assertEqual(alist, []) # del isn't enough to clean up cycles gc.collect() - test_support.gc_collect() + extra_collect() self.assertEqual(alist, ["safe_callback called"]) self.assertEqual(external_wr(), None) @@ -770,18 +783,18 @@ del items1, items2 self.assert_(len(dict) == self.COUNT) del objects[0] - test_support.gc_collect() + extra_collect() self.assert_(len(dict) == (self.COUNT - 1), "deleting object did not cause dictionary update") del objects, o - test_support.gc_collect() + extra_collect() self.assert_(len(dict) == 0, "deleting the values did not clear the dictionary") # regression on SF bug #447152: dict = weakref.WeakValueDictionary() self.assertRaises(KeyError, dict.__getitem__, 1) dict[2] = C() - test_support.gc_collect() + extra_collect() self.assertRaises(KeyError, dict.__getitem__, 2) def test_weak_keys(self): @@ -802,11 +815,11 @@ del items1, items2 self.assert_(len(dict) == self.COUNT) del objects[0] - test_support.gc_collect() + extra_collect() self.assert_(len(dict) == (self.COUNT - 1), "deleting object did not cause dictionary update") del objects, o - test_support.gc_collect() + extra_collect() self.assert_(len(dict) == 0, "deleting the keys did not clear the dictionary") o = Object(42) @@ -1115,7 +1128,7 @@ >>> o is o2 True >>> del o, o2 ->>> test_support.gc_collect() +>>> extra_collect() >>> print r() None @@ -1168,7 +1181,7 @@ >>> id2obj(a_id) is a True >>> del a ->>> test_support.gc_collect() +>>> extra_collect() >>> try: ... id2obj(a_id) ... except KeyError: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-06-01 04:38:00
|
Revision: 6436 http://jython.svn.sourceforge.net/jython/?rev=6436&view=rev Author: pjenvey Date: 2009-06-01 04:37:42 +0000 (Mon, 01 Jun 2009) Log Message: ----------- change our extra_collect into the 2.7/3.1 style test_support.gc_collect Modified Paths: -------------- trunk/jython/Lib/test/test_array.py trunk/jython/Lib/test/test_class.py trunk/jython/Lib/test/test_deque.py trunk/jython/Lib/test/test_descr.py trunk/jython/Lib/test/test_file.py trunk/jython/Lib/test/test_functools.py trunk/jython/Lib/test/test_generators.py trunk/jython/Lib/test/test_iter.py trunk/jython/Lib/test/test_scope.py trunk/jython/Lib/test/test_set.py trunk/jython/Lib/test/test_support.py trunk/jython/Lib/test/test_weakref.py Modified: trunk/jython/Lib/test/test_array.py =================================================================== --- trunk/jython/Lib/test/test_array.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_array.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -11,7 +11,6 @@ if test_support.is_jython: import operator - from test_weakref import extra_collect class ArraySubclass(array.array): pass @@ -704,8 +703,7 @@ p = proxy(s) self.assertEqual(p.tostring(), s.tostring()) s = None - if test_support.is_jython: - extra_collect() + test_support.gc_collect() self.assertRaises(ReferenceError, len, p) def test_bug_782369(self): Modified: trunk/jython/Lib/test/test_class.py =================================================================== --- trunk/jython/Lib/test/test_class.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_class.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -1,6 +1,6 @@ "Test the functionality of Python classes implementing operators." -from test.test_support import TestFailed +from test.test_support import TestFailed, gc_collect testmeths = [ @@ -249,9 +249,7 @@ # This test has to be last (duh.) del testme -if sys.platform[:4] == 'java': - from test_weakref import extra_collect - extra_collect() +gc_collect() # Interfering tests Modified: trunk/jython/Lib/test/test_deque.py =================================================================== --- trunk/jython/Lib/test/test_deque.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_deque.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -475,9 +475,7 @@ p = proxy(d) self.assertEqual(str(p), str(d)) d = None - if test_support.is_jython: - from test_weakref import extra_collect - extra_collect() + test_support.gc_collect() self.assertRaises(ReferenceError, str, p) def test_strange_subclass(self): Modified: trunk/jython/Lib/test/test_descr.py =================================================================== --- trunk/jython/Lib/test/test_descr.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_descr.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -1,14 +1,9 @@ # Test enhancements related to descriptors and new-style classes -from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_original_stdout, is_jython +from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_original_stdout, gc_collect, is_jython from copy import deepcopy import warnings import types -if is_jython: - from test_weakref import extra_collect -else: - def extra_collect(): - pass warnings.filterwarnings("ignore", r'complex divmod\(\), // and % are deprecated$', @@ -1266,7 +1261,7 @@ x.c = Counted() vereq(Counted.counter, 3) del x - extra_collect() + gc_collect() vereq(Counted.counter, 0) class D(C): pass @@ -1275,7 +1270,7 @@ x.z = Counted() vereq(Counted.counter, 2) del x - extra_collect() + gc_collect() vereq(Counted.counter, 0) class E(D): __slots__ = ['e'] @@ -1285,7 +1280,7 @@ x.e = Counted() vereq(Counted.counter, 3) del x - extra_collect() + gc_collect() vereq(Counted.counter, 0) # Test cyclical leaks [SF bug 519621] @@ -1298,7 +1293,7 @@ s = None import gc gc.collect() - extra_collect() + gc_collect() vereq(Counted.counter, 0) # XXX: This tests a CPython GC reference count bug and Jython lacks @@ -1331,7 +1326,7 @@ h = H() try: del h - extra_collect() + gc_collect() finally: sys.stderr = save_stderr @@ -1982,7 +1977,7 @@ r = weakref.ref(c) verify(r() is c) del c - extra_collect() + gc_collect() verify(r() is None) del r class NoWeak(object): @@ -2002,7 +1997,7 @@ r = weakref.ref(yes) verify(r() is yes) del yes - extra_collect() + gc_collect() verify(r() is None) del r @@ -3332,7 +3327,7 @@ c = C() vereq(log, []) del c - extra_collect() + gc_collect() vereq(log, [1]) class D(object): pass Modified: trunk/jython/Lib/test/test_file.py =================================================================== --- trunk/jython/Lib/test/test_file.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_file.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -5,7 +5,7 @@ from array import array from weakref import proxy -from test.test_support import TESTFN, findfile, is_jython, run_unittest +from test.test_support import TESTFN, findfile, gc_collect, is_jython, run_unittest from UserList import UserList class AutoFileTests(unittest.TestCase): @@ -26,9 +26,7 @@ self.assertEquals(self.f.tell(), p.tell()) self.f.close() self.f = None - if is_jython: - from test_weakref import extra_collect - extra_collect() + gc_collect() self.assertRaises(ReferenceError, getattr, p, 'tell') def testAttributes(self): Modified: trunk/jython/Lib/test/test_functools.py =================================================================== --- trunk/jython/Lib/test/test_functools.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_functools.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -131,9 +131,7 @@ p = proxy(f) self.assertEqual(f.func, p.func) f = None - if test_support.is_jython: - from test_weakref import extra_collect - extra_collect() + test_support.gc_collect() self.assertRaises(ReferenceError, getattr, p, 'func') def test_with_bound_and_unbound_methods(self): Modified: trunk/jython/Lib/test/test_generators.py =================================================================== --- trunk/jython/Lib/test/test_generators.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_generators.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -1653,7 +1653,7 @@ >>> g = f() >>> g.next() ->>> del g; extra_collect() +>>> del g; gc_collect() exiting @@ -1678,7 +1678,7 @@ >>> old, sys.stderr = sys.stderr, StringIO.StringIO() >>> g = f() >>> g.next() ->>> del g; extra_collect() +>>> del g; gc_collect() >>> sys.stderr.getvalue().startswith( ... "Exception RuntimeError" ... ) @@ -1795,7 +1795,7 @@ ... raise RuntimeError ... ... l = Leaker() -... del l; extra_collect() +... del l; gc_collect() ... err = sys.stderr.getvalue().strip() ... err.startswith( ... "Exception RuntimeError in <" @@ -1834,13 +1834,8 @@ from test import test_support, test_generators test_support.run_doctest(test_generators, verbose) -def extra_collect(): - import gc - from time import sleep +from test.test_support import gc_collect - gc.collect(); sleep(1); gc.collect(); sleep(0.1); gc.collect() - - # This part isn't needed for regrtest, but for running the test directly. if __name__ == "__main__": test_main(1) Modified: trunk/jython/Lib/test/test_iter.py =================================================================== --- trunk/jython/Lib/test/test_iter.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_iter.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -1,7 +1,7 @@ # Test iterators. import unittest -from test.test_support import run_unittest, TESTFN, unlink, have_unicode +from test.test_support import gc_collect, run_unittest, TESTFN, unlink, have_unicode # Test result of triple loop (too big to inline) TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2), @@ -781,7 +781,6 @@ # Test reference count behavior # XXX: Jython new style objects don't support __del__ yet - from test_weakref import extra_collect #class C(object): class C: count = 0 @@ -797,7 +796,7 @@ x = C() self.assertEqual(C.count, 1) del x - extra_collect() + gc_collect() self.assertEqual(C.count, 0) l = [C(), C(), C()] self.assertEqual(C.count, 3) @@ -806,7 +805,7 @@ except ValueError: pass del l - extra_collect() + gc_collect() self.assertEqual(C.count, 0) Modified: trunk/jython/Lib/test/test_scope.py =================================================================== --- trunk/jython/Lib/test/test_scope.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_scope.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -1,4 +1,4 @@ -from test.test_support import verify, TestFailed, check_syntax, vereq, is_jython +from test.test_support import verify, TestFailed, check_syntax, vereq, gc_collect import warnings warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "<string>") @@ -435,11 +435,9 @@ for i in range(100): f1() -if is_jython: - from test_weakref import extra_collect - extra_collect() - # A lot of garbage - extra_collect() +gc_collect() +# A lot of garbage +gc_collect() vereq(Foo.count, 0) print "17. class and global" Modified: trunk/jython/Lib/test/test_set.py =================================================================== --- trunk/jython/Lib/test/test_set.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_set.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -1,6 +1,5 @@ import unittest from test import test_support -from test_weakref import extra_collect from weakref import proxy import operator import copy @@ -484,7 +483,7 @@ p = proxy(s) self.assertEqual(str(p), str(s)) s = None - extra_collect() + test_support.gc_collect() self.assertRaises(ReferenceError, str, p) # C API test only available in a debug build Modified: trunk/jython/Lib/test/test_support.py =================================================================== --- trunk/jython/Lib/test/test_support.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_support.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -299,6 +299,22 @@ fn, _ = urllib.urlretrieve(url, filename) return open(fn) +def gc_collect(): + """Force as many objects as possible to be collected. + + In non-CPython implementations of Python, this is needed because timely + deallocation is not guaranteed by the garbage collector. (Even in CPython + this can be the case in case of reference cycles.) This means that __del__ + methods may be called later than expected and weakrefs may remain alive for + longer than expected. This function tries its best to force all garbage + objects to disappear. + """ + import gc + gc.collect() + time.sleep(0.1) + gc.collect() + gc.collect() + #======================================================================= # Decorator for running a function in a different locale, correctly resetting # it afterwards. Modified: trunk/jython/Lib/test/test_weakref.py =================================================================== --- trunk/jython/Lib/test/test_weakref.py 2009-05-31 21:42:09 UTC (rev 6435) +++ trunk/jython/Lib/test/test_weakref.py 2009-06-01 04:37:42 UTC (rev 6436) @@ -6,19 +6,6 @@ from test import test_support -if test_support.is_jython: - import time - - def extra_collect(): - """Kick Java's GC into gear""" - gc.collect() - time.sleep(0.1) - gc.collect() - gc.collect() -else: - def extra_collect(): - pass - # Used in ReferencesTestCase.test_ref_created_during_del() . ref_from_del = None @@ -82,7 +69,7 @@ ref1 = weakref.ref(o, self.callback) ref2 = weakref.ref(o, self.callback) del o - extra_collect() + test_support.gc_collect() self.assert_(ref1() is None, "expected reference to be invalidated") self.assert_(ref2() is None, @@ -118,7 +105,7 @@ def check(proxy): proxy.bar - extra_collect() + test_support.gc_collect() self.assertRaises(weakref.ReferenceError, check, ref1) self.assertRaises(weakref.ReferenceError, check, ref2) # XXX: CPython GC collects C() immediately. use ref1 instead on @@ -143,7 +130,7 @@ o = factory() ref = weakref.ref(o, self.callback) del o - extra_collect() + test_support.gc_collect() self.assert_(self.cbcalled == 1, "callback did not properly set 'cbcalled'") self.assert_(ref() is None, @@ -168,7 +155,7 @@ self.assert_(weakref.getweakrefcount(o) == 2, "wrong weak ref count for object") del proxy - extra_collect() + test_support.gc_collect() self.assert_(weakref.getweakrefcount(o) == 1, "wrong weak ref count for object after deleting proxy") @@ -314,7 +301,7 @@ "got wrong number of weak reference objects") del ref1, ref2, proxy1, proxy2 - extra_collect() + test_support.gc_collect() self.assert_(weakref.getweakrefcount(o) == 0, "weak reference objects not unlinked from" " referent when discarded.") @@ -328,7 +315,7 @@ ref1 = weakref.ref(o, self.callback) ref2 = weakref.ref(o, self.callback) del ref1 - extra_collect() + test_support.gc_collect() self.assert_(weakref.getweakrefs(o) == [ref2], "list of refs does not match") @@ -336,7 +323,7 @@ ref1 = weakref.ref(o, self.callback) ref2 = weakref.ref(o, self.callback) del ref2 - extra_collect() + test_support.gc_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 @@ -353,7 +340,7 @@ "list of refs does not match") del ref1 - extra_collect() + test_support.gc_collect() self.assert_(weakref.getweakrefs(o) == [], "list of refs not cleared") @@ -632,7 +619,7 @@ del callback, c, d, C self.assertEqual(alist, []) # del isn't enough to clean up cycles gc.collect() - extra_collect() + test_support.gc_collect() self.assertEqual(alist, ["safe_callback called"]) self.assertEqual(external_wr(), None) @@ -783,18 +770,18 @@ del items1, items2 self.assert_(len(dict) == self.COUNT) del objects[0] - extra_collect() + test_support.gc_collect() self.assert_(len(dict) == (self.COUNT - 1), "deleting object did not cause dictionary update") del objects, o - extra_collect() + test_support.gc_collect() self.assert_(len(dict) == 0, "deleting the values did not clear the dictionary") # regression on SF bug #447152: dict = weakref.WeakValueDictionary() self.assertRaises(KeyError, dict.__getitem__, 1) dict[2] = C() - extra_collect() + test_support.gc_collect() self.assertRaises(KeyError, dict.__getitem__, 2) def test_weak_keys(self): @@ -815,11 +802,11 @@ del items1, items2 self.assert_(len(dict) == self.COUNT) del objects[0] - extra_collect() + test_support.gc_collect() self.assert_(len(dict) == (self.COUNT - 1), "deleting object did not cause dictionary update") del objects, o - extra_collect() + test_support.gc_collect() self.assert_(len(dict) == 0, "deleting the keys did not clear the dictionary") o = Object(42) @@ -1128,7 +1115,7 @@ >>> o is o2 True >>> del o, o2 ->>> extra_collect() +>>> test_support.gc_collect() >>> print r() None @@ -1181,7 +1168,7 @@ >>> id2obj(a_id) is a True >>> del a ->>> extra_collect() +>>> test_support.gc_collect() >>> try: ... id2obj(a_id) ... except KeyError: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-31 21:42:26
|
Revision: 6435 http://jython.svn.sourceforge.net/jython/?rev=6435&view=rev Author: pjenvey Date: 2009-05-31 21:42:09 +0000 (Sun, 31 May 2009) Log Message: ----------- remove the no longer needed exposed {str,unicode}.toString Modified Paths: -------------- trunk/jython/Lib/unicodedata.py trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/core/PyUnicode.java Modified: trunk/jython/Lib/unicodedata.py =================================================================== --- trunk/jython/Lib/unicodedata.py 2009-05-31 14:50:48 UTC (rev 6434) +++ trunk/jython/Lib/unicodedata.py 2009-05-31 21:42:09 UTC (rev 6435) @@ -209,7 +209,7 @@ normalizer_form = _forms[form] except KeyError: raise ValueError('invalid normalization form') - return Normalizer.normalize(unistr.toString(), normalizer_form) + return Normalizer.normalize(unistr, normalizer_form) except ImportError: pass Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2009-05-31 14:50:48 UTC (rev 6434) +++ trunk/jython/src/org/python/core/PyString.java 2009-05-31 21:42:09 UTC (rev 6435) @@ -116,12 +116,6 @@ return string; } - //XXX: need doc - @ExposedMethod - final String str_toString() { - return toString(); - } - public String internedString() { if (interned) return string; Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2009-05-31 14:50:48 UTC (rev 6434) +++ trunk/jython/src/org/python/core/PyUnicode.java 2009-05-31 21:42:09 UTC (rev 6435) @@ -1431,10 +1431,4 @@ } return sb.toString(); } - - //needs doc - @ExposedMethod/*(doc = BuiltinDocs.unicode_toString_doc)*/ - final String unicode_toString() { - return toString(); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-05-31 14:50:49
|
Revision: 6434 http://jython.svn.sourceforge.net/jython/?rev=6434&view=rev Author: otmarhumbel Date: 2009-05-31 14:50:48 +0000 (Sun, 31 May 2009) Log Message: ----------- quote the policy file if it contains spaces Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-05-31 03:26:57 UTC (rev 6433) +++ trunk/jython/Lib/test/test_java_integration.py 2009-05-31 14:50:48 UTC (rev 6434) @@ -411,6 +411,9 @@ # script must lie within python.home for this test to work return policy = test_support.findfile("python_home.policy") + if len(policy.split(' ')) > 1: + # quote the policy file if it contains spaces + policy = '"%s"' % policy self.assertEquals(subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true", "-J-Djava.security.manager", "-J-Djava.security.policy=%s" % policy, script]), 0) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-31 03:27:45
|
Revision: 6433 http://jython.svn.sourceforge.net/jython/?rev=6433&view=rev Author: pjenvey Date: 2009-05-31 03:26:57 +0000 (Sun, 31 May 2009) Log Message: ----------- deprecate the no longer needed {str,unicode}.isunicode and remove cPickle's use of it Modified Paths: -------------- trunk/jython/src/org/python/core/PyString.java trunk/jython/src/org/python/core/PyUnicode.java trunk/jython/src/org/python/modules/cPickle.java Modified: trunk/jython/src/org/python/core/PyString.java =================================================================== --- trunk/jython/src/org/python/core/PyString.java 2009-05-31 00:25:12 UTC (rev 6432) +++ trunk/jython/src/org/python/core/PyString.java 2009-05-31 03:26:57 UTC (rev 6433) @@ -2406,9 +2406,9 @@ return str_isunicode(); } - //XXX: need doc - @ExposedMethod/*(doc = BuiltinDocs.unicode_isunicode_doc)*/ + @ExposedMethod(doc = "isunicode is deprecated.") final boolean str_isunicode() { + Py.warning(Py.DeprecationWarning, "isunicode is deprecated."); int n = string.length(); for (int i = 0; i < n; i++) { char ch = string.charAt(i); Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2009-05-31 00:25:12 UTC (rev 6432) +++ trunk/jython/src/org/python/core/PyUnicode.java 2009-05-31 03:26:57 UTC (rev 6433) @@ -1318,10 +1318,11 @@ } return true; } - // XXX: needs doc + // end utf-16 aware - @ExposedMethod + @ExposedMethod(doc = "isunicode is deprecated.") final boolean unicode_isunicode() { + Py.warning(Py.DeprecationWarning, "isunicode is deprecated."); return true; } Modified: trunk/jython/src/org/python/modules/cPickle.java =================================================================== --- trunk/jython/src/org/python/modules/cPickle.java 2009-05-31 00:25:12 UTC (rev 6432) +++ trunk/jython/src/org/python/modules/cPickle.java 2009-05-31 03:26:57 UTC (rev 6433) @@ -1067,21 +1067,15 @@ final private void save_string(PyObject object) { - boolean unicode = ((PyString) object).isunicode(); String str = object.toString(); if (protocol > 0) { - if (unicode) - str = codecs.PyUnicode_EncodeUTF8(str, "struct"); int l = str.length(); - if (l < 256 && !unicode) { + if (l < 256) { file.write(SHORT_BINSTRING); file.write((char)l); } else { - if (unicode) - file.write(BINUNICODE); - else - file.write(BINSTRING); + file.write(BINSTRING); file.write((char)( l & 0xFF)); file.write((char)((l >>> 8 ) & 0xFF)); file.write((char)((l >>> 16) & 0xFF)); @@ -1089,14 +1083,8 @@ } file.write(str); } else { - if (unicode) { - file.write(UNICODE); - file.write(codecs.PyUnicode_EncodeRawUnicodeEscape(str, - "strict", true)); - } else { - file.write(STRING); - file.write(object.__repr__().toString()); - } + file.write(STRING); + file.write(object.__repr__().toString()); file.write("\n"); } put(putMemo(get_id(object), object)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-31 01:01:44
|
Revision: 6432 http://jython.svn.sourceforge.net/jython/?rev=6432&view=rev Author: pjenvey Date: 2009-05-31 00:25:12 +0000 (Sun, 31 May 2009) Log Message: ----------- lame workaround for test_support.make_jar_classloader jar file handles being held onto, for test_classpathimporter on Windows Modified Paths: -------------- trunk/jython/Lib/test/test_support.py Modified: trunk/jython/Lib/test/test_support.py =================================================================== --- trunk/jython/Lib/test/test_support.py 2009-05-30 22:47:39 UTC (rev 6431) +++ trunk/jython/Lib/test/test_support.py 2009-05-31 00:25:12 UTC (rev 6432) @@ -147,9 +147,21 @@ is_jython = sys.platform.startswith('java') if is_jython: def make_jar_classloader(jar): - from java.io import File - from java.net import URLClassLoader - url = File(findfile(jar)).toURL() + import os + from java.net import URL, URLClassLoader + + url = URL('jar:file:%s!/' % jar) + if os._name == 'nt': + # URLJarFiles keep a cached open file handle to the jar even + # after this ClassLoader is GC'ed, disallowing Windows tests + # from removing the jar file from disk when finished with it + conn = url.openConnection() + if conn.getDefaultUseCaches(): + # XXX: Globally turn off jar caching: this stupid + # instance method actually toggles a static flag. Need a + # better fix + conn.setDefaultUseCaches(False) + return URLClassLoader([url]) import os This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-30 22:47:41
|
Revision: 6431 http://jython.svn.sourceforge.net/jython/?rev=6431&view=rev Author: pjenvey Date: 2009-05-30 22:47:39 +0000 (Sat, 30 May 2009) Log Message: ----------- regen per r6430 Modified Paths: -------------- trunk/jython/src/org/python/antlr/ast/Assert.java trunk/jython/src/org/python/antlr/ast/Assign.java trunk/jython/src/org/python/antlr/ast/Attribute.java trunk/jython/src/org/python/antlr/ast/AugAssign.java trunk/jython/src/org/python/antlr/ast/BinOp.java trunk/jython/src/org/python/antlr/ast/BoolOp.java trunk/jython/src/org/python/antlr/ast/Break.java trunk/jython/src/org/python/antlr/ast/Call.java trunk/jython/src/org/python/antlr/ast/ClassDef.java trunk/jython/src/org/python/antlr/ast/Compare.java trunk/jython/src/org/python/antlr/ast/Continue.java trunk/jython/src/org/python/antlr/ast/Delete.java trunk/jython/src/org/python/antlr/ast/Dict.java trunk/jython/src/org/python/antlr/ast/Ellipsis.java trunk/jython/src/org/python/antlr/ast/ExceptHandler.java trunk/jython/src/org/python/antlr/ast/Exec.java trunk/jython/src/org/python/antlr/ast/Expr.java trunk/jython/src/org/python/antlr/ast/Expression.java trunk/jython/src/org/python/antlr/ast/ExtSlice.java trunk/jython/src/org/python/antlr/ast/For.java trunk/jython/src/org/python/antlr/ast/FunctionDef.java trunk/jython/src/org/python/antlr/ast/GeneratorExp.java trunk/jython/src/org/python/antlr/ast/Global.java trunk/jython/src/org/python/antlr/ast/If.java trunk/jython/src/org/python/antlr/ast/IfExp.java trunk/jython/src/org/python/antlr/ast/Import.java trunk/jython/src/org/python/antlr/ast/ImportFrom.java trunk/jython/src/org/python/antlr/ast/Index.java trunk/jython/src/org/python/antlr/ast/Interactive.java trunk/jython/src/org/python/antlr/ast/Lambda.java trunk/jython/src/org/python/antlr/ast/List.java trunk/jython/src/org/python/antlr/ast/ListComp.java trunk/jython/src/org/python/antlr/ast/Module.java trunk/jython/src/org/python/antlr/ast/Name.java trunk/jython/src/org/python/antlr/ast/Num.java trunk/jython/src/org/python/antlr/ast/Pass.java trunk/jython/src/org/python/antlr/ast/Print.java trunk/jython/src/org/python/antlr/ast/Raise.java trunk/jython/src/org/python/antlr/ast/Repr.java trunk/jython/src/org/python/antlr/ast/Return.java trunk/jython/src/org/python/antlr/ast/Slice.java trunk/jython/src/org/python/antlr/ast/Str.java trunk/jython/src/org/python/antlr/ast/Subscript.java trunk/jython/src/org/python/antlr/ast/Suite.java trunk/jython/src/org/python/antlr/ast/TryExcept.java trunk/jython/src/org/python/antlr/ast/TryFinally.java trunk/jython/src/org/python/antlr/ast/Tuple.java trunk/jython/src/org/python/antlr/ast/UnaryOp.java trunk/jython/src/org/python/antlr/ast/While.java trunk/jython/src/org/python/antlr/ast/With.java trunk/jython/src/org/python/antlr/ast/Yield.java trunk/jython/src/org/python/antlr/ast/alias.java trunk/jython/src/org/python/antlr/ast/arguments.java trunk/jython/src/org/python/antlr/ast/comprehension.java trunk/jython/src/org/python/antlr/ast/keyword.java Modified: trunk/jython/src/org/python/antlr/ast/Assert.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Assert.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Assert.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -140,7 +140,7 @@ return visitor.visitAssert(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (test != null) test.accept(visitor); if (msg != null) Modified: trunk/jython/src/org/python/antlr/ast/Assign.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Assign.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Assign.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -155,7 +155,7 @@ return visitor.visitAssign(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (targets != null) { for (PythonTree t : targets) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/Attribute.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Attribute.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Attribute.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -159,7 +159,7 @@ return visitor.visitAttribute(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (value != null) value.accept(visitor); } Modified: trunk/jython/src/org/python/antlr/ast/AugAssign.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AugAssign.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/AugAssign.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -161,7 +161,7 @@ return visitor.visitAugAssign(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (target != null) target.accept(visitor); if (value != null) Modified: trunk/jython/src/org/python/antlr/ast/BinOp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BinOp.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/BinOp.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -161,7 +161,7 @@ return visitor.visitBinOp(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (left != null) left.accept(visitor); if (right != null) Modified: trunk/jython/src/org/python/antlr/ast/BoolOp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BoolOp.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/BoolOp.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -152,7 +152,7 @@ return visitor.visitBoolOp(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (values != null) { for (PythonTree t : values) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/Break.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Break.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Break.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -88,7 +88,7 @@ return visitor.visitBreak(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { } private int lineno = -1; Modified: trunk/jython/src/org/python/antlr/ast/Call.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Call.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Call.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -247,7 +247,7 @@ return visitor.visitCall(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (func != null) func.accept(visitor); if (args != null) { Modified: trunk/jython/src/org/python/antlr/ast/ClassDef.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ClassDef.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/ClassDef.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -235,7 +235,7 @@ return visitor.visitClassDef(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (bases != null) { for (PythonTree t : bases) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/Compare.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Compare.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Compare.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -179,7 +179,7 @@ return visitor.visitCompare(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (left != null) left.accept(visitor); if (comparators != null) { Modified: trunk/jython/src/org/python/antlr/ast/Continue.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Continue.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Continue.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -88,7 +88,7 @@ return visitor.visitContinue(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { } private int lineno = -1; Modified: trunk/jython/src/org/python/antlr/ast/Delete.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Delete.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Delete.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -131,7 +131,7 @@ return visitor.visitDelete(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (targets != null) { for (PythonTree t : targets) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/Dict.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Dict.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Dict.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -171,7 +171,7 @@ return visitor.visitDict(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (keys != null) { for (PythonTree t : keys) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/Ellipsis.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Ellipsis.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Ellipsis.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -77,7 +77,7 @@ return visitor.visitEllipsis(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { } } Modified: trunk/jython/src/org/python/antlr/ast/ExceptHandler.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExceptHandler.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/ExceptHandler.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -180,7 +180,7 @@ return visitor.visitExceptHandler(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (type != null) type.accept(visitor); if (name != null) Modified: trunk/jython/src/org/python/antlr/ast/Exec.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Exec.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Exec.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -164,7 +164,7 @@ return visitor.visitExec(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (body != null) body.accept(visitor); if (globals != null) Modified: trunk/jython/src/org/python/antlr/ast/Expr.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Expr.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Expr.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -116,7 +116,7 @@ return visitor.visitExpr(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (value != null) value.accept(visitor); } Modified: trunk/jython/src/org/python/antlr/ast/Expression.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Expression.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Expression.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -105,7 +105,7 @@ return visitor.visitExpression(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (body != null) body.accept(visitor); } Modified: trunk/jython/src/org/python/antlr/ast/ExtSlice.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExtSlice.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/ExtSlice.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -120,7 +120,7 @@ return visitor.visitExtSlice(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (dims != null) { for (PythonTree t : dims) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/For.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/For.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/For.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -222,7 +222,7 @@ return visitor.visitFor(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (target != null) target.accept(visitor); if (iter != null) Modified: trunk/jython/src/org/python/antlr/ast/FunctionDef.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/FunctionDef.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/FunctionDef.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -217,7 +217,7 @@ return visitor.visitFunctionDef(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (args != null) args.accept(visitor); if (body != null) { Modified: trunk/jython/src/org/python/antlr/ast/GeneratorExp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GeneratorExp.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/GeneratorExp.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -156,7 +156,7 @@ return visitor.visitGeneratorExp(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (elt != null) elt.accept(visitor); if (generators != null) { Modified: trunk/jython/src/org/python/antlr/ast/Global.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Global.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Global.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -113,7 +113,7 @@ return visitor.visitGlobal(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { } private int lineno = -1; Modified: trunk/jython/src/org/python/antlr/ast/If.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/If.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/If.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -195,7 +195,7 @@ return visitor.visitIf(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (test != null) test.accept(visitor); if (body != null) { Modified: trunk/jython/src/org/python/antlr/ast/IfExp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfExp.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/IfExp.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -164,7 +164,7 @@ return visitor.visitIfExp(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (test != null) test.accept(visitor); if (body != null) Modified: trunk/jython/src/org/python/antlr/ast/Import.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Import.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Import.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -131,7 +131,7 @@ return visitor.visitImport(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (names != null) { for (PythonTree t : names) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/ImportFrom.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportFrom.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/ImportFrom.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -175,7 +175,7 @@ return visitor.visitImportFrom(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (names != null) { for (PythonTree t : names) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/Index.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Index.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Index.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -105,7 +105,7 @@ return visitor.visitIndex(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (value != null) value.accept(visitor); } Modified: trunk/jython/src/org/python/antlr/ast/Interactive.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Interactive.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Interactive.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -120,7 +120,7 @@ return visitor.visitInteractive(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (body != null) { for (PythonTree t : body) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/Lambda.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Lambda.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Lambda.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -137,7 +137,7 @@ return visitor.visitLambda(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (args != null) args.accept(visitor); if (body != null) Modified: trunk/jython/src/org/python/antlr/ast/List.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/List.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/List.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -152,7 +152,7 @@ return visitor.visitList(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (elts != null) { for (PythonTree t : elts) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/ListComp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ListComp.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/ListComp.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -156,7 +156,7 @@ return visitor.visitListComp(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (elt != null) elt.accept(visitor); if (generators != null) { Modified: trunk/jython/src/org/python/antlr/ast/Module.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Module.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Module.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -120,7 +120,7 @@ return visitor.visitModule(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (body != null) { for (PythonTree t : body) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/Name.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Name.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Name.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -135,7 +135,7 @@ return visitor.visitName(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { } public void setContext(expr_contextType c) { Modified: trunk/jython/src/org/python/antlr/ast/Num.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Num.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Num.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -113,7 +113,7 @@ return visitor.visitNum(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { } private int lineno = -1; Modified: trunk/jython/src/org/python/antlr/ast/Pass.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Pass.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Pass.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -88,7 +88,7 @@ return visitor.visitPass(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { } private int lineno = -1; Modified: trunk/jython/src/org/python/antlr/ast/Print.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Print.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Print.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -177,7 +177,7 @@ return visitor.visitPrint(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (dest != null) dest.accept(visitor); if (values != null) { Modified: trunk/jython/src/org/python/antlr/ast/Raise.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Raise.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Raise.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -164,7 +164,7 @@ return visitor.visitRaise(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (type != null) type.accept(visitor); if (inst != null) Modified: trunk/jython/src/org/python/antlr/ast/Repr.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Repr.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Repr.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -116,7 +116,7 @@ return visitor.visitRepr(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (value != null) value.accept(visitor); } Modified: trunk/jython/src/org/python/antlr/ast/Return.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Return.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Return.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -116,7 +116,7 @@ return visitor.visitReturn(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (value != null) value.accept(visitor); } Modified: trunk/jython/src/org/python/antlr/ast/Slice.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Slice.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Slice.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -153,7 +153,7 @@ return visitor.visitSlice(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (lower != null) lower.accept(visitor); if (upper != null) Modified: trunk/jython/src/org/python/antlr/ast/Str.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Str.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Str.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -113,7 +113,7 @@ return visitor.visitStr(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { } private int lineno = -1; Modified: trunk/jython/src/org/python/antlr/ast/Subscript.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Subscript.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Subscript.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -158,7 +158,7 @@ return visitor.visitSubscript(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (value != null) value.accept(visitor); if (slice != null) Modified: trunk/jython/src/org/python/antlr/ast/Suite.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Suite.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Suite.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -120,7 +120,7 @@ return visitor.visitSuite(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (body != null) { for (PythonTree t : body) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/TryExcept.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryExcept.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/TryExcept.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -212,7 +212,7 @@ return visitor.visitTryExcept(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (body != null) { for (PythonTree t : body) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/TryFinally.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/TryFinally.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/TryFinally.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -171,7 +171,7 @@ return visitor.visitTryFinally(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (body != null) { for (PythonTree t : body) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/Tuple.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Tuple.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Tuple.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -152,7 +152,7 @@ return visitor.visitTuple(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (elts != null) { for (PythonTree t : elts) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/UnaryOp.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/UnaryOp.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/UnaryOp.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -137,7 +137,7 @@ return visitor.visitUnaryOp(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (operand != null) operand.accept(visitor); } Modified: trunk/jython/src/org/python/antlr/ast/While.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/While.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/While.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -196,7 +196,7 @@ return visitor.visitWhile(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (test != null) test.accept(visitor); if (body != null) { Modified: trunk/jython/src/org/python/antlr/ast/With.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/With.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/With.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -181,7 +181,7 @@ return visitor.visitWith(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (context_expr != null) context_expr.accept(visitor); if (optional_vars != null) Modified: trunk/jython/src/org/python/antlr/ast/Yield.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Yield.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/Yield.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -116,7 +116,7 @@ return visitor.visitYield(this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (value != null) value.accept(visitor); } Modified: trunk/jython/src/org/python/antlr/ast/alias.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/alias.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/alias.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -126,7 +126,7 @@ return null; } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { } } Modified: trunk/jython/src/org/python/antlr/ast/arguments.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/arguments.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/arguments.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -208,7 +208,7 @@ return null; } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (args != null) { for (PythonTree t : args) { if (t != null) Modified: trunk/jython/src/org/python/antlr/ast/comprehension.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/comprehension.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/comprehension.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -170,7 +170,7 @@ return null; } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (target != null) target.accept(visitor); if (iter != null) Modified: trunk/jython/src/org/python/antlr/ast/keyword.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/keyword.java 2009-05-30 22:46:21 UTC (rev 6430) +++ trunk/jython/src/org/python/antlr/ast/keyword.java 2009-05-30 22:47:39 UTC (rev 6431) @@ -128,7 +128,7 @@ return null; } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { if (value != null) value.accept(visitor); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-30 22:46:33
|
Revision: 6430 http://jython.svn.sourceforge.net/jython/?rev=6430&view=rev Author: pjenvey Date: 2009-05-30 22:46:21 +0000 (Sat, 30 May 2009) Log Message: ----------- quiet a simple unchecked warning pervading the ast nodes Modified Paths: -------------- trunk/jython/ast/asdl_antlr.py trunk/jython/src/org/python/antlr/PythonTree.java Modified: trunk/jython/ast/asdl_antlr.py =================================================================== --- trunk/jython/ast/asdl_antlr.py 2009-05-30 21:20:11 UTC (rev 6429) +++ trunk/jython/ast/asdl_antlr.py 2009-05-30 22:46:21 UTC (rev 6430) @@ -441,7 +441,7 @@ self.emit("", 0) # The visitChildren() method - self.emit("public void traverse(VisitorIF visitor) throws Exception {", depth) + self.emit("public void traverse(VisitorIF<?> visitor) throws Exception {", depth) for f in fields: if self.bltinnames.has_key(str(f.type)): continue Modified: trunk/jython/src/org/python/antlr/PythonTree.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTree.java 2009-05-30 21:20:11 UTC (rev 6429) +++ trunk/jython/src/org/python/antlr/PythonTree.java 2009-05-30 22:46:21 UTC (rev 6430) @@ -176,6 +176,7 @@ node.setChildIndex(index); } + @Override public String toString() { if (isNil()) { return "None"; @@ -245,7 +246,7 @@ throw new RuntimeException("Unexpected node: " + this); } - public void traverse(VisitorIF visitor) throws Exception { + public void traverse(VisitorIF<?> visitor) throws Exception { throw new RuntimeException("Cannot traverse node: " + this); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-30 21:20:12
|
Revision: 6429 http://jython.svn.sourceforge.net/jython/?rev=6429&view=rev Author: pjenvey Date: 2009-05-30 21:20:11 +0000 (Sat, 30 May 2009) Log Message: ----------- ensure open file handles are closed Modified Paths: -------------- trunk/jython/Lib/test/test_classpathimporter.py trunk/jython/src/org/python/core/util/importer.java Modified: trunk/jython/Lib/test/test_classpathimporter.py =================================================================== --- trunk/jython/Lib/test/test_classpathimporter.py 2009-05-30 06:49:08 UTC (rev 6428) +++ trunk/jython/Lib/test/test_classpathimporter.py 2009-05-30 21:20:11 UTC (rev 6429) @@ -68,7 +68,6 @@ os.path.join(compile_path, 'jar_pkg', 'prefer_compiled$py.class')) zip.close() - zip = zipfile.ZipFile(jar) Thread.currentThread().contextClassLoader = test_support.make_jar_classloader(jar) import flat_in_jar Modified: trunk/jython/src/org/python/core/util/importer.java =================================================================== --- trunk/jython/src/org/python/core/util/importer.java 2009-05-30 06:49:08 UTC (rev 6428) +++ trunk/jython/src/org/python/core/util/importer.java 2009-05-30 21:20:11 UTC (rev 6429) @@ -188,16 +188,19 @@ Bundle bundle = makeBundle(searchPath, tocEntry); byte[] codeBytes; - if (isbytecode) { - try { - codeBytes = imp.readCode(fullname, bundle.inputStream, true); - } catch (IOException ioe) { - throw Py.ImportError(ioe.getMessage() + "[path=" + fullSearchPath + "]"); + try { + if (isbytecode) { + try { + codeBytes = imp.readCode(fullname, bundle.inputStream, true); + } catch (IOException ioe) { + throw Py.ImportError(ioe.getMessage() + "[path=" + fullSearchPath + "]"); + } + } else { + codeBytes = imp.compileSource(fullname, bundle.inputStream, fullSearchPath); } - } else { - codeBytes = imp.compileSource(fullname, bundle.inputStream, fullSearchPath); + } finally { + bundle.close(); } - bundle.close(); if (codeBytes == null) { // bad magic number or non-matching mtime in byte code, try next This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-30 06:49:09
|
Revision: 6428 http://jython.svn.sourceforge.net/jython/?rev=6428&view=rev Author: pjenvey Date: 2009-05-30 06:49:08 +0000 (Sat, 30 May 2009) Log Message: ----------- just skip test_popen on windows when ' ' in sys.executable as CPython still suffers from this anyway Modified Paths: -------------- trunk/jython/Lib/test/regrtest.py Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2009-05-30 06:41:33 UTC (rev 6427) +++ trunk/jython/Lib/test/regrtest.py 2009-05-30 06:49:08 UTC (rev 6428) @@ -1493,6 +1493,9 @@ # XXX: Omitted for now because it fails so miserably and ruins # other tests _failures['java'] += '\ntest_mailbox' + if ' ' in sys.executable: + # http://bugs.python.org/issue1559298 + _failures['java'] += '\ntest_popen' class _ExpectedSkips: def __init__(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-30 06:42:35
|
Revision: 6427 http://jython.svn.sourceforge.net/jython/?rev=6427&view=rev Author: pjenvey Date: 2009-05-30 06:41:33 +0000 (Sat, 30 May 2009) Log Message: ----------- o close some mailbox file handles o skip test_shutil.test_on_error which is questionable for Jython Modified Paths: -------------- trunk/jython/Lib/mailbox.py trunk/jython/Lib/test/test_old_mailbox.py trunk/jython/Lib/test/test_shutil.py Modified: trunk/jython/Lib/mailbox.py =================================================================== --- trunk/jython/Lib/mailbox.py 2009-05-30 06:40:55 UTC (rev 6426) +++ trunk/jython/Lib/mailbox.py 2009-05-30 06:41:33 UTC (rev 6427) @@ -955,6 +955,7 @@ if self._locked: _unlock_file(self._file) _sync_close(self._file) + self._file.close() del self._file self._locked = False @@ -1780,6 +1781,7 @@ def close(self): """Close the file.""" + self._file.close() del self._file def _read(self, size, read_method): Modified: trunk/jython/Lib/test/test_old_mailbox.py =================================================================== --- trunk/jython/Lib/test/test_old_mailbox.py 2009-05-30 06:40:55 UTC (rev 6426) +++ trunk/jython/Lib/test/test_old_mailbox.py 2009-05-30 06:41:33 UTC (rev 6427) @@ -1,6 +1,7 @@ # This set of tests exercises the backward-compatibility class # in mailbox.py (the ones without write support). +from __future__ import with_statement import mailbox import os import time @@ -63,6 +64,10 @@ self._msgfiles.append(newname) return tmpname + def assert_and_close(self, message): + self.assert_(message is not None) + message.fp.close() + def test_empty_maildir(self): """Test an empty maildir mailbox""" # Test for regression on bug #117490: @@ -75,7 +80,7 @@ self.createMessage("cur") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assert_(len(self.mbox) == 1) - self.assert_(self.mbox.next() is not None) + self.assert_and_close(self.mbox.next()) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None) @@ -83,7 +88,7 @@ self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assert_(len(self.mbox) == 1) - self.assert_(self.mbox.next() is not None) + self.assert_and_close(self.mbox.next()) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None) @@ -92,8 +97,8 @@ self.createMessage("new") self.mbox = mailbox.Maildir(test_support.TESTFN) self.assert_(len(self.mbox) == 2) - self.assert_(self.mbox.next() is not None) - self.assert_(self.mbox.next() is not None) + self.assert_and_close(self.mbox.next()) + self.assert_and_close(self.mbox.next()) self.assert_(self.mbox.next() is None) self.assert_(self.mbox.next() is None) @@ -102,11 +107,12 @@ import email.Parser fname = self.createMessage("cur", True) n = 0 - for msg in mailbox.PortableUnixMailbox(open(fname), - email.Parser.Parser().parse): - n += 1 - self.assertEqual(msg["subject"], "Simple Test") - self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE)) + with open(fname) as fp: + for msg in mailbox.PortableUnixMailbox(fp, + email.Parser.Parser().parse): + n += 1 + self.assertEqual(msg["subject"], "Simple Test") + self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE)) self.assertEqual(n, 1) class MboxTestCase(unittest.TestCase): @@ -139,7 +145,10 @@ """) f.close() box = mailbox.UnixMailbox(open(self._path, 'r')) - self.assert_(len(list(iter(box))) == 4) + messages = list(iter(box)) + self.assert_(len(messages) == 4) + for message in messages: + message.fp.close() # XXX We still need more tests! Modified: trunk/jython/Lib/test/test_shutil.py =================================================================== --- trunk/jython/Lib/test/test_shutil.py 2009-05-30 06:40:55 UTC (rev 6426) +++ trunk/jython/Lib/test/test_shutil.py 2009-05-30 06:41:33 UTC (rev 6427) @@ -18,8 +18,11 @@ # See bug #1071513 for why we don't run this on cygwin # and bug #1076467 for why we don't run this as root. + # XXX: Fails on Jython because Java resets the S_IREAD permission + # when removing the file if (hasattr(os, 'chmod') and sys.platform[:6] != 'cygwin' - and not (hasattr(os, 'geteuid') and os.geteuid() == 0)): + and not (hasattr(os, 'geteuid') and os.geteuid() == 0) + and (not test_support.is_jython or os._name != 'nt')): def test_on_error(self): self.errorState = 0 os.mkdir(TESTFN) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-30 06:41:44
|
Revision: 6426 http://jython.svn.sourceforge.net/jython/?rev=6426&view=rev Author: pjenvey Date: 2009-05-30 06:40:55 +0000 (Sat, 30 May 2009) Log Message: ----------- from: http://svn.python.org/projects/python/branches/release25-maint/Lib/mailbox.py@60096 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_old_mailbox.py@54954 http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_shutil.py@51187 Added Paths: ----------- trunk/jython/Lib/mailbox.py trunk/jython/Lib/test/test_old_mailbox.py trunk/jython/Lib/test/test_shutil.py Added: trunk/jython/Lib/mailbox.py =================================================================== --- trunk/jython/Lib/mailbox.py (rev 0) +++ trunk/jython/Lib/mailbox.py 2009-05-30 06:40:55 UTC (rev 6426) @@ -0,0 +1,2097 @@ +#! /usr/bin/env python + +"""Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.""" + +# Notes for authors of new mailbox subclasses: +# +# Remember to fsync() changes to disk before closing a modified file +# or returning from a flush() method. See functions _sync_flush() and +# _sync_close(). + +import sys +import os +import time +import calendar +import socket +import errno +import copy +import email +import email.Message +import email.Generator +import rfc822 +import StringIO +try: + if sys.platform == 'os2emx': + # OS/2 EMX fcntl() not adequate + raise ImportError + import fcntl +except ImportError: + fcntl = None + +__all__ = [ 'Mailbox', 'Maildir', 'mbox', 'MH', 'Babyl', 'MMDF', + 'Message', 'MaildirMessage', 'mboxMessage', 'MHMessage', + 'BabylMessage', 'MMDFMessage', 'UnixMailbox', + 'PortableUnixMailbox', 'MmdfMailbox', 'MHMailbox', 'BabylMailbox' ] + +class Mailbox: + """A group of messages in a particular place.""" + + def __init__(self, path, factory=None, create=True): + """Initialize a Mailbox instance.""" + self._path = os.path.abspath(os.path.expanduser(path)) + self._factory = factory + + def add(self, message): + """Add message and return assigned key.""" + raise NotImplementedError('Method must be implemented by subclass') + + def remove(self, key): + """Remove the keyed message; raise KeyError if it doesn't exist.""" + raise NotImplementedError('Method must be implemented by subclass') + + def __delitem__(self, key): + self.remove(key) + + def discard(self, key): + """If the keyed message exists, remove it.""" + try: + self.remove(key) + except KeyError: + pass + + def __setitem__(self, key, message): + """Replace the keyed message; raise KeyError if it doesn't exist.""" + raise NotImplementedError('Method must be implemented by subclass') + + def get(self, key, default=None): + """Return the keyed message, or default if it doesn't exist.""" + try: + return self.__getitem__(key) + except KeyError: + return default + + def __getitem__(self, key): + """Return the keyed message; raise KeyError if it doesn't exist.""" + if not self._factory: + return self.get_message(key) + else: + return self._factory(self.get_file(key)) + + def get_message(self, key): + """Return a Message representation or raise a KeyError.""" + raise NotImplementedError('Method must be implemented by subclass') + + def get_string(self, key): + """Return a string representation or raise a KeyError.""" + raise NotImplementedError('Method must be implemented by subclass') + + def get_file(self, key): + """Return a file-like representation or raise a KeyError.""" + raise NotImplementedError('Method must be implemented by subclass') + + def iterkeys(self): + """Return an iterator over keys.""" + raise NotImplementedError('Method must be implemented by subclass') + + def keys(self): + """Return a list of keys.""" + return list(self.iterkeys()) + + def itervalues(self): + """Return an iterator over all messages.""" + for key in self.iterkeys(): + try: + value = self[key] + except KeyError: + continue + yield value + + def __iter__(self): + return self.itervalues() + + def values(self): + """Return a list of messages. Memory intensive.""" + return list(self.itervalues()) + + def iteritems(self): + """Return an iterator over (key, message) tuples.""" + for key in self.iterkeys(): + try: + value = self[key] + except KeyError: + continue + yield (key, value) + + def items(self): + """Return a list of (key, message) tuples. Memory intensive.""" + return list(self.iteritems()) + + def has_key(self, key): + """Return True if the keyed message exists, False otherwise.""" + raise NotImplementedError('Method must be implemented by subclass') + + def __contains__(self, key): + return self.has_key(key) + + def __len__(self): + """Return a count of messages in the mailbox.""" + raise NotImplementedError('Method must be implemented by subclass') + + def clear(self): + """Delete all messages.""" + for key in self.iterkeys(): + self.discard(key) + + def pop(self, key, default=None): + """Delete the keyed message and return it, or default.""" + try: + result = self[key] + except KeyError: + return default + self.discard(key) + return result + + def popitem(self): + """Delete an arbitrary (key, message) pair and return it.""" + for key in self.iterkeys(): + return (key, self.pop(key)) # This is only run once. + else: + raise KeyError('No messages in mailbox') + + def update(self, arg=None): + """Change the messages that correspond to certain keys.""" + if hasattr(arg, 'iteritems'): + source = arg.iteritems() + elif hasattr(arg, 'items'): + source = arg.items() + else: + source = arg + bad_key = False + for key, message in source: + try: + self[key] = message + except KeyError: + bad_key = True + if bad_key: + raise KeyError('No message with key(s)') + + def flush(self): + """Write any pending changes to the disk.""" + raise NotImplementedError('Method must be implemented by subclass') + + def lock(self): + """Lock the mailbox.""" + raise NotImplementedError('Method must be implemented by subclass') + + def unlock(self): + """Unlock the mailbox if it is locked.""" + raise NotImplementedError('Method must be implemented by subclass') + + def close(self): + """Flush and close the mailbox.""" + raise NotImplementedError('Method must be implemented by subclass') + + def _dump_message(self, message, target, mangle_from_=False): + # Most files are opened in binary mode to allow predictable seeking. + # To get native line endings on disk, the user-friendly \n line endings + # used in strings and by email.Message are translated here. + """Dump message contents to target file.""" + if isinstance(message, email.Message.Message): + buffer = StringIO.StringIO() + gen = email.Generator.Generator(buffer, mangle_from_, 0) + gen.flatten(message) + buffer.seek(0) + target.write(buffer.read().replace('\n', os.linesep)) + elif isinstance(message, str): + if mangle_from_: + message = message.replace('\nFrom ', '\n>From ') + message = message.replace('\n', os.linesep) + target.write(message) + elif hasattr(message, 'read'): + while True: + line = message.readline() + if line == '': + break + if mangle_from_ and line.startswith('From '): + line = '>From ' + line[5:] + line = line.replace('\n', os.linesep) + target.write(line) + else: + raise TypeError('Invalid message type: %s' % type(message)) + + +class Maildir(Mailbox): + """A qmail-style Maildir mailbox.""" + + colon = ':' + + def __init__(self, dirname, factory=rfc822.Message, create=True): + """Initialize a Maildir instance.""" + Mailbox.__init__(self, dirname, factory, create) + if not os.path.exists(self._path): + if create: + os.mkdir(self._path, 0700) + os.mkdir(os.path.join(self._path, 'tmp'), 0700) + os.mkdir(os.path.join(self._path, 'new'), 0700) + os.mkdir(os.path.join(self._path, 'cur'), 0700) + else: + raise NoSuchMailboxError(self._path) + self._toc = {} + + def add(self, message): + """Add message and return assigned key.""" + tmp_file = self._create_tmp() + try: + self._dump_message(message, tmp_file) + finally: + _sync_close(tmp_file) + if isinstance(message, MaildirMessage): + subdir = message.get_subdir() + suffix = self.colon + message.get_info() + if suffix == self.colon: + suffix = '' + else: + subdir = 'new' + suffix = '' + uniq = os.path.basename(tmp_file.name).split(self.colon)[0] + dest = os.path.join(self._path, subdir, uniq + suffix) + try: + if hasattr(os, 'link'): + os.link(tmp_file.name, dest) + os.remove(tmp_file.name) + else: + os.rename(tmp_file.name, dest) + except OSError, e: + os.remove(tmp_file.name) + if e.errno == errno.EEXIST: + raise ExternalClashError('Name clash with existing message: %s' + % dest) + else: + raise + if isinstance(message, MaildirMessage): + os.utime(dest, (os.path.getatime(dest), message.get_date())) + return uniq + + def remove(self, key): + """Remove the keyed message; raise KeyError if it doesn't exist.""" + os.remove(os.path.join(self._path, self._lookup(key))) + + def discard(self, key): + """If the keyed message exists, remove it.""" + # This overrides an inapplicable implementation in the superclass. + try: + self.remove(key) + except KeyError: + pass + except OSError, e: + if e.errno != errno.ENOENT: + raise + + def __setitem__(self, key, message): + """Replace the keyed message; raise KeyError if it doesn't exist.""" + old_subpath = self._lookup(key) + temp_key = self.add(message) + temp_subpath = self._lookup(temp_key) + if isinstance(message, MaildirMessage): + # temp's subdir and suffix were specified by message. + dominant_subpath = temp_subpath + else: + # temp's subdir and suffix were defaults from add(). + dominant_subpath = old_subpath + subdir = os.path.dirname(dominant_subpath) + if self.colon in dominant_subpath: + suffix = self.colon + dominant_subpath.split(self.colon)[-1] + else: + suffix = '' + self.discard(key) + new_path = os.path.join(self._path, subdir, key + suffix) + os.rename(os.path.join(self._path, temp_subpath), new_path) + if isinstance(message, MaildirMessage): + os.utime(new_path, (os.path.getatime(new_path), + message.get_date())) + + def get_message(self, key): + """Return a Message representation or raise a KeyError.""" + subpath = self._lookup(key) + f = open(os.path.join(self._path, subpath), 'r') + try: + if self._factory: + msg = self._factory(f) + else: + msg = MaildirMessage(f) + finally: + f.close() + subdir, name = os.path.split(subpath) + msg.set_subdir(subdir) + if self.colon in name: + msg.set_info(name.split(self.colon)[-1]) + msg.set_date(os.path.getmtime(os.path.join(self._path, subpath))) + return msg + + def get_string(self, key): + """Return a string representation or raise a KeyError.""" + f = open(os.path.join(self._path, self._lookup(key)), 'r') + try: + return f.read() + finally: + f.close() + + def get_file(self, key): + """Return a file-like representation or raise a KeyError.""" + f = open(os.path.join(self._path, self._lookup(key)), 'rb') + return _ProxyFile(f) + + def iterkeys(self): + """Return an iterator over keys.""" + self._refresh() + for key in self._toc: + try: + self._lookup(key) + except KeyError: + continue + yield key + + def has_key(self, key): + """Return True if the keyed message exists, False otherwise.""" + self._refresh() + return key in self._toc + + def __len__(self): + """Return a count of messages in the mailbox.""" + self._refresh() + return len(self._toc) + + def flush(self): + """Write any pending changes to disk.""" + return # Maildir changes are always written immediately. + + def lock(self): + """Lock the mailbox.""" + return + + def unlock(self): + """Unlock the mailbox if it is locked.""" + return + + def close(self): + """Flush and close the mailbox.""" + return + + def list_folders(self): + """Return a list of folder names.""" + result = [] + for entry in os.listdir(self._path): + if len(entry) > 1 and entry[0] == '.' and \ + os.path.isdir(os.path.join(self._path, entry)): + result.append(entry[1:]) + return result + + def get_folder(self, folder): + """Return a Maildir instance for the named folder.""" + return Maildir(os.path.join(self._path, '.' + folder), + factory=self._factory, + create=False) + + def add_folder(self, folder): + """Create a folder and return a Maildir instance representing it.""" + path = os.path.join(self._path, '.' + folder) + result = Maildir(path, factory=self._factory) + maildirfolder_path = os.path.join(path, 'maildirfolder') + if not os.path.exists(maildirfolder_path): + os.close(os.open(maildirfolder_path, os.O_CREAT | os.O_WRONLY)) + return result + + def remove_folder(self, folder): + """Delete the named folder, which must be empty.""" + path = os.path.join(self._path, '.' + folder) + for entry in os.listdir(os.path.join(path, 'new')) + \ + os.listdir(os.path.join(path, 'cur')): + if len(entry) < 1 or entry[0] != '.': + raise NotEmptyError('Folder contains message(s): %s' % folder) + for entry in os.listdir(path): + if entry != 'new' and entry != 'cur' and entry != 'tmp' and \ + os.path.isdir(os.path.join(path, entry)): + raise NotEmptyError("Folder contains subdirectory '%s': %s" % + (folder, entry)) + for root, dirs, files in os.walk(path, topdown=False): + for entry in files: + os.remove(os.path.join(root, entry)) + for entry in dirs: + os.rmdir(os.path.join(root, entry)) + os.rmdir(path) + + def clean(self): + """Delete old files in "tmp".""" + now = time.time() + for entry in os.listdir(os.path.join(self._path, 'tmp')): + path = os.path.join(self._path, 'tmp', entry) + if now - os.path.getatime(path) > 129600: # 60 * 60 * 36 + os.remove(path) + + _count = 1 # This is used to generate unique file names. + + def _create_tmp(self): + """Create a file in the tmp subdirectory and open and return it.""" + now = time.time() + hostname = socket.gethostname() + if '/' in hostname: + hostname = hostname.replace('/', r'\057') + if ':' in hostname: + hostname = hostname.replace(':', r'\072') + uniq = "%s.M%sP%sQ%s.%s" % (int(now), int(now % 1 * 1e6), os.getpid(), + Maildir._count, hostname) + path = os.path.join(self._path, 'tmp', uniq) + try: + os.stat(path) + except OSError, e: + if e.errno == errno.ENOENT: + Maildir._count += 1 + try: + return _create_carefully(path) + except OSError, e: + if e.errno != errno.EEXIST: + raise + else: + raise + + # Fall through to here if stat succeeded or open raised EEXIST. + raise ExternalClashError('Name clash prevented file creation: %s' % + path) + + def _refresh(self): + """Update table of contents mapping.""" + self._toc = {} + for subdir in ('new', 'cur'): + subdir_path = os.path.join(self._path, subdir) + for entry in os.listdir(subdir_path): + p = os.path.join(subdir_path, entry) + if os.path.isdir(p): + continue + uniq = entry.split(self.colon)[0] + self._toc[uniq] = os.path.join(subdir, entry) + + def _lookup(self, key): + """Use TOC to return subpath for given key, or raise a KeyError.""" + try: + if os.path.exists(os.path.join(self._path, self._toc[key])): + return self._toc[key] + except KeyError: + pass + self._refresh() + try: + return self._toc[key] + except KeyError: + raise KeyError('No message with key: %s' % key) + + # This method is for backward compatibility only. + def next(self): + """Return the next message in a one-time iteration.""" + if not hasattr(self, '_onetime_keys'): + self._onetime_keys = self.iterkeys() + while True: + try: + return self[self._onetime_keys.next()] + except StopIteration: + return None + except KeyError: + continue + + +class _singlefileMailbox(Mailbox): + """A single-file mailbox.""" + + def __init__(self, path, factory=None, create=True): + """Initialize a single-file mailbox.""" + Mailbox.__init__(self, path, factory, create) + try: + f = open(self._path, 'rb+') + except IOError, e: + if e.errno == errno.ENOENT: + if create: + f = open(self._path, 'wb+') + else: + raise NoSuchMailboxError(self._path) + elif e.errno == errno.EACCES: + f = open(self._path, 'rb') + else: + raise + self._file = f + self._toc = None + self._next_key = 0 + self._pending = False # No changes require rewriting the file. + self._locked = False + + def add(self, message): + """Add message and return assigned key.""" + self._lookup() + self._toc[self._next_key] = self._append_message(message) + self._next_key += 1 + self._pending = True + return self._next_key - 1 + + def remove(self, key): + """Remove the keyed message; raise KeyError if it doesn't exist.""" + self._lookup(key) + del self._toc[key] + self._pending = True + + def __setitem__(self, key, message): + """Replace the keyed message; raise KeyError if it doesn't exist.""" + self._lookup(key) + self._toc[key] = self._append_message(message) + self._pending = True + + def iterkeys(self): + """Return an iterator over keys.""" + self._lookup() + for key in self._toc.keys(): + yield key + + def has_key(self, key): + """Return True if the keyed message exists, False otherwise.""" + self._lookup() + return key in self._toc + + def __len__(self): + """Return a count of messages in the mailbox.""" + self._lookup() + return len(self._toc) + + def lock(self): + """Lock the mailbox.""" + if not self._locked: + _lock_file(self._file) + self._locked = True + + def unlock(self): + """Unlock the mailbox if it is locked.""" + if self._locked: + _unlock_file(self._file) + self._locked = False + + def flush(self): + """Write any pending changes to disk.""" + if not self._pending: + return + self._lookup() + new_file = _create_temporary(self._path) + try: + new_toc = {} + self._pre_mailbox_hook(new_file) + for key in sorted(self._toc.keys()): + start, stop = self._toc[key] + self._file.seek(start) + self._pre_message_hook(new_file) + new_start = new_file.tell() + while True: + buffer = self._file.read(min(4096, + stop - self._file.tell())) + if buffer == '': + break + new_file.write(buffer) + new_toc[key] = (new_start, new_file.tell()) + self._post_message_hook(new_file) + except: + new_file.close() + os.remove(new_file.name) + raise + _sync_close(new_file) + # self._file is about to get replaced, so no need to sync. + self._file.close() + try: + os.rename(new_file.name, self._path) + except OSError, e: + if e.errno == errno.EEXIST or \ + (os.name == 'os2' and e.errno == errno.EACCES): + os.remove(self._path) + os.rename(new_file.name, self._path) + else: + raise + self._file = open(self._path, 'rb+') + self._toc = new_toc + self._pending = False + if self._locked: + _lock_file(self._file, dotlock=False) + + def _pre_mailbox_hook(self, f): + """Called before writing the mailbox to file f.""" + return + + def _pre_message_hook(self, f): + """Called before writing each message to file f.""" + return + + def _post_message_hook(self, f): + """Called after writing each message to file f.""" + return + + def close(self): + """Flush and close the mailbox.""" + self.flush() + if self._locked: + self.unlock() + self._file.close() # Sync has been done by self.flush() above. + + def _lookup(self, key=None): + """Return (start, stop) or raise KeyError.""" + if self._toc is None: + self._generate_toc() + if key is not None: + try: + return self._toc[key] + except KeyError: + raise KeyError('No message with key: %s' % key) + + def _append_message(self, message): + """Append message to mailbox and return (start, stop) offsets.""" + self._file.seek(0, 2) + self._pre_message_hook(self._file) + offsets = self._install_message(message) + self._post_message_hook(self._file) + self._file.flush() + return offsets + + + +class _mboxMMDF(_singlefileMailbox): + """An mbox or MMDF mailbox.""" + + _mangle_from_ = True + + def get_message(self, key): + """Return a Message representation or raise a KeyError.""" + start, stop = self._lookup(key) + self._file.seek(start) + from_line = self._file.readline().replace(os.linesep, '') + string = self._file.read(stop - self._file.tell()) + msg = self._message_factory(string.replace(os.linesep, '\n')) + msg.set_from(from_line[5:]) + return msg + + def get_string(self, key, from_=False): + """Return a string representation or raise a KeyError.""" + start, stop = self._lookup(key) + self._file.seek(start) + if not from_: + self._file.readline() + string = self._file.read(stop - self._file.tell()) + return string.replace(os.linesep, '\n') + + def get_file(self, key, from_=False): + """Return a file-like representation or raise a KeyError.""" + start, stop = self._lookup(key) + self._file.seek(start) + if not from_: + self._file.readline() + return _PartialFile(self._file, self._file.tell(), stop) + + def _install_message(self, message): + """Format a message and blindly write to self._file.""" + from_line = None + if isinstance(message, str) and message.startswith('From '): + newline = message.find('\n') + if newline != -1: + from_line = message[:newline] + message = message[newline + 1:] + else: + from_line = message + message = '' + elif isinstance(message, _mboxMMDFMessage): + from_line = 'From ' + message.get_from() + elif isinstance(message, email.Message.Message): + from_line = message.get_unixfrom() # May be None. + if from_line is None: + from_line = 'From MAILER-DAEMON %s' % time.asctime(time.gmtime()) + start = self._file.tell() + self._file.write(from_line + os.linesep) + self._dump_message(message, self._file, self._mangle_from_) + stop = self._file.tell() + return (start, stop) + + +class mbox(_mboxMMDF): + """A classic mbox mailbox.""" + + _mangle_from_ = True + + def __init__(self, path, factory=None, create=True): + """Initialize an mbox mailbox.""" + self._message_factory = mboxMessage + _mboxMMDF.__init__(self, path, factory, create) + + def _pre_message_hook(self, f): + """Called before writing each message to file f.""" + if f.tell() != 0: + f.write(os.linesep) + + def _generate_toc(self): + """Generate key-to-(start, stop) table of contents.""" + starts, stops = [], [] + self._file.seek(0) + while True: + line_pos = self._file.tell() + line = self._file.readline() + if line.startswith('From '): + if len(stops) < len(starts): + stops.append(line_pos - len(os.linesep)) + starts.append(line_pos) + elif line == '': + stops.append(line_pos) + break + self._toc = dict(enumerate(zip(starts, stops))) + self._next_key = len(self._toc) + + +class MMDF(_mboxMMDF): + """An MMDF mailbox.""" + + def __init__(self, path, factory=None, create=True): + """Initialize an MMDF mailbox.""" + self._message_factory = MMDFMessage + _mboxMMDF.__init__(self, path, factory, create) + + def _pre_message_hook(self, f): + """Called before writing each message to file f.""" + f.write('\001\001\001\001' + os.linesep) + + def _post_message_hook(self, f): + """Called after writing each message to file f.""" + f.write(os.linesep + '\001\001\001\001' + os.linesep) + + def _generate_toc(self): + """Generate key-to-(start, stop) table of contents.""" + starts, stops = [], [] + self._file.seek(0) + next_pos = 0 + while True: + line_pos = next_pos + line = self._file.readline() + next_pos = self._file.tell() + if line.startswith('\001\001\001\001' + os.linesep): + starts.append(next_pos) + while True: + line_pos = next_pos + line = self._file.readline() + next_pos = self._file.tell() + if line == '\001\001\001\001' + os.linesep: + stops.append(line_pos - len(os.linesep)) + break + elif line == '': + stops.append(line_pos) + break + elif line == '': + break + self._toc = dict(enumerate(zip(starts, stops))) + self._next_key = len(self._toc) + + +class MH(Mailbox): + """An MH mailbox.""" + + def __init__(self, path, factory=None, create=True): + """Initialize an MH instance.""" + Mailbox.__init__(self, path, factory, create) + if not os.path.exists(self._path): + if create: + os.mkdir(self._path, 0700) + os.close(os.open(os.path.join(self._path, '.mh_sequences'), + os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0600)) + else: + raise NoSuchMailboxError(self._path) + self._locked = False + + def add(self, message): + """Add message and return assigned key.""" + keys = self.keys() + if len(keys) == 0: + new_key = 1 + else: + new_key = max(keys) + 1 + new_path = os.path.join(self._path, str(new_key)) + f = _create_carefully(new_path) + try: + if self._locked: + _lock_file(f) + try: + self._dump_message(message, f) + if isinstance(message, MHMessage): + self._dump_sequences(message, new_key) + finally: + if self._locked: + _unlock_file(f) + finally: + _sync_close(f) + return new_key + + def remove(self, key): + """Remove the keyed message; raise KeyError if it doesn't exist.""" + path = os.path.join(self._path, str(key)) + try: + f = open(path, 'rb+') + except IOError, e: + if e.errno == errno.ENOENT: + raise KeyError('No message with key: %s' % key) + else: + raise + try: + if self._locked: + _lock_file(f) + try: + f.close() + os.remove(os.path.join(self._path, str(key))) + finally: + if self._locked: + _unlock_file(f) + finally: + f.close() + + def __setitem__(self, key, message): + """Replace the keyed message; raise KeyError if it doesn't exist.""" + path = os.path.join(self._path, str(key)) + try: + f = open(path, 'rb+') + except IOError, e: + if e.errno == errno.ENOENT: + raise KeyError('No message with key: %s' % key) + else: + raise + try: + if self._locked: + _lock_file(f) + try: + os.close(os.open(path, os.O_WRONLY | os.O_TRUNC)) + self._dump_message(message, f) + if isinstance(message, MHMessage): + self._dump_sequences(message, key) + finally: + if self._locked: + _unlock_file(f) + finally: + _sync_close(f) + + def get_message(self, key): + """Return a Message representation or raise a KeyError.""" + try: + if self._locked: + f = open(os.path.join(self._path, str(key)), 'r+') + else: + f = open(os.path.join(self._path, str(key)), 'r') + except IOError, e: + if e.errno == errno.ENOENT: + raise KeyError('No message with key: %s' % key) + else: + raise + try: + if self._locked: + _lock_file(f) + try: + msg = MHMessage(f) + finally: + if self._locked: + _unlock_file(f) + finally: + f.close() + for name, key_list in self.get_sequences(): + if key in key_list: + msg.add_sequence(name) + return msg + + def get_string(self, key): + """Return a string representation or raise a KeyError.""" + try: + if self._locked: + f = open(os.path.join(self._path, str(key)), 'r+') + else: + f = open(os.path.join(self._path, str(key)), 'r') + except IOError, e: + if e.errno == errno.ENOENT: + raise KeyError('No message with key: %s' % key) + else: + raise + try: + if self._locked: + _lock_file(f) + try: + return f.read() + finally: + if self._locked: + _unlock_file(f) + finally: + f.close() + + def get_file(self, key): + """Return a file-like representation or raise a KeyError.""" + try: + f = open(os.path.join(self._path, str(key)), 'rb') + except IOError, e: + if e.errno == errno.ENOENT: + raise KeyError('No message with key: %s' % key) + else: + raise + return _ProxyFile(f) + + def iterkeys(self): + """Return an iterator over keys.""" + return iter(sorted(int(entry) for entry in os.listdir(self._path) + if entry.isdigit())) + + def has_key(self, key): + """Return True if the keyed message exists, False otherwise.""" + return os.path.exists(os.path.join(self._path, str(key))) + + def __len__(self): + """Return a count of messages in the mailbox.""" + return len(list(self.iterkeys())) + + def lock(self): + """Lock the mailbox.""" + if not self._locked: + self._file = open(os.path.join(self._path, '.mh_sequences'), 'rb+') + _lock_file(self._file) + self._locked = True + + def unlock(self): + """Unlock the mailbox if it is locked.""" + if self._locked: + _unlock_file(self._file) + _sync_close(self._file) + del self._file + self._locked = False + + def flush(self): + """Write any pending changes to the disk.""" + return + + def close(self): + """Flush and close the mailbox.""" + if self._locked: + self.unlock() + + def list_folders(self): + """Return a list of folder names.""" + result = [] + for entry in os.listdir(self._path): + if os.path.isdir(os.path.join(self._path, entry)): + result.append(entry) + return result + + def get_folder(self, folder): + """Return an MH instance for the named folder.""" + return MH(os.path.join(self._path, folder), + factory=self._factory, create=False) + + def add_folder(self, folder): + """Create a folder and return an MH instance representing it.""" + return MH(os.path.join(self._path, folder), + factory=self._factory) + + def remove_folder(self, folder): + """Delete the named folder, which must be empty.""" + path = os.path.join(self._path, folder) + entries = os.listdir(path) + if entries == ['.mh_sequences']: + os.remove(os.path.join(path, '.mh_sequences')) + elif entries == []: + pass + else: + raise NotEmptyError('Folder not empty: %s' % self._path) + os.rmdir(path) + + def get_sequences(self): + """Return a name-to-key-list dictionary to define each sequence.""" + results = {} + f = open(os.path.join(self._path, '.mh_sequences'), 'r') + try: + all_keys = set(self.keys()) + for line in f: + try: + name, contents = line.split(':') + keys = set() + for spec in contents.split(): + if spec.isdigit(): + keys.add(int(spec)) + else: + start, stop = (int(x) for x in spec.split('-')) + keys.update(range(start, stop + 1)) + results[name] = [key for key in sorted(keys) \ + if key in all_keys] + if len(results[name]) == 0: + del results[name] + except ValueError: + raise FormatError('Invalid sequence specification: %s' % + line.rstrip()) + finally: + f.close() + return results + + def set_sequences(self, sequences): + """Set sequences using the given name-to-key-list dictionary.""" + f = open(os.path.join(self._path, '.mh_sequences'), 'r+') + try: + os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC)) + for name, keys in sequences.iteritems(): + if len(keys) == 0: + continue + f.write('%s:' % name) + prev = None + completing = False + for key in sorted(set(keys)): + if key - 1 == prev: + if not completing: + completing = True + f.write('-') + elif completing: + completing = False + f.write('%s %s' % (prev, key)) + else: + f.write(' %s' % key) + prev = key + if completing: + f.write(str(prev) + '\n') + else: + f.write('\n') + finally: + _sync_close(f) + + def pack(self): + """Re-name messages to eliminate numbering gaps. Invalidates keys.""" + sequences = self.get_sequences() + prev = 0 + changes = [] + for key in self.iterkeys(): + if key - 1 != prev: + changes.append((key, prev + 1)) + if hasattr(os, 'link'): + os.link(os.path.join(self._path, str(key)), + os.path.join(self._path, str(prev + 1))) + os.unlink(os.path.join(self._path, str(key))) + else: + os.rename(os.path.join(self._path, str(key)), + os.path.join(self._path, str(prev + 1))) + prev += 1 + self._next_key = prev + 1 + if len(changes) == 0: + return + for name, key_list in sequences.items(): + for old, new in changes: + if old in key_list: + key_list[key_list.index(old)] = new + self.set_sequences(sequences) + + def _dump_sequences(self, message, key): + """Inspect a new MHMessage and update sequences appropriately.""" + pending_sequences = message.get_sequences() + all_sequences = self.get_sequences() + for name, key_list in all_sequences.iteritems(): + if name in pending_sequences: + key_list.append(key) + elif key in key_list: + del key_list[key_list.index(key)] + for sequence in pending_sequences: + if sequence not in all_sequences: + all_sequences[sequence] = [key] + self.set_sequences(all_sequences) + + +class Babyl(_singlefileMailbox): + """An Rmail-style Babyl mailbox.""" + + _special_labels = frozenset(('unseen', 'deleted', 'filed', 'answered', + 'forwarded', 'edited', 'resent')) + + def __init__(self, path, factory=None, create=True): + """Initialize a Babyl mailbox.""" + _singlefileMailbox.__init__(self, path, factory, create) + self._labels = {} + + def add(self, message): + """Add message and return assigned key.""" + key = _singlefileMailbox.add(self, message) + if isinstance(message, BabylMessage): + self._labels[key] = message.get_labels() + return key + + def remove(self, key): + """Remove the keyed message; raise KeyError if it doesn't exist.""" + _singlefileMailbox.remove(self, key) + if key in self._labels: + del self._labels[key] + + def __setitem__(self, key, message): + """Replace the keyed message; raise KeyError if it doesn't exist.""" + _singlefileMailbox.__setitem__(self, key, message) + if isinstance(message, BabylMessage): + self._labels[key] = message.get_labels() + + def get_message(self, key): + """Return a Message representation or raise a KeyError.""" + start, stop = self._lookup(key) + self._file.seek(start) + self._file.readline() # Skip '1,' line specifying labels. + original_headers = StringIO.StringIO() + while True: + line = self._file.readline() + if line == '*** EOOH ***' + os.linesep or line == '': + break + original_headers.write(line.replace(os.linesep, '\n')) + visible_headers = StringIO.StringIO() + while True: + line = self._file.readline() + if line == os.linesep or line == '': + break + visible_headers.write(line.replace(os.linesep, '\n')) + body = self._file.read(stop - self._file.tell()).replace(os.linesep, + '\n') + msg = BabylMessage(original_headers.getvalue() + body) + msg.set_visible(visible_headers.getvalue()) + if key in self._labels: + msg.set_labels(self._labels[key]) + return msg + + def get_string(self, key): + """Return a string representation or raise a KeyError.""" + start, stop = self._lookup(key) + self._file.seek(start) + self._file.readline() # Skip '1,' line specifying labels. + original_headers = StringIO.StringIO() + while True: + line = self._file.readline() + if line == '*** EOOH ***' + os.linesep or line == '': + break + original_headers.write(line.replace(os.linesep, '\n')) + while True: + line = self._file.readline() + if line == os.linesep or line == '': + break + return original_headers.getvalue() + \ + self._file.read(stop - self._file.tell()).replace(os.linesep, + '\n') + + def get_file(self, key): + """Return a file-like representation or raise a KeyError.""" + return StringIO.StringIO(self.get_string(key).replace('\n', + os.linesep)) + + def get_labels(self): + """Return a list of user-defined labels in the mailbox.""" + self._lookup() + labels = set() + for label_list in self._labels.values(): + labels.update(label_list) + labels.difference_update(self._special_labels) + return list(labels) + + def _generate_toc(self): + """Generate key-to-(start, stop) table of contents.""" + starts, stops = [], [] + self._file.seek(0) + next_pos = 0 + label_lists = [] + while True: + line_pos = next_pos + line = self._file.readline() + next_pos = self._file.tell() + if line == '\037\014' + os.linesep: + if len(stops) < len(starts): + stops.append(line_pos - len(os.linesep)) + starts.append(next_pos) + labels = [label.strip() for label + in self._file.readline()[1:].split(',') + if label.strip() != ''] + label_lists.append(labels) + elif line == '\037' or line == '\037' + os.linesep: + if len(stops) < len(starts): + stops.append(line_pos - len(os.linesep)) + elif line == '': + stops.append(line_pos - len(os.linesep)) + break + self._toc = dict(enumerate(zip(starts, stops))) + self._labels = dict(enumerate(label_lists)) + self._next_key = len(self._toc) + + def _pre_mailbox_hook(self, f): + """Called before writing the mailbox to file f.""" + f.write('BABYL OPTIONS:%sVersion: 5%sLabels:%s%s\037' % + (os.linesep, os.linesep, ','.join(self.get_labels()), + os.linesep)) + + def _pre_message_hook(self, f): + """Called before writing each message to file f.""" + f.write('\014' + os.linesep) + + def _post_message_hook(self, f): + """Called after writing each message to file f.""" + f.write(os.linesep + '\037') + + def _install_message(self, message): + """Write message contents and return (start, stop).""" + start = self._file.tell() + if isinstance(message, BabylMessage): + special_labels = [] + labels = [] + for label in message.get_labels(): + if label in self._special_labels: + special_labels.append(label) + else: + labels.append(label) + self._file.write('1') + for label in special_labels: + self._file.write(', ' + label) + self._file.write(',,') + for label in labels: + self._file.write(' ' + label + ',') + self._file.write(os.linesep) + else: + self._file.write('1,,' + os.linesep) + if isinstance(message, email.Message.Message): + orig_buffer = StringIO.StringIO() + orig_generator = email.Generator.Generator(orig_buffer, False, 0) + orig_generator.flatten(message) + orig_buffer.seek(0) + while True: + line = orig_buffer.readline() + self._file.write(line.replace('\n', os.linesep)) + if line == '\n' or line == '': + break + self._file.write('*** EOOH ***' + os.linesep) + if isinstance(message, BabylMessage): + vis_buffer = StringIO.StringIO() + vis_generator = email.Generator.Generator(vis_buffer, False, 0) + vis_generator.flatten(message.get_visible()) + while True: + line = vis_buffer.readline() + self._file.write(line.replace('\n', os.linesep)) + if line == '\n' or line == '': + break + else: + orig_buffer.seek(0) + while True: + line = orig_buffer.readline() + self._file.write(line.replace('\n', os.linesep)) + if line == '\n' or line == '': + break + while True: + buffer = orig_buffer.read(4096) # Buffer size is arbitrary. + if buffer == '': + break + self._file.write(buffer.replace('\n', os.linesep)) + elif isinstance(message, str): + body_start = message.find('\n\n') + 2 + if body_start - 2 != -1: + self._file.write(message[:body_start].replace('\n', + os.linesep)) + self._file.write('*** EOOH ***' + os.linesep) + self._file.write(message[:body_start].replace('\n', + os.linesep)) + self._file.write(message[body_start:].replace('\n', + os.linesep)) + else: + self._file.write('*** EOOH ***' + os.linesep + os.linesep) + self._file.write(message.replace('\n', os.linesep)) + elif hasattr(message, 'readline'): + original_pos = message.tell() + first_pass = True + while True: + line = message.readline() + self._file.write(line.replace('\n', os.linesep)) + if line == '\n' or line == '': + self._file.write('*** EOOH ***' + os.linesep) + if first_pass: + first_pass = False + message.seek(original_pos) + else: + break + while True: + buffer = message.read(4096) # Buffer size is arbitrary. + if buffer == '': + break + self._file.write(buffer.replace('\n', os.linesep)) + else: + raise TypeError('Invalid message type: %s' % type(message)) + stop = self._file.tell() + return (start, stop) + + +class Message(email.Message.Message): + """Message with mailbox-format-specific properties.""" + + def __init__(self, message=None): + """Initialize a Message instance.""" + if isinstance(message, email.Message.Message): + self._become_message(copy.deepcopy(message)) + if isinstance(message, Message): + message._explain_to(self) + elif isinstance(message, str): + self._become_message(email.message_from_string(message)) + elif hasattr(message, "read"): + self._become_message(email.message_from_file(message)) + elif message is None: + email.Message.Message.__init__(self) + else: + raise TypeError('Invalid message type: %s' % type(message)) + + def _become_message(self, message): + """Assume the non-format-specific state of message.""" + for name in ('_headers', '_unixfrom', '_payload', '_charset', + 'preamble', 'epilogue', 'defects', '_default_type'): + self.__dict__[name] = message.__dict__[name] + + def _explain_to(self, message): + """Copy format-specific state to message insofar as possible.""" + if isinstance(message, Message): + return # There's nothing format-specific to explain. + else: + raise TypeError('Cannot convert to specified type') + + +class MaildirMessage(Message): + """Message with Maildir-specific properties.""" + + def __init__(self, message=None): + """Initialize a MaildirMessage instance.""" + self._subdir = 'new' + self._info = '' + self._date = time.time() + Message.__init__(self, message) + + def get_subdir(self): + """Return 'new' or 'cur'.""" + return self._subdir + + def set_subdir(self, subdir): + """Set subdir to 'new' or 'cur'.""" + if subdir == 'new' or subdir == 'cur': + self._subdir = subdir + else: + raise ValueError("subdir must be 'new' or 'cur': %s" % subdir) + + def get_flags(self): + """Return as a string the flags that are set.""" + if self._info.startswith('2,'): + return self._info[2:] + else: + return '' + + def set_flags(self, flags): + """Set the given flags and unset all others.""" + self._info = '2,' + ''.join(sorted(flags)) + + def add_flag(self, flag): + """Set the given flag(s) without changing others.""" + self.set_flags(''.join(set(self.get_flags()) | set(flag))) + + def remove_flag(self, flag): + """Unset the given string flag(s) without changing others.""" + if self.get_flags() != '': + self.set_flags(''.join(set(self.get_flags()) - set(flag))) + + def get_date(self): + """Return delivery date of message, in seconds since the epoch.""" + return self._date + + def set_date(self, date): + """Set delivery date of message, in seconds since the epoch.""" + try: + self._date = float(date) + except ValueError: + raise TypeError("can't convert to float: %s" % date) + + def get_info(self): + """Get the message's "info" as a string.""" + return self._info + + def set_info(self, info): + """Set the message's "info" string.""" + if isinstance(info, str): + self._info = info + else: + raise TypeError('info must be a string: %s' % type(info)) + + def _explain_to(self, message): + """Copy Maildir-specific state to message insofar as possible.""" + if isinstance(message, MaildirMessage): + message.set_flags(self.get_flags()) + message.set_subdir(self.get_subdir()) + message.set_date(self.get_date()) + elif isinstance(message, _mboxMMDFMessage): + flags = set(self.get_flags()) + if 'S' in flags: + message.add_flag('R') + if self.get_subdir() == 'cur': + message.add_flag('O') + if 'T' in flags: + message.add_flag('D') + if 'F' in flags: + message.add_flag('F') + if 'R' in flags: + message.add_flag('A') + message.set_from('MAILER-DAEMON', time.gmtime(self.get_date())) + elif isinstance(message, MHMessage): + flags = set(self.get_flags()) + if 'S' not in flags: + message.add_sequence('unseen') + if 'R' in flags: + message.add_sequence('replied') + if 'F' in flags: + message.add_sequence('flagged') + elif isinstance(message, BabylMessage): + flags = set(self.get_flags()) + if 'S' not in flags: + message.add_label('unseen') + if 'T' in flags: + message.add_label('deleted') + if 'R' in flags: + message.add_label('answered') + if 'P' in flags: + message.add_label('forwarded') + elif isinstance(message, Message): + pass + else: + raise TypeError('Cannot convert to specified type: %s' % + type(message)) + + +class _mboxMMDFMessage(Message): + """Message with mbox- or MMDF-specific properties.""" + + def __init__(self, message=None): + """Initialize an mboxMMDFMessage instance.""" + self.set_from('MAILER-DAEMON', True) + if isinstance(message, email.Message.Message): + unixfrom = message.get_unixfrom() + if unixfrom is not None and unixfrom.startswith('From '): + self.set_from(unixfrom[5:]) + Message.__init__(self, message) + + def get_from(self): + """Return contents of "From " line.""" + return self._from + + def set_from(self, from_, time_=None): + """Set "From " line, formatting and appending time_ if specified.""" + if time_ is not None: + if time_ is True: + time_ = time.gmtime() + from_ += ' ' + time.asctime(time_) + self._from = from_ + + def get_flags(self): + """Return as a string the flags that are set.""" + return self.get('Status', '') + self.get('X-Status', '') + + def set_flags(self, flags): + """Set the given flags and unset all others.""" + flags = set(flags) + status_flags, xstatus_flags = '', '' + for flag in ('R', 'O'): + if flag in flags: + status_flags += flag + flags.remove(flag) + for flag in ('D', 'F', 'A'): + if flag in flags: + xstatus_flags += flag + flags.remove(flag) + xstatus_flags += ''.join(sorted(flags)) + try: + self.replace_header('Status', status_flags) + except KeyError: + self.add_header('Status', status_flags) + try: + self.replace_header('X-Status', xstatus_flags) + except KeyError: + self.add_header('X-Status', xstatus_flags) + + def add_flag(self, flag): + """Set the given flag(s) without changing others.""" + self.set_flags(''.join(set(self.get_flags()) | set(flag))) + + def remove_flag(self, flag): + """Unset the given string flag(s) without changing others.""" + if 'Status' in self or 'X-Status' in self: + self.set_flags(''.join(set(self.get_flags()) - set(flag))) + + def _explain_to(self, message): + """Copy mbox- or MMDF-specific state to message insofar as possible.""" + if isinstance(message, MaildirMessage): + flags = set(self.get_flags()) + if 'O' in flags: + message.set_subdir('cur') + if 'F' in flags: + message.add_flag('F') + if 'A' in flags: + message.add_flag('R') + if 'R' in flags: + message.add_flag('S') + if 'D' in flags: + message.add_flag('T') + del message['status'] + del message['x-status'] + maybe_date = ' '.join(self.get_from().split()[-5:]) + try: + message.set_date(calendar.timegm(time.strptime(maybe_date, + '%a %b %d %H:%M:%S %Y'))) + except (ValueError, OverflowError): + pass + elif isinstance(message, _mboxMMDFMessage): + message.set_flags(self.get_flags()) + message.set_from(self.get_from()) + elif isinstance(message, MHMessage): + flags = set(self.get_flags()) + if 'R' not in flags: + message.add_sequence('unseen') + if 'A' in flags: + message.add_sequence('replied') + if 'F' in flags: + message.add_sequence('flagged') + del message['status'] + del message['x-status'] + elif isinstance(message, BabylMessage): + flags = set(self.get_flags()) + if 'R' not in flags: + message.add_label('unseen') + if 'D' in flags: + message.add_label('deleted') + if 'A' in flags: + message.add_label('answered') + del message['status'] + del message['x-status'] + elif isinstance(message, Message): + pass + else: + raise TypeError('Cannot convert to specified type: %s' % + type(message)) + + +class mboxMessage(_mboxMMDFMessage): + """Message with mbox-specific properties.""" + + +class MHMessage(Message): + """Message with MH-specific properties.""" + + def __init__(self, message=None): + """Initialize an MHMessage instance.""" + self._sequences = [] + Message.__init__(self, message) + + def get_sequences(self): + """Return a list of sequences that include the message.""" + return self._sequences[:] + + def set_sequences(self, sequences): + """Set the list of sequences that include the message.""" + self._sequences = list(sequences) + + def add_sequence(self, sequence): + """Add sequence to list of sequences including the message.""" + if isinstance(sequence, str): + if not sequence in self._sequences: + self._sequences.append(sequence) + else: + raise TypeError('sequence must be a string: %s' % type(sequence)) + + def remove_sequence(self, sequence): + """Remove sequence from the list of sequences including the message.""" + try: + self._sequences.remove(sequence) + except ValueError: + pass + + def _explain_to(self, message): + """Copy MH-specific state to message insofar as possible.""" + i... [truncated message content] |
From: <pj...@us...> - 2009-05-30 06:03:09
|
Revision: 6425 http://jython.svn.sourceforge.net/jython/?rev=6425&view=rev Author: pjenvey Date: 2009-05-30 06:00:25 +0000 (Sat, 30 May 2009) Log Message: ----------- quiet some warnings and remove a couple unused things Modified Paths: -------------- trunk/jython/src/org/python/core/JavaImportHelper.java trunk/jython/src/org/python/core/Py.java trunk/jython/src/org/python/core/PyArray.java trunk/jython/src/org/python/core/ReflectedArgs.java trunk/jython/src/org/python/core/codecs.java Modified: trunk/jython/src/org/python/core/JavaImportHelper.java =================================================================== --- trunk/jython/src/org/python/core/JavaImportHelper.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/JavaImportHelper.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -36,10 +36,8 @@ // check explicit imports first (performance optimization) // handle 'from java.net import URL' like explicit imports - List stringFromlist = getFromListAsStrings(fromlist); - Iterator fromlistIterator = stringFromlist.iterator(); - while (fromlistIterator.hasNext()) { - String fromName = (String) fromlistIterator.next(); + List<String> stringFromlist = getFromListAsStrings(fromlist); + for (String fromName : stringFromlist) { if (isJavaClass(packageName, fromName)) { packageAdded = addPackage(packageName, packageAdded); @@ -59,7 +57,7 @@ // if all else fails, check already loaded packages if (!packageAdded) { // build the actual map with the packages known to the VM - Map packages = buildLoadedPackages(); + Map<String, String> packages = buildLoadedPackages(); // add known packages String parentPackageName = packageName; @@ -78,9 +76,7 @@ } while (dotPos > 0); // handle package imports like 'from java import math' - fromlistIterator = stringFromlist.iterator(); - while (fromlistIterator.hasNext()) { - String fromName = (String) fromlistIterator.next(); + for (String fromName : stringFromlist) { String fromPackageName = packageName + DOT + fromName; if (isLoadedPackage(fromPackageName, packages)) { packageAdded = addPackage(fromPackageName, packageAdded); @@ -113,8 +109,8 @@ * @param fromlist * @return a list containing java.lang.String entries */ - private static final List getFromListAsStrings(PyObject fromlist) { - List stringFromlist = new ArrayList(); + private static final List<String> getFromListAsStrings(PyObject fromlist) { + List<String> stringFromlist = new ArrayList<String>(); if (fromlist != null && fromlist != Py.EmptyTuple && fromlist instanceof PyTuple) { Iterator iterator = ((PyTuple) fromlist).iterator(); @@ -146,7 +142,7 @@ * @return <code>true</code> if the package with the given name is already loaded by the VM, <code>false</code> * otherwise. */ - private static boolean isLoadedPackage(String javaPackageName, Map packages) { + private static boolean isLoadedPackage(String javaPackageName, Map<String, String> packages) { boolean isLoaded = false; if (javaPackageName != null) { isLoaded = packages.containsKey(javaPackageName); @@ -160,8 +156,8 @@ * All parent packages appear as single entries like python modules, e.g. <code>java</code>, * <code>java.lang</code>, <code>java.lang.reflect</code>, */ - private static Map buildLoadedPackages() { - TreeMap packageMap = new TreeMap(); + private static Map<String, String> buildLoadedPackages() { + TreeMap<String, String> packageMap = new TreeMap<String, String>(); Package[] packages = Package.getPackages(); for (int i = 0; i < packages.length; i++) { String packageName = packages[i].getName(); Modified: trunk/jython/src/org/python/core/Py.java =================================================================== --- trunk/jython/src/org/python/core/Py.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/Py.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -13,6 +13,7 @@ import java.io.Serializable; import java.io.StreamCorruptedException; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; @@ -23,7 +24,6 @@ import com.kenai.constantine.platform.Errno; import java.util.ArrayList; import java.util.List; -import org.python.compiler.Module; import org.python.core.adapter.ClassicPyObjectAdapter; import org.python.core.adapter.ExtensiblePyObjectAdapter; import org.python.util.Generic; @@ -481,7 +481,7 @@ // ??pending: was @deprecated but is actually used by proxie code. // Can get rid of it? public static Object tojava(PyObject o, String s) { - Class c = findClass(s); + Class<?> c = findClass(s); if (c == null) { throw Py.TypeError("can't convert to: " + s); } @@ -663,15 +663,13 @@ funcs, func_id); } - public static PyCode newJavaCode(Class cls, String name) { + public static PyCode newJavaCode(Class<?> cls, String name) { return new JavaCode(newJavaFunc(cls, name)); } - public static PyObject newJavaFunc(Class cls, String name) { + public static PyObject newJavaFunc(Class<?> cls, String name) { try { - java.lang.reflect.Method m = cls.getMethod(name, new Class[]{ - PyObject[].class, String[].class - }); + Method m = cls.getMethod(name, new Class<?>[]{PyObject[].class, String[].class}); return new JavaFunc(m); } catch (NoSuchMethodException e) { throw Py.JavaError(e); @@ -1510,10 +1508,6 @@ */ private static ExtensiblePyObjectAdapter adapter; - private static Class[] pyClassCtrSignature = { - String.class, PyTuple.class, PyObject.class, Class.class - }; - // XXX: The following two makeClass overrides are *only* for the // old compiler, they should be removed when the newcompiler hits public static PyObject makeClass(String name, PyObject[] bases, @@ -1939,6 +1933,7 @@ } } + @Override protected PyObject myFile() { return file; } @@ -1958,6 +1953,7 @@ } } + @Override public PyObject call(ThreadState state, PyFrame frame, PyObject closure) { //XXX: what the heck is this? Looks like debug code, but it's // been here a long time... @@ -1965,39 +1961,46 @@ return Py.None; } + @Override public PyObject call(ThreadState state, PyObject args[], String keywords[], PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(args, keywords); } + @Override public PyObject call(ThreadState state, PyObject self, PyObject args[], String keywords[], PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(self, args, keywords); } + @Override public PyObject call(ThreadState state, PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(); } + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(arg1); } + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject arg2, PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(arg1, arg2); } + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject arg2, PyObject arg3, PyObject globals, PyObject[] defaults, PyObject closure) { return func.__call__(arg1, arg2, arg3); } + @Override public PyObject call(ThreadState state, PyObject arg1, PyObject arg2, PyObject arg3, PyObject arg4, PyObject globals, PyObject[] defaults, PyObject closure) { @@ -2011,12 +2014,13 @@ */ class JavaFunc extends PyObject { - java.lang.reflect.Method method; + Method method; - public JavaFunc(java.lang.reflect.Method method) { + public JavaFunc(Method method) { this.method = method; } + @Override public PyObject __call__(PyObject[] args, String[] kws) { Object[] margs = new Object[]{args, kws}; try { @@ -2026,10 +2030,12 @@ } } + @Override public PyObject _doget(PyObject container) { return _doget(container, null); } + @Override public PyObject _doget(PyObject container, PyObject wherefound) { if (container == null) { return this; Modified: trunk/jython/src/org/python/core/PyArray.java =================================================================== --- trunk/jython/src/org/python/core/PyArray.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/PyArray.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -36,7 +36,7 @@ private Object data; /** The Java array class. */ - private Class type; + private Class<?> type; /** The Python style typecode of the array. */ private String typecode; @@ -47,12 +47,12 @@ super(type); } - public PyArray(Class type, Object data) { + public PyArray(Class<?> type, Object data) { this(TYPE); setup(type, data); } - public PyArray(Class type, int n) { + public PyArray(Class<?> type, int n) { this(type, Array.newInstance(type, n)); } @@ -61,7 +61,7 @@ typecode = toCopy.typecode; } - private void setup(Class type, Object data) { + private void setup(Class<?> type, Object data) { this.type = type; typecode = class2char(type); if (data == null) { @@ -87,7 +87,7 @@ PyObject obj = ap.getPyObject(0); PyObject initial = ap.getPyObject(1, null); - Class type; + Class<?> type; String typecode; if (obj instanceof PyString && !(obj instanceof PyUnicode)) { if (obj.__len__() != 1) { @@ -138,7 +138,7 @@ return array; } - public static PyArray zeros(int n, Class ctype) { + public static PyArray zeros(int n, Class<?> ctype) { PyArray array = new PyArray(ctype, n); array.typecode = ctype.getName(); return array; @@ -161,7 +161,7 @@ * <code>Class</code> type of the elements stored in the array. * @return a new PyArray */ - public static PyArray array(PyObject init, Class ctype) { + public static PyArray array(PyObject init, Class<?> ctype) { PyArray array = new PyArray(ctype, 0); array.typecode = ctype.getName(); array.extendInternal(init); @@ -248,6 +248,7 @@ seq___delslice__(start, stop, step); } + @Override public PyObject __imul__(PyObject o) { return array___imul__(o); } @@ -272,6 +273,7 @@ return this; } + @Override public PyObject __mul__(PyObject o) { return array___mul__(o); } @@ -284,6 +286,7 @@ return repeat(o.asIndex(Py.OverflowError)); } + @Override public PyObject __rmul__(PyObject o) { return array___rmul__(o); } @@ -296,6 +299,7 @@ return repeat(o.asIndex(Py.OverflowError)); } + @Override public PyObject __iadd__(PyObject other) { return array___iadd__(other); } @@ -316,6 +320,7 @@ return this; } + @Override public PyObject __add__(PyObject other) { return array___add__(other); } @@ -348,6 +353,7 @@ * * @return number of elements in the array */ + @Override public int __len__() { return array___len__(); } @@ -357,6 +363,7 @@ return delegate.getSize(); } + @Override public PyObject __reduce__() { return array___reduce__(); } @@ -402,7 +409,8 @@ * target <em>Class</em> for the conversion * @return Java object converted to required class type if possible. */ - public Object __tojava__(Class c) { + @Override + public Object __tojava__(Class<?> c) { if(c == Object.class || (c.isArray() && c.getComponentType().isAssignableFrom(type))) { return data; @@ -502,6 +510,7 @@ * * @return copy of current PyArray */ + @Override public Object clone() { return new PyArray(this); } @@ -558,7 +567,7 @@ */ // promote B, H, I (unsigned int) to next larger size - public static Class char2class(char type) throws PyIgnoreMethodTag { + public static Class<?> char2class(char type) throws PyIgnoreMethodTag { switch(type){ case 'z': return Boolean.TYPE; @@ -591,40 +600,7 @@ } } - private static Class char2storageClass(char type) throws PyIgnoreMethodTag { - switch(type){ - case 'z': - return Boolean.TYPE; - case 'b': - return Byte.TYPE; - case 'B': - return Byte.TYPE; - case 'u': - return Integer.TYPE; - case 'c': - return Character.TYPE; - case 'h': - return Short.TYPE; - case 'H': - return Short.TYPE; - case 'i': - return Integer.TYPE; - case 'I': - return Integer.TYPE; - case 'l': - return Long.TYPE; - case 'L': - return Long.TYPE; - case 'f': - return Float.TYPE; - case 'd': - return Double.TYPE; - default: - throw Py.ValueError("bad typecode (must be c, b, B, u, h, H, i, I, l, L, f or d)"); - } - } - - private static String class2char(Class cls) { + private static String class2char(Class<?> cls) { if(cls.equals(Boolean.TYPE)) return "z"; else if(cls.equals(Character.TYPE)) @@ -684,6 +660,7 @@ * @param i * index of the item to be deleted from the array */ + @Override protected void del(int i) { // Now the AbstractArray can support this: // throw Py.TypeError("can't remove from array"); @@ -698,6 +675,7 @@ * @param stop * finishing index of slice */ + @Override protected void delRange(int start, int stop) { delegate.remove(start, stop); } @@ -1054,6 +1032,7 @@ * @param i * index of the item to be retrieved from the array */ + @Override protected PyObject pyget(int i) { if ("u".equals(typecode)) { return new PyUnicode(Array.getInt(data, i)); @@ -1199,6 +1178,7 @@ * stepping increment of the slice * @return A new PyArray object containing the described slice */ + @Override protected PyObject getslice(int start, int stop, int step) { if (step > 0 && stop < start) { stop = start; @@ -1376,6 +1356,7 @@ * @return A new PyArray object containing the source object repeated * <em>count</em> times. */ + @Override protected PyObject repeat(int count) { Object arraycopy = delegate.copyArray(); PyArray ret = new PyArray(type, 0); @@ -1425,6 +1406,7 @@ pyset(i, value); } + @Override protected void pyset(int i, PyObject value) { if ("u".equals(typecode)) { Array.setInt(data, i, getCodePoint(value)); @@ -1528,6 +1510,7 @@ * @param step * stepping increment of the slice */ + @Override protected void setslice(int start, int stop, int step, PyObject value) { if (stop < start) { stop = start; @@ -1819,17 +1802,19 @@ super(data == null ? 0 : Array.getLength(data)); } + @Override protected Object getArray() { return data; } + @Override protected void setArray(Object array) { data = array; } @Override protected Object createArray(int size) { - Class baseType = data.getClass().getComponentType(); + Class<?> baseType = data.getClass().getComponentType(); return Array.newInstance(baseType, size); } } Modified: trunk/jython/src/org/python/core/ReflectedArgs.java =================================================================== --- trunk/jython/src/org/python/core/ReflectedArgs.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/ReflectedArgs.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -2,11 +2,11 @@ package org.python.core; public class ReflectedArgs { - public Class[] args; + public Class<?>[] args; public Object data; - public Class declaringClass; + public Class<?> declaringClass; public boolean isStatic; @@ -18,8 +18,7 @@ public static final int PyArgsKeywordsCall = 2; - public ReflectedArgs(Object data, Class[] args, Class declaringClass, - boolean isStatic) { + public ReflectedArgs(Object data, Class<?>[] args, Class<?> declaringClass, boolean isStatic) { this.data = data; this.args = args; this.declaringClass = declaringClass; @@ -129,7 +128,7 @@ return true; } - public static int precedence(Class arg) { + public static int precedence(Class<?> arg) { if (arg == Object.class) { return 3000; } @@ -166,7 +165,7 @@ } if (arg.isArray()) { - Class componentType = arg.getComponentType(); + Class<?> componentType = arg.getComponentType(); if (componentType == Object.class) { return 2500; } @@ -180,7 +179,7 @@ * unimportantly different Returns +/-2 iff arg1 and arg2 are significantly * different */ - public static int compare(Class arg1, Class arg2) { + public static int compare(Class<?> arg1, Class<?> arg2) { int p1 = precedence(arg1); int p2 = precedence(arg2); // Special code if they are both nonprimitives @@ -207,7 +206,7 @@ public static final int REPLACE = 1998; public int compareTo(ReflectedArgs other) { - Class[] oargs = other.args; + Class<?>[] oargs = other.args; // First decision based on flags if (other.flags != this.flags) { @@ -258,6 +257,7 @@ return replace ? REPLACE : 0; } + @Override public String toString() { String s = declaringClass + ", " + isStatic + ", " + flags + ", " + data + "\n"; s = s + "\t("; Modified: trunk/jython/src/org/python/core/codecs.java =================================================================== --- trunk/jython/src/org/python/core/codecs.java 2009-05-30 02:08:23 UTC (rev 6424) +++ trunk/jython/src/org/python/core/codecs.java 2009-05-30 06:00:25 UTC (rev 6425) @@ -1116,7 +1116,7 @@ int input_size = input.length(); int output_size = 0; - ArrayList<Integer> ucs4 = new ArrayList(input_size); + ArrayList<Integer> ucs4 = new ArrayList<Integer>(input_size); int j = 0; for (; j < input_size; j++) { int c = input.charAt(j); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-30 03:22:30
|
Revision: 6424 http://jython.svn.sourceforge.net/jython/?rev=6424&view=rev Author: pjenvey Date: 2009-05-30 02:08:23 +0000 (Sat, 30 May 2009) Log Message: ----------- o parse raw unicode escapes o add \U support and fix handling of EOF during a truncated escape in the raw unicode escape decoder fixes #1355 Modified Paths: -------------- trunk/jython/Lib/test/test_unicode_jy.py trunk/jython/NEWS trunk/jython/src/org/python/antlr/GrammarActions.java trunk/jython/src/org/python/core/codecs.java Modified: trunk/jython/Lib/test/test_unicode_jy.py =================================================================== --- trunk/jython/Lib/test/test_unicode_jy.py 2009-05-30 00:46:58 UTC (rev 6423) +++ trunk/jython/Lib/test/test_unicode_jy.py 2009-05-30 02:08:23 UTC (rev 6424) @@ -51,6 +51,29 @@ self.assertEqual(ord(bar[2]), 92) self.assertEqual(ord(bar[3]), 110) + for baz in ur'Hello\u0020World !', ur'Hello\U00000020World !': + self.assertEqual(len(baz), 13, repr(baz)) + self.assertEqual(repr(baz), "u'Hello World !'") + self.assertEqual(ord(baz[5]), 32) + + quux = ur'\U00100000' + self.assertEqual(repr(quux), "u'\\U00100000'") + if sys.maxunicode == 0xffff: + self.assertEqual(len(quux), 2) + self.assertEqual(ord(quux[0]), 56256) + self.assertEqual(ord(quux[1]), 56320) + else: + self.assertEqual(len(quux), 1) + self.assertEqual(ord(quux), 1048576) + + def test_raw_unicode_escape(self): + foo = u'\U00100000' + self.assertEqual(foo.encode('raw_unicode_escape'), '\\U00100000') + self.assertEqual(foo.encode('raw_unicode_escape').decode('raw_unicode_escape'), + foo) + for bar in '\\u', '\\u000', '\\U00000': + self.assertRaises(UnicodeDecodeError, bar.decode, 'raw_unicode_escape') + def test_encode_decimal(self): self.assertEqual(int(u'\u0039\u0032'), 92) self.assertEqual(int(u'\u0660'), 0) Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2009-05-30 00:46:58 UTC (rev 6423) +++ trunk/jython/NEWS 2009-05-30 02:08:23 UTC (rev 6424) @@ -9,6 +9,7 @@ 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 Jython 2.5.0 rc3 Bugs fixed Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2009-05-30 00:46:58 UTC (rev 6423) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-05-30 02:08:23 UTC (rev 6424) @@ -9,6 +9,7 @@ import org.python.core.PyLong; import org.python.core.PyString; import org.python.core.PyUnicode; +import org.python.core.codecs; import org.python.antlr.ast.alias; import org.python.antlr.ast.arguments; import org.python.antlr.ast.boolopType; @@ -441,8 +442,12 @@ ustring); } } else if (raw) { - // Raw str without an encoding or raw unicode: simply passthru + // Raw str without an encoding or raw unicode string = string.substring(start, end); + if (ustring) { + // Raw unicode: handle unicode escapes + string = codecs.PyUnicode_DecodeRawUnicodeEscape(string, "strict"); + } } else { // Plain unicode: already decoded, just handle escapes string = PyString.decode_UnicodeEscape(string, start, end, "strict", ustring); Modified: trunk/jython/src/org/python/core/codecs.java =================================================================== --- trunk/jython/src/org/python/core/codecs.java 2009-05-30 00:46:58 UTC (rev 6423) +++ trunk/jython/src/org/python/core/codecs.java 2009-05-30 02:08:23 UTC (rev 6424) @@ -920,45 +920,54 @@ private static char[] hexdigit = "0123456789ABCDEF".toCharArray(); // The modified flag is used by cPickle. - public static String PyUnicode_EncodeRawUnicodeEscape(String str, - String errors, - boolean modifed) { - - int size = str.length(); + public static String PyUnicode_EncodeRawUnicodeEscape(String str, String errors, + boolean modifed) { StringBuilder v = new StringBuilder(str.length()); - for (int i = 0; i < size; i++) { - char ch = str.charAt(i); - if (ch >= 256 || (modifed && (ch == '\n' || ch == '\\'))) { + for (Iterator<Integer> iter = new PyUnicode(str).newSubsequenceIterator(); + iter.hasNext();) { + int codePoint = iter.next(); + if (codePoint >= Character.MIN_SUPPLEMENTARY_CODE_POINT) { + // Map 32-bit characters to '\\Uxxxxxxxx' + v.append("\\U"); + v.append(hexdigit[(codePoint >> 28) & 0xF]); + v.append(hexdigit[(codePoint >> 24) & 0xF]); + v.append(hexdigit[(codePoint >> 20) & 0xF]); + v.append(hexdigit[(codePoint >> 16) & 0xF]); + v.append(hexdigit[(codePoint >> 12) & 0xF]); + v.append(hexdigit[(codePoint >> 8) & 0xF]); + v.append(hexdigit[(codePoint >> 4) & 0xF]); + v.append(hexdigit[codePoint & 0xF]); + } else if (codePoint >= 256 || (modifed && (codePoint == '\\' || codePoint == '\n'))) { + // Map 16-bit chararacters to '\\uxxxx' v.append("\\u"); - v.append(hexdigit[(ch >>> 12) & 0xF]); - v.append(hexdigit[(ch >>> 8) & 0xF]); - v.append(hexdigit[(ch >>> 4) & 0xF]); - v.append(hexdigit[ch & 0xF]); + v.append(hexdigit[(codePoint >> 12) & 0xF]); + v.append(hexdigit[(codePoint >> 8) & 0xF]); + v.append(hexdigit[(codePoint >> 4) & 0xF]); + v.append(hexdigit[codePoint & 0xF]); } else { - v.append(ch); + v.append((char)codePoint); } } return v.toString(); } - public static String PyUnicode_DecodeRawUnicodeEscape(String str, - String errors) { + public static String PyUnicode_DecodeRawUnicodeEscape(String str, String errors) { int size = str.length(); StringBuilder v = new StringBuilder(size); + for (int i = 0; i < size;) { char ch = str.charAt(i); - /* Non-escape characters are interpreted as Unicode ordinals */ + // Non-escape characters are interpreted as Unicode ordinals if (ch != '\\') { v.append(ch); i++; continue; } - /* - * \\u-escapes are only interpreted iff the number of leading - * backslashes is odd - */ + + // \\u-escapes are only interpreted if the number of leading backslashes is + // odd int bs = i; while (i < size) { ch = str.charAt(i); @@ -968,34 +977,37 @@ v.append(ch); i++; } - if (((i - bs) & 1) == 0 || i >= size || ch != 'u') { + if (((i - bs) & 1) == 0 || i >= size || (ch != 'u' && ch != 'U')) { continue; } v.setLength(v.length() - 1); + int count = ch == 'u' ? 4 : 8; i++; - /* \\uXXXX with 4 hex digits */ - int x = 0, d = 0, j = 0; - for (; j < 4; j++) { - ch = str.charAt(i + j); - d = Character.digit(ch, 16); - if (d == -1) { + + // \\uXXXX with 4 hex digits, \Uxxxxxxxx with 8 + int codePoint = 0, asDigit = -1; + for (int j = 0; j < count; i++, j++) { + if (i == size) { + // EOF in a truncated escape + asDigit = -1; break; } - x = ((x << 4) & ~0xF) + d; + + ch = str.charAt(i); + asDigit = Character.digit(ch, 16); + if (asDigit == -1) { + break; + } + codePoint = ((codePoint << 4) & ~0xF) + asDigit; } - if (d == -1) { - i = codecs.insertReplacementAndGetResume(v, - errors, - "unicodeescape", - str, - bs, - i + j, - "truncated \\uXXXX"); + if (asDigit == -1) { + i = codecs.insertReplacementAndGetResume(v, errors, "rawunicodeescape", str, bs, i, + "truncated \\uXXXX"); } else { - i += 4; - v.append((char) x); + v.appendCodePoint(codePoint); } } + return v.toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-30 00:47:00
|
Revision: 6423 http://jython.svn.sourceforge.net/jython/?rev=6423&view=rev Author: pjenvey Date: 2009-05-30 00:46:58 +0000 (Sat, 30 May 2009) Log Message: ----------- quiet some warnings Modified Paths: -------------- trunk/jython/src/org/python/core/PyUnicode.java Modified: trunk/jython/src/org/python/core/PyUnicode.java =================================================================== --- trunk/jython/src/org/python/core/PyUnicode.java 2009-05-29 09:44:21 UTC (rev 6422) +++ trunk/jython/src/org/python/core/PyUnicode.java 2009-05-30 00:46:58 UTC (rev 6423) @@ -213,6 +213,7 @@ return fmt.format(other); } + @Override public PyUnicode __unicode__() { return this; } @@ -411,13 +412,17 @@ } } - public Iterator newSubsequenceIterator() { + // XXX: Parameterize SubsequenceIteratorImpl and friends (and make them Iterable) + public Iterator<Integer> newSubsequenceIterator() { return new SubsequenceIteratorImpl(); } - public Iterator newSubsequenceIterator(int start, int stop, int step) { + public Iterator<Integer> newSubsequenceIterator(int start, int stop, int step) { if (step < 0) { - return new SteppedIterator(step * -1, new ReversedIterator(new SubsequenceIteratorImpl(stop + 1, start + 1, 1))); + return new SteppedIterator(step * -1, + new ReversedIterator(new SubsequenceIteratorImpl(stop + 1, + start + 1, + 1))); } else { return new SubsequenceIteratorImpl(start, stop, step); } @@ -454,6 +459,7 @@ return str___rmul__(o); } + @Override public PyObject __add__(PyObject other) { return unicode___add__(other); } @@ -632,6 +638,7 @@ new ReversedIterator(newSubsequenceIterator())))); } + @Override public PyTuple partition(PyObject sep) { return unicode_partition(sep); } @@ -872,6 +879,7 @@ } } + @Override public PyTuple rpartition(PyObject sep) { return unicode_rpartition(sep); } @@ -1117,6 +1125,7 @@ } // end utf-16 aware + @Override public PyString join(PyObject seq) { return unicode_join(seq); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2009-05-29 09:44:28
|
Revision: 6422 http://jython.svn.sourceforge.net/jython/?rev=6422&view=rev Author: otmarhumbel Date: 2009-05-29 09:44:21 +0000 (Fri, 29 May 2009) Log Message: ----------- fix subprocess.test_executable() in the java -jar case Modified Paths: -------------- trunk/jython/Lib/subprocess.py Modified: trunk/jython/Lib/subprocess.py =================================================================== --- trunk/jython/Lib/subprocess.py 2009-05-29 05:28:56 UTC (rev 6421) +++ trunk/jython/Lib/subprocess.py 2009-05-29 09:44:21 UTC (rev 6422) @@ -1244,6 +1244,8 @@ if executable is not None: args[0] = executable + if '.jar' == executable[-4:]: + args = ['java', '-jar'] + args builder = java.lang.ProcessBuilder(args) # os.environ may be inherited for compatibility with CPython This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-29 05:29:15
|
Revision: 6421 http://jython.svn.sourceforge.net/jython/?rev=6421&view=rev Author: pjenvey Date: 2009-05-29 05:28:56 +0000 (Fri, 29 May 2009) Log Message: ----------- unused imports Modified Paths: -------------- trunk/jython/src/org/python/antlr/GrammarActions.java Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2009-05-29 05:27:30 UTC (rev 6420) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-05-29 05:28:56 UTC (rev 6421) @@ -22,19 +22,14 @@ import org.python.antlr.ast.BinOp; import org.python.antlr.ast.BoolOp; import org.python.antlr.ast.Call; -import org.python.antlr.ast.ClassDef; -import org.python.antlr.ast.Expression; import org.python.antlr.ast.ExtSlice; import org.python.antlr.ast.For; import org.python.antlr.ast.FunctionDef; import org.python.antlr.ast.GeneratorExp; -import org.python.antlr.ast.If; import org.python.antlr.ast.IfExp; import org.python.antlr.ast.Index; -import org.python.antlr.ast.Interactive; import org.python.antlr.ast.Lambda; import org.python.antlr.ast.ListComp; -import org.python.antlr.ast.Module; import org.python.antlr.ast.Name; import org.python.antlr.ast.Num; import org.python.antlr.ast.Slice; @@ -48,7 +43,6 @@ import org.python.antlr.ast.Yield; import org.python.antlr.base.excepthandler; import org.python.antlr.base.expr; -import org.python.antlr.base.mod; import org.python.antlr.base.slice; import org.python.antlr.base.stmt; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-05-29 05:27:48
|
Revision: 6420 http://jython.svn.sourceforge.net/jython/?rev=6420&view=rev Author: pjenvey Date: 2009-05-29 05:27:30 +0000 (Fri, 29 May 2009) Log Message: ----------- close file handles Modified Paths: -------------- trunk/jython/Lib/urllib.py Modified: trunk/jython/Lib/urllib.py =================================================================== --- trunk/jython/Lib/urllib.py 2009-05-29 02:42:15 UTC (rev 6419) +++ trunk/jython/Lib/urllib.py 2009-05-29 05:27:30 UTC (rev 6420) @@ -44,7 +44,7 @@ # Helper for non-unix systems if os.name == 'mac': from macurl2path import url2pathname, pathname2url -elif os.name == 'nt' or sys.platform.startswith('java') and os._name == 'nt': +elif (os._name if sys.platform.startswith('java') else os.name) == 'nt': from nturl2path import url2pathname, pathname2url elif os.name == 'riscos': from rourl2path import url2pathname, pathname2url @@ -215,7 +215,7 @@ try: fp = self.open_local_file(url1) hdrs = fp.info() - del fp + fp.close() return url2pathname(splithost(url1)[1]), hdrs except IOError, msg: pass @@ -1496,7 +1496,7 @@ print '======' fp = open(fn, 'rb') data = fp.read() - del fp + fp.close() if '\r' in data: table = string.maketrans("", "") data = data.translate(table, "\r") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |