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: <am...@us...> - 2010-08-01 12:48:55
|
Revision: 7083 http://jython.svn.sourceforge.net/jython/?rev=7083&view=rev Author: amak Date: 2010-08-01 12:48:48 +0000 (Sun, 01 Aug 2010) Log Message: ----------- Fixing a bug with site-packages processing. http://bugs.jython.org/issue1629 Modified Paths: -------------- trunk/jython/src/com/xhaus/modjy/ModjyJServlet.java Modified: trunk/jython/src/com/xhaus/modjy/ModjyJServlet.java =================================================================== --- trunk/jython/src/com/xhaus/modjy/ModjyJServlet.java 2010-07-27 23:44:47 UTC (rev 7082) +++ trunk/jython/src/com/xhaus/modjy/ModjyJServlet.java 2010-08-01 12:48:48 UTC (rev 7083) @@ -162,8 +162,8 @@ protected void setupEnvironment(PythonInterpreter interp, Properties props, PySystemState systemState) throws PyException { + processPythonLib(interp, systemState); checkSitePackages(props); - processPythonLib(interp, systemState); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2010-07-27 23:44:58
|
Revision: 7082 http://jython.svn.sourceforge.net/jython/?rev=7082&view=rev Author: pjenvey Date: 2010-07-27 23:44:47 +0000 (Tue, 27 Jul 2010) Log Message: ----------- fix array breaking __radd__ fallbacks fixes #1622 Modified Paths: -------------- trunk/jython/Lib/test/test_array.py trunk/jython/Lib/test/test_array_jy.py trunk/jython/NEWS trunk/jython/src/org/python/core/PyArray.java Modified: trunk/jython/Lib/test/test_array.py =================================================================== --- trunk/jython/Lib/test/test_array.py 2010-07-20 05:20:12 UTC (rev 7081) +++ trunk/jython/Lib/test/test_array.py 2010-07-27 23:44:47 UTC (rev 7082) @@ -291,10 +291,13 @@ ) b = array.array(self.badtypecode()) - self.assertRaises(TypeError, a.__add__, b) + if test_support.is_jython: + self.assertRaises(TypeError, operator.add, a, b) + self.assertRaises(TypeError, operator.add, a, "bad") + else: + self.assertRaises(TypeError, a.__add__, b) + self.assertRaises(TypeError, a.__add__, "bad") - self.assertRaises(TypeError, a.__add__, "bad") - def test_iadd(self): a = array.array(self.typecode, self.example[::-1]) b = a @@ -306,10 +309,13 @@ ) b = array.array(self.badtypecode()) - self.assertRaises(TypeError, a.__add__, b) + if test_support.is_jython: + self.assertRaises(TypeError, operator.add, a, b) + self.assertRaises(TypeError, operator.iadd, a, "bad") + else: + self.assertRaises(TypeError, a.__add__, b) + self.assertRaises(TypeError, a.__iadd__, "bad") - self.assertRaises(TypeError, a.__iadd__, "bad") - def test_mul(self): a = 5*array.array(self.typecode, self.example) self.assertEqual( Modified: trunk/jython/Lib/test/test_array_jy.py =================================================================== --- trunk/jython/Lib/test/test_array_jy.py 2010-07-20 05:20:12 UTC (rev 7081) +++ trunk/jython/Lib/test/test_array_jy.py 2010-07-27 23:44:47 UTC (rev 7082) @@ -4,10 +4,7 @@ import os import unittest from test import test_support -from array import array, zeros -from java.lang import String -from java.lang.reflect import Array -from java.util import Arrays +from array import array class ArrayJyTestCase(unittest.TestCase): @@ -15,12 +12,17 @@ # While jarray is still being phased out, just flex the initializers. # The rest of the test for array will catch all the big problems. import jarray + from java.lang import String jarray.array(range(5), 'i') jarray.array([String("a"), String("b"), String("c")], String) jarray.zeros(5, 'i') jarray.zeros(5, String) def test_java_object_arrays(self): + from array import zeros + from java.lang import String + from java.lang.reflect import Array + from java.util import Arrays jStringArr = array(String, [String("a"), String("b"), String("c")]) self.assert_( Arrays.equals(jStringArr.typecode, 'java.lang.String'), @@ -32,6 +34,7 @@ self.assertEqual(jStringArr, eval(str(jStringArr))) def test_java_compat(self): + from array import zeros from java.awt import Color hsb = Color.RGBtoHSB(0,255,255, None) self.assertEqual(hsb, array('f', [0.5,1,1]), @@ -68,9 +71,24 @@ self.assertEqual(x, array('i', range(5) * 4)) +class ArrayOpsTestCase(unittest.TestCase): + + def test_ops(self): + # http://bugs.jython.org/issue1622 + class Foo(object): + def __radd__(self, that): + return '__radd__' + ar = array('i', range(5)) + self.assertEqual('__radd__', ar + Foo()) + ar += Foo() + self.assertEqual('__radd__', ar) + + def test_main(): - test_support.run_unittest(ArrayJyTestCase, - ToFromfileTestCase) + tests = [ToFromfileTestCase, ArrayOpsTestCase] + if test_support.is_jython: + tests.extend([ArrayJyTestCase]) + test_support.run_unittest(*tests) if __name__ == "__main__": Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-07-20 05:20:12 UTC (rev 7081) +++ trunk/jython/NEWS 2010-07-27 23:44:47 UTC (rev 7082) @@ -6,6 +6,7 @@ - [ 1506 ] Jython applies PEP263 pattern for determining source-code encoding on noncomments - [ 1630 ] threading.Thread lacks __tojava__ method - [ 1558 ] PyFunction to single method interface wrapping does not handle java.lang.Object methods + - [ 1622 ] array type prevents __radd__ fallback Jython 2.5.2b1 Bugs Fixed Modified: trunk/jython/src/org/python/core/PyArray.java =================================================================== --- trunk/jython/src/org/python/core/PyArray.java 2010-07-20 05:20:12 UTC (rev 7081) +++ trunk/jython/src/org/python/core/PyArray.java 2010-07-27 23:44:47 UTC (rev 7082) @@ -304,17 +304,16 @@ return array___iadd__(other); } - @ExposedMethod + @ExposedMethod(type = MethodType.BINARY) final PyObject array___iadd__(PyObject other) { - PyArray otherArr = null; if (!(other instanceof PyArray)) { - throw Py.TypeError(String.format("can only append array (not \"%.200s\") to array", - other.getType().fastGetName())); + return null; } - otherArr = (PyArray)other; + + PyArray otherArr = (PyArray)other; if (!otherArr.typecode.equals(this.typecode)) { - throw Py.TypeError("can only append arrays of the same type, " - + "expected '" + this.type + ", found " + otherArr.type); + throw Py.TypeError("can only append arrays of the same type, expected '" + + this.type + ", found " + otherArr.type); } delegate.appendArray(otherArr.delegate.copyArray()); return this; @@ -332,16 +331,16 @@ * a PyArray to be added to the instance * @return the result of the addition as a new PyArray instance */ - @ExposedMethod + @ExposedMethod(type = MethodType.BINARY) final PyObject array___add__(PyObject other) { - PyArray otherArr = null; - if(!(other instanceof PyArray)) { - throw Py.TypeError("can only append another array to an array"); + if (!(other instanceof PyArray)) { + return null; } - otherArr = (PyArray)other; - if(!otherArr.typecode.equals(this.typecode)) { - throw Py.TypeError("can only append arrays of the same type, " - + "expected '" + this.type + ", found " + otherArr.type); + + PyArray otherArr = (PyArray)other; + if (!otherArr.typecode.equals(this.typecode)) { + throw Py.TypeError("can only append arrays of the same type, expected '" + this.type + + ", found " + otherArr.type); } PyArray ret = new PyArray(this); ret.delegate.appendArray(otherArr.delegate.copyArray()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-07-20 05:20:18
|
Revision: 7081 http://jython.svn.sourceforge.net/jython/?rev=7081&view=rev Author: zyasoft Date: 2010-07-20 05:20:12 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Added test to verify that single method interface support does not break java.lang.Object methods like toString. (This was actually fixed by Tobias in r6982.) Modified Paths: -------------- trunk/jython/Lib/test/test_func_jy.py trunk/jython/NEWS Modified: trunk/jython/Lib/test/test_func_jy.py =================================================================== --- trunk/jython/Lib/test/test_func_jy.py 2010-07-20 04:28:59 UTC (rev 7080) +++ trunk/jython/Lib/test/test_func_jy.py 2010-07-20 05:20:12 UTC (rev 7081) @@ -4,6 +4,7 @@ """ import types import unittest +from java.lang import Object from test import test_support xyz = 123 @@ -48,9 +49,25 @@ self.assertNotEqual(hash(foo.bar), hash(Foo().bar)) +class SingleMethodInterfaceTestCase(unittest.TestCase): + + def test_java_lang_object_methods(self): + # Passing a PyFunction to Object.toString, .hashCode, etc + # should not result in the function itself being called + + def return42(): + return 42 + s = Object.toString(return42) + self.assertNotEqual(s, 42) + self.assert_(s.startswith('<function return42')) + + + + def test_main(): test_support.run_unittest(FunctionTypeTestCase, - MethodHashCodeTestCase) + MethodHashCodeTestCase, + SingleMethodInterfaceTestCase) if __name__ == '__main__': test_main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-07-20 04:28:59 UTC (rev 7080) +++ trunk/jython/NEWS 2010-07-20 05:20:12 UTC (rev 7081) @@ -5,6 +5,7 @@ - [ 1373 ] Jython ClassLoader getResource does not work - [ 1506 ] Jython applies PEP263 pattern for determining source-code encoding on noncomments - [ 1630 ] threading.Thread lacks __tojava__ method + - [ 1558 ] PyFunction to single method interface wrapping does not handle java.lang.Object methods Jython 2.5.2b1 Bugs Fixed @@ -98,6 +99,8 @@ - Fix pickling of collections.defaultdict objects - Fix the cmath module to accept objects implementing the __float__ method - Add google indexer (by Yin Wang and Steve Yegge) + - Python functions can be directly passed to Java methods that + take a single method interface (such as Callable or Runnable) Jython 2.5.1rc3 Bugs Fixed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-07-20 04:29:05
|
Revision: 7080 http://jython.svn.sourceforge.net/jython/?rev=7080&view=rev Author: zyasoft Date: 2010-07-20 04:28:59 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Fixes SyspathJavaLoader so that packages added to sys.path work with Java's standard resource loading (getResource, getResourceAsStream) methods. Resolves #1373. Thanks Justin Deoliveira and Costantino Cerbo for contributing this patch. Modified Paths: -------------- trunk/jython/ACKNOWLEDGMENTS trunk/jython/Lib/test/test_sys_jy.py trunk/jython/NEWS trunk/jython/src/org/python/core/SyspathJavaLoader.java Added Paths: ----------- trunk/jython/Lib/test/bug1373.jar Modified: trunk/jython/ACKNOWLEDGMENTS =================================================================== --- trunk/jython/ACKNOWLEDGMENTS 2010-07-20 03:50:50 UTC (rev 7079) +++ trunk/jython/ACKNOWLEDGMENTS 2010-07-20 04:28:59 UTC (rev 7080) @@ -88,6 +88,8 @@ Leonardo Soto James Robinson Jonathan Feinberg + Justin Deoliveira + Costantino Cerbo Local Variables: mode: indented-text Added: trunk/jython/Lib/test/bug1373.jar =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/bug1373.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/jython/Lib/test/test_sys_jy.py =================================================================== --- trunk/jython/Lib/test/test_sys_jy.py 2010-07-20 03:50:50 UTC (rev 7079) +++ trunk/jython/Lib/test/test_sys_jy.py 2010-07-20 04:28:59 UTC (rev 7080) @@ -129,8 +129,25 @@ self.assertTrue('sys_jy_test_module' not in sys.modules, "sys.modules should be per PySystemState instance") +class SyspathResourceTest(unittest.TestCase): + def setUp(self): + self.orig_path = sys.path + sys.path.insert(0, test.test_support.findfile("bug1373.jar")) + + def tearDown(self): + sys.path = self.orig_path + + def test_resource_stream_from_syspath(self): + from pck import Main + self.assert_(Main.getResourceAsStream('Main.txt')) + + def test_resource_url_from_syspath(self): + from pck import Main + self.assert_(Main.getResource('Main.txt')) + + def test_main(): - test.test_support.run_unittest(SysTest, ShadowingTest) + test.test_support.run_unittest(SysTest, ShadowingTest, SyspathResourceTest) if __name__ == "__main__": test_main() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-07-20 03:50:50 UTC (rev 7079) +++ trunk/jython/NEWS 2010-07-20 04:28:59 UTC (rev 7080) @@ -2,6 +2,7 @@ Jython 2.5.2b2 Bugs Fixed + - [ 1373 ] Jython ClassLoader getResource does not work - [ 1506 ] Jython applies PEP263 pattern for determining source-code encoding on noncomments - [ 1630 ] threading.Thread lacks __tojava__ method Modified: trunk/jython/src/org/python/core/SyspathJavaLoader.java =================================================================== --- trunk/jython/src/org/python/core/SyspathJavaLoader.java 2010-07-20 03:50:50 UTC (rev 7079) +++ trunk/jython/src/org/python/core/SyspathJavaLoader.java 2010-07-20 04:28:59 UTC (rev 7080) @@ -134,7 +134,7 @@ ZipEntry ze = archive.getEntry(entryRes); if (ze != null) { try { - return new URL("jar:" + entry.__str__().toString() + "!/" + entryRes); + return new URL("jar:file:" + entry.__str__().toString() + "!/" + entryRes); } catch (MalformedURLException e) { throw new RuntimeException(e); } @@ -143,7 +143,11 @@ } String dir = sys.getPath(entry.__str__().toString()); try { - return new File(dir, res).toURI().toURL(); + File resource = new File(dir, res); + if (!resource.exists()) { + continue; + } + return resource.toURI().toURL(); } catch (MalformedURLException e) { throw new RuntimeException(e); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-07-20 03:50:57
|
Revision: 7079 http://jython.svn.sourceforge.net/jython/?rev=7079&view=rev Author: zyasoft Date: 2010-07-20 03:50:50 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Fixed magic comments for source encoding so that it only looks at actual comments (first two lines), not other source text. Resolves #1506 Modified Paths: -------------- trunk/jython/Lib/test/test_grammar_jy.py trunk/jython/NEWS trunk/jython/src/org/python/core/ParserFacade.java Modified: trunk/jython/Lib/test/test_grammar_jy.py =================================================================== --- trunk/jython/Lib/test/test_grammar_jy.py 2010-07-14 05:12:19 UTC (rev 7078) +++ trunk/jython/Lib/test/test_grammar_jy.py 2010-07-20 03:50:50 UTC (rev 7079) @@ -2,6 +2,7 @@ """ from test import test_support +import sys import unittest class GrammarTest(unittest.TestCase): @@ -32,8 +33,21 @@ self.assertEquals(7, foo(1, 7)) self.assertEquals(10, foo(b=10)) -def test_main(): + +pep263 = """ + # verify that PEP263 encoding is only set by magic comments, not + # by other similar looking input; seen in issue 1506 + >>> line = '"Content-Transfer-Encoding: 8bit"' + >>> print line + "Content-Transfer-Encoding: 8bit" + """ + +__test__ = dict(pep263=pep263) + + +def test_main(verbose=None): test_support.run_unittest(GrammarTest) + test_support.run_doctest(sys.modules[__name__], verbose) if __name__ == '__main__': - test_main() + test_main(verbose=True) Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-07-14 05:12:19 UTC (rev 7078) +++ trunk/jython/NEWS 2010-07-20 03:50:50 UTC (rev 7079) @@ -2,6 +2,7 @@ Jython 2.5.2b2 Bugs Fixed + - [ 1506 ] Jython applies PEP263 pattern for determining source-code encoding on noncomments - [ 1630 ] threading.Thread lacks __tojava__ method Jython 2.5.2b1 Modified: trunk/jython/src/org/python/core/ParserFacade.java =================================================================== --- trunk/jython/src/org/python/core/ParserFacade.java 2010-07-14 05:12:19 UTC (rev 7078) +++ trunk/jython/src/org/python/core/ParserFacade.java 2010-07-20 03:50:50 UTC (rev 7079) @@ -344,9 +344,9 @@ } private static ExpectedEncodingBufferedReader prepBufReader(String string, - CompilerFlags cflags, - String filename) - throws IOException { + CompilerFlags cflags, + String filename) + throws IOException { if (cflags.source_is_utf8) return prepBufReader(new StringReader(string), cflags, filename); @@ -429,10 +429,10 @@ return encoding; } + private static final Pattern pep263EncodingPattern = Pattern.compile("#.*coding[:=]\\s*([-\\w.]+)"); + private static String matchEncoding(String inputStr) { - String patternStr = "coding[:=]\\s*([-\\w.]+)"; - Pattern pattern = Pattern.compile(patternStr); - Matcher matcher = pattern.matcher(inputStr); + Matcher matcher = pep263EncodingPattern.matcher(inputStr); boolean matchFound = matcher.find(); if (matchFound && matcher.groupCount() == 1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-07-14 05:12:26
|
Revision: 7078 http://jython.svn.sourceforge.net/jython/?rev=7078&view=rev Author: zyasoft Date: 2010-07-14 05:12:19 +0000 (Wed, 14 Jul 2010) Log Message: ----------- Added specific support of threading.Thread.__tojava__, which enables the underlying Java thread to be accessed. Also restored concurrency of the canonical maps by switching to Google Guava to support them with MapMaker. Fixes #1630. Modified Paths: -------------- trunk/jython/Lib/test/test_threading_jy.py trunk/jython/Lib/threading.py trunk/jython/NEWS trunk/jython/src/org/python/modules/_threading/_threading.java Modified: trunk/jython/Lib/test/test_threading_jy.py =================================================================== --- trunk/jython/Lib/test/test_threading_jy.py 2010-07-14 04:18:08 UTC (rev 7077) +++ trunk/jython/Lib/test/test_threading_jy.py 2010-07-14 05:12:19 UTC (rev 7078) @@ -2,13 +2,17 @@ Made for Jython. """ +from __future__ import with_statement + import unittest from test import test_support import threading import time import random -from threading import Thread +from threading import Condition, Lock, Thread +from java.lang import Thread as JThread, InterruptedException + class ThreadingTestCase(unittest.TestCase): def test_str_name(self): @@ -42,8 +46,46 @@ self.assertEqual(threading.Lock, threading._Lock) self.assertEqual(threading.RLock, threading._RLock) + +class JavaIntegrationTestCase(unittest.TestCase): + """Verifies that Thread.__tojava__ correctly gets the underlying Java thread""" + + def test_interruptible(self): + + def wait_until_interrupted(cv): + name = threading.currentThread().getName() + with cv: + while not JThread.currentThread().isInterrupted(): + try: + cv.wait() + except InterruptedException, e: + break + + num_threads = 5 + unfair_condition = Condition() + threads = [ + Thread( + name="thread #%d" % i, + target=wait_until_interrupted, + args=(unfair_condition,)) + for i in xrange(num_threads)] + + for thread in threads: + thread.start() + time.sleep(0.1) + + for thread in threads: + JThread.interrupt(thread) + + joined_threads = 0 + for thread in threads: + thread.join(1.) # timeout just in case so we don't stall regrtest + joined_threads += 1 + self.assertEqual(joined_threads, num_threads) + + def test_main(): - test_support.run_unittest(ThreadingTestCase, TwistedTestCase) + test_support.run_unittest(JavaIntegrationTestCase, ThreadingTestCase, TwistedTestCase) if __name__ == "__main__": Modified: trunk/jython/Lib/threading.py =================================================================== --- trunk/jython/Lib/threading.py 2010-07-14 04:18:08 UTC (rev 7077) +++ trunk/jython/Lib/threading.py 2010-07-14 05:12:19 UTC (rev 7078) @@ -3,12 +3,11 @@ from java.util.concurrent import Semaphore, CyclicBarrier from java.util.concurrent.locks import ReentrantLock from org.python.util import jython +from org.python.core import Py from thread import _newFunctionThread from thread import _local as local -from _threading import Lock, RLock, Condition, _Lock, _RLock +from _threading import Lock, RLock, Condition, _Lock, _RLock, _threads, _active, _jthread_to_pythread, _register_thread, _unregister_thread import java.lang.Thread -import weakref - import sys as _sys from traceback import print_exc as _print_exc @@ -93,8 +92,7 @@ class JavaThread(object): def __init__(self, thread): self._thread = thread - _jthread_to_pythread[thread] = self - _threads[thread.getId()] = self + _register_thread(thread, self) def __repr__(self): _thread = self._thread @@ -141,11 +139,14 @@ def setDaemon(self, daemonic): self._thread.setDaemon(bool(daemonic)) -# relies on the fact that this is a CHM -_threads = weakref.WeakValueDictionary() -_active = _threads -_jthread_to_pythread = Collections.synchronizedMap(WeakHashMap()) + def __tojava__(self, c): + if isinstance(self._thread, c): + return self._thread + if isinstance(self, c): + return self + return Py.NoConversion + class Thread(JavaThread): def __init__(self, group=None, target=None, name=None, args=None, kwargs=None): assert group is None, "group argument must be None for now" @@ -225,7 +226,7 @@ pass def __delete(self): - del _threads[self._thread.getId()] + _unregister_thread(self._thread) class _MainThread(Thread): @@ -241,7 +242,7 @@ return False def __exitfunc(self): - del _threads[self._thread.getId()] + _unregister_thread(self._thread) t = _pickSomeNonDaemonThread() while t: t.join() Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-07-14 04:18:08 UTC (rev 7077) +++ trunk/jython/NEWS 2010-07-14 05:12:19 UTC (rev 7078) @@ -1,8 +1,8 @@ Jython NEWS -Jython 2.5.2a1 +Jython 2.5.2b2 Bugs Fixed - - [ ] + - [ 1630 ] threading.Thread lacks __tojava__ method Jython 2.5.2b1 Bugs Fixed Modified: trunk/jython/src/org/python/modules/_threading/_threading.java =================================================================== --- trunk/jython/src/org/python/modules/_threading/_threading.java 2010-07-14 04:18:08 UTC (rev 7077) +++ trunk/jython/src/org/python/modules/_threading/_threading.java 2010-07-14 05:12:19 UTC (rev 7078) @@ -3,6 +3,8 @@ import org.python.core.ClassDictInit; import org.python.core.Py; import org.python.core.PyObject; +import com.google.common.collect.MapMaker; +import java.util.Map; public class _threading implements ClassDictInit { @@ -13,5 +15,21 @@ dict.__setitem__("_Lock", Lock.TYPE); dict.__setitem__("_RLock", Lock.TYPE); dict.__setitem__("Condition", Condition.TYPE); +// dict.__setitem__("JavaThread", JavaThread.TYPE); } + + // internals to support threading.py, test_threading.py + public static Map<Long, PyObject> _threads = new MapMaker().weakValues().makeMap(); + public static Map<Thread, PyObject> _jthread_to_pythread = new MapMaker().weakKeys().makeMap(); + public static Map<Long, PyObject> _active = _threads; + + public static void _register_thread(Thread jthread, PyObject pythread) { + _threads.put(jthread.getId(), pythread); + _jthread_to_pythread.put(jthread, pythread); + } + + public static void _unregister_thread(Thread jthread) { + _threads.remove(jthread.getId()); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-07-14 04:18:14
|
Revision: 7077 http://jython.svn.sourceforge.net/jython/?rev=7077&view=rev Author: otmarhumbel Date: 2010-07-14 04:18:08 +0000 (Wed, 14 Jul 2010) Log Message: ----------- add the missing bugs fixed in 2.5.2b1 Modified Paths: -------------- trunk/jython/NEWS Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-07-09 05:50:59 UTC (rev 7076) +++ trunk/jython/NEWS 2010-07-14 04:18:08 UTC (rev 7077) @@ -1,5 +1,9 @@ Jython NEWS +Jython 2.5.2a1 + Bugs Fixed + - [ ] + Jython 2.5.2b1 Bugs Fixed - [ 1614 ] minidom chunks the character input on multi-line values @@ -53,6 +57,40 @@ - [ 1356 ] [Windows] test_subprocess test_communicate_pipe_buf fails - [ 1595 ] [patch] CachedJarsPackageManager cannot write cache for packages in jar over 64k - [ 1522 ] repeated execution of external python scripts causing PermGen out of memory exception + - [ 1251 ] select() fails when selecting on a file descriptor + - [ 1233 ] couldn't make directories when installing django in jython on Windows + - [ 1260 ] Why is asyncore.py so different? + - [ 1236 ] Django 1.0.2 jython setup.py install fails in 2.5b1 (ok in 2.5b0) + - [ 1263 ] importing * from java-class fails + - [ 1252 ] StackOverflow when name referenced before global declaration and run as a script + - [ 1275 ] Jython doesn't load directories of JARs + - [ 1278 ] socket.py error wording nitpick + - [ 1249 ] Trace function is not called with an exception event exactly when the exception occurs + - [ 1282 ] Java serialization problem + - [ 1289 ] os.path.isdir(path) return 0 istead of False + - [ 1290 ] 600x slower network download speed with urllib.urlretrieve() or urllib2.urlopen() compared to CPython + - [ 1299 ] NullPointerException without any clues + - [ 1277 ] jython applets & jythonc + - [ 1273 ] ImportError: No module named os + - [ 1308 ] Calling sys.exit() in a spawned thread fails to exit. + - [ 1346 ] compiler.transformer uses parser which is not defined + - [ 1347 ] socket Level 6 not supported + - [ 1321 ] distutils breakage with the setup.py of mercurial + - [ 1310 ] Serialization problem for wrapped Java objects + - [ 1600 ] jython dict() behaving differently from cpython's. + - [ 1269 ] windows jython.bat fails in 2.5b2 + - [ 1266 ] PythonInterpreter does not have setOut(StringWriter) + - [ 1283,1284 ] File resource leaks in pkgutil + - [ 1246 ] KeyError: 'twisted.internet.reactor' + - [ 1265 ] Possible problem with subclasses of Java classes, constructors, and reflection + - [ 1124 ] os.popen variants hang when executed command produces a lot to stderr + - [ 1291 ] select() crashes with IOException + - [ 1317 ] list.count considers tuples and lists to be equal + - [ 1297 ] Methods inherited from a Java class are not overridden properly + - [ 1285 ] [2.5b3] respectJavaAccessibility = false makes some Java class method signatures inaccessible from Jython + - [ 1254 ] jython.jar (2.5b1) conflicts with previous version (2.2) + - [ 1238 ] randomly select() exception on 2.5b1 + - [ 1259 ] jython 2.5b1 trunk failing manage.py validate - Fix runtime issues during exitfuncs triggered via SystemRestart (such as during Django or Pylons development mode reloading) - Fix pickling of collections.defaultdict objects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-07-09 05:51:06
|
Revision: 7076 http://jython.svn.sourceforge.net/jython/?rev=7076&view=rev Author: otmarhumbel Date: 2010-07-09 05:50:59 +0000 (Fri, 09 Jul 2010) Log Message: ----------- website updates for 2.5.2b1 Modified Paths: -------------- trunk/website/index.txt trunk/website/redirects/downloads.txt Modified: trunk/website/index.txt =================================================================== --- trunk/website/index.txt 2010-06-27 04:55:37 UTC (rev 7075) +++ trunk/website/index.txt 2010-07-09 05:50:59 UTC (rev 7076) @@ -4,6 +4,19 @@ Latest News ~~~~~~~~~~~ +**Jython 2.5.2 Beta 1 Has Been Released** (June 28, 2010) + +The Jython development team would like to announce the release of 2.5.2 Beta 1. For a complete listing of changes, please visit the `Release Notes`_. + +Please `download the installer by clicking here`_ to download the release from Sourceforge (`Installation instructions`_). Thanks to the developers for all of the hard work producing this release. +If you find any bugs or issues, please report them to the `jython bug tracker`_. + + +**Using Spring Python from Jython** (May 27, 2010) + +Interested in using Spring Python with Jython? Take a look at `this post`_ by Greg Turnquist to learn more + + **The Definitive Guide to Jython is Published** (February 6, 2010) `The Definitive Guide to Jython`_ , written by the official Jython team leads, covers the latest Jython 2.5 (or 2.5.x) from the basics to the advanced features. This book begins with a brief introduction to the language and then journeys through Jythons different features and uses. @@ -44,23 +57,21 @@ .. _wiki: http://wiki.python.org/jython .. _Jython 2.1: ./archive/21/index.html .. _Jython 2.2: ./archive/22/index.html -.. _Installation instructions: http://wiki.python.org/jython/InstallationInstructions -.. _Download location: http://downloads.sourceforge.net/jython/jython_installer-2.2.1.jar .. _jython-users: http://sourceforge.net/mailarchive/forum.php?forum_name=jython-users .. _jython bug tracker: http://bugs.jython.org/ .. _jython-users subscribe: https://lists.sourceforge.net/lists/listinfo/jython-users .. _wiki examples page: http://wiki.python.org/jython/DocumentationAndEducation -.. _"The Definitive Guide to Jython": http://developers.apress.com/book/view/9781430225270 -.. _Download 2.5.1 rc1 today: https://sourceforge.net/projects/jython/files/jython/2.5.1rc1/jython_installer-2.5.1rc1.jar/download .. _wiki instructions: http://wiki.python.org/jython/InstallationInstructions -.. _Download 2.5.1 rc2 today: https://sourceforge.net/projects/jython/files/jython-dev/2.5.1rc2/jython_installer-2.5.1rc2.jar/download -.. _Jython 2.5.1: https://sourceforge.net/projects/jython/files/jython/2.5.1/jython_installer-2.5.1.jar/download -.. _Download 2.5.1 rc3: https://sourceforge.net/projects/jython/files/jython-dev/2.5.1rc3/jython_installer-2.5.1rc3.jar/download .. _django-jython: http://code.google.com/p/django-jython/ .. _ibmpressbooks.com: http://www.ibmpressbooks.com/bookstore/product.asp?isbn=9780137009527 .. _Sikuli: http://groups.csail.mit.edu/uid/sikuli/ +.. _this post: http://blog.springpython.webfactional.com/2009/10/15/see-how-spring-python-works-with-jython/ .. _documentation: http://jython.org/currentdocs.html .. _The Definitive Guide to Jython: http://apress.com/book/view/9781430225270 .. _jythonbook.com: http://jythonbook.com +.. _Installation instructions: http://wiki.python.org/jython/InstallationInstructions +.. _Release Notes: http://www.jython.org/latest.html +.. _download the installer by clicking here: http://sourceforge.net/projects/jython/files/jython-dev/2.5.2b1/jython_installer-2.5.2b1.jar/download + Modified: trunk/website/redirects/downloads.txt =================================================================== --- trunk/website/redirects/downloads.txt 2010-06-27 04:55:37 UTC (rev 7075) +++ trunk/website/redirects/downloads.txt 2010-07-09 05:50:59 UTC (rev 7076) @@ -1,18 +1,36 @@ Downloads --------- -The current version of Jython is 2.5.1, please use the link below to download the Java installer. Once downloaded, please double-click on the JAR file to start the installation process. +The current version of Jython is 2.5.2 - Beta 1, please use the link below to download the Java installer. +Once downloaded, please double-click on the JAR file to start the installation process. +You may also want to read the `Installation instructions`_ or the `Release Notes`_. -`Download Jython 2.5.1`_ +`Download Jython 2.5.2`_ Beta 1 +- MD5: ``469a72e433b35e350a2c7d05c69c5e22`` +- SHA1: ``79d60b55d6df00ab1b63a788c21b322f9e33b4c7`` + Previous Releases ----------------- +`Jython 2.5.1`_ + +- MD5: ``2ee978eff4306b23753b3fe9d7af5b37`` +- SHA1: ``f0e8137b79b6f42cdc0835ab5344d823173ae326`` + `Jython 2.5.0`_ +- MD5: ``f98b83fce9669feec69d0a17ee515a20`` +- SHA1: ``6bffcbacafe9c8ccbbc62a4eeb80c62fa6790a1c`` + `Jython 2.2.1`_ -.. _Download Jython 2.5.1: http://sourceforge.net/projects/jython/files/jython/jython_installer-2.5.1.jar +- MD5: ``774543534bef2d68247953882237d448`` +- SHA1: ``6fea1e8985af955fc843789e2d60fcfc38a76fd8`` + +.. _Download Jython 2.5.2: http://sourceforge.net/projects/jython/files/jython-dev/2.5.2b1/jython_installer-2.5.2b1.jar/download +.. _Jython 2.5.1: http://sourceforge.net/projects/jython/files/jython/jython_installer-2.5.1.jar .. _Jython 2.5.0: http://sourceforge.net/projects/jython/files/jython/jython_installer-2.5.0.jar .. _Jython 2.2.1: http://sourceforge.net/projects/jython/files/jython/jython_installer-2.2.1.jar -.. _Download Jython 2.5.1rc2: https://sourceforge.net/projects/jython/files/jython-dev/2.5.1rc2/jython_installer-2.5.1rc2.jar/download +.. _Installation instructions: http://wiki.python.org/jython/InstallationInstructions +.. _Release Notes: http://www.jython.org/latest.html This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-06-27 04:55:43
|
Revision: 7075 http://jython.svn.sourceforge.net/jython/?rev=7075&view=rev Author: otmarhumbel Date: 2010-06-27 04:55:37 +0000 (Sun, 27 Jun 2010) Log Message: ----------- tag the 2.5.2b1 release Added Paths: ----------- tags/Release_2_5_2beta1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-06-27 04:51:35
|
Revision: 7074 http://jython.svn.sourceforge.net/jython/?rev=7074&view=rev Author: otmarhumbel Date: 2010-06-27 04:51:29 +0000 (Sun, 27 Jun 2010) Log Message: ----------- prepare for 2.5.2b1 Modified Paths: -------------- trunk/jython/NEWS trunk/jython/README.txt trunk/jython/build.xml Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-06-26 06:26:04 UTC (rev 7073) +++ trunk/jython/NEWS 2010-06-27 04:51:29 UTC (rev 7074) @@ -1,6 +1,6 @@ Jython NEWS -Jython 2.5.2a1 +Jython 2.5.2b1 Bugs Fixed - [ 1614 ] minidom chunks the character input on multi-line values - [ 1615 ] Can't invoke Java method that takes a variable number of arguments with zero arguments @@ -52,6 +52,7 @@ - [ 1594 ] Glob patterns like *.txt processed incorrectly on startup - [ 1356 ] [Windows] test_subprocess test_communicate_pipe_buf fails - [ 1595 ] [patch] CachedJarsPackageManager cannot write cache for packages in jar over 64k + - [ 1522 ] repeated execution of external python scripts causing PermGen out of memory exception - Fix runtime issues during exitfuncs triggered via SystemRestart (such as during Django or Pylons development mode reloading) - Fix pickling of collections.defaultdict objects Modified: trunk/jython/README.txt =================================================================== --- trunk/jython/README.txt 2010-06-26 06:26:04 UTC (rev 7073) +++ trunk/jython/README.txt 2010-06-27 04:51:29 UTC (rev 7074) @@ -6,6 +6,6 @@ bugs, a number of Python compatibility bugs, and more. See the NEWS file for more details. -The release was compiled on Windows XP with JDK 6 and requires JDK 5 to run. +The release was compiled on Mac OS X with JDK 5 and requires JDK 5 to run. Please try this out and report any bugs at http://bugs.jython.org. Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2010-06-26 06:26:04 UTC (rev 7073) +++ trunk/jython/build.xml 2010-06-27 04:51:29 UTC (rev 7074) @@ -122,13 +122,13 @@ <property name="PY_RELEASE_LEVEL_SNAPSHOT" value="170"/> <!-- 0xAA --> <!-- The current version info --> - <property name="jython.version" value="2.5.1+"/> - <property name="jython.version.noplus" value="2.5.1"/> + <property name="jython.version" value="2.5.2b1"/> + <property name="jython.version.noplus" value="2.5.2b1"/> <property name="jython.major_version" value="2"/> <property name="jython.minor_version" value="5"/> - <property name="jython.micro_version" value="1"/> - <property name="jython.release_level" value="${PY_RELEASE_LEVEL_FINAL}"/> - <property name="jython.release_serial" value="0"/> + <property name="jython.micro_version" value="2"/> + <property name="jython.release_level" value="${PY_RELEASE_LEVEL_BETA}"/> + <property name="jython.release_serial" value="1"/> <condition property="do.snapshot.build"> <isset property="snapshot.revision" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-06-26 06:26:10
|
Revision: 7073 http://jython.svn.sourceforge.net/jython/?rev=7073&view=rev Author: otmarhumbel Date: 2010-06-26 06:26:04 +0000 (Sat, 26 Jun 2010) Log Message: ----------- for eclipse users: add the new guava-r05.jar to .classpath Modified Paths: -------------- trunk/jython/.classpath Modified: trunk/jython/.classpath =================================================================== --- trunk/jython/.classpath 2010-06-26 06:04:00 UTC (rev 7072) +++ trunk/jython/.classpath 2010-06-26 06:26:04 UTC (rev 7073) @@ -37,5 +37,6 @@ <classpathentry kind="lib" path="extlibs/jffi-x86_64-SunOS.jar"/> <classpathentry kind="lib" path="extlibs/jffi.jar"/> <classpathentry kind="lib" path="extlibs/jnr-posix.jar"/> + <classpathentry kind="lib" path="extlibs/guava-r05.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-06-26 06:04:07
|
Revision: 7072 http://jython.svn.sourceforge.net/jython/?rev=7072&view=rev Author: zyasoft Date: 2010-06-26 06:04:00 +0000 (Sat, 26 Jun 2010) Log Message: ----------- Fixed #1522 by weakening references in class_to_type map (both key and value). However, in certain cases our code expects that these refs are in fact hard, so make all exposed types hard and also by default PyType#fromClass will add a hard ref. In contrast, types imported in that proxy Java classes should now be weak. Added Guava R05 (which includes google collections), to support the desired map. We may wish to strip this down, however, it could be useful in the future too. Modified Paths: -------------- trunk/jython/build.xml trunk/jython/src/org/python/core/PyJavaType.java trunk/jython/src/org/python/core/PyObject.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/core/adapter/ClassicPyObjectAdapter.java trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/modules/zipimport/zipimporter.java trunk/jython/src/org/python/util/Generic.java Added Paths: ----------- trunk/jython/extlibs/guava-r05.jar Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2010-06-26 04:03:22 UTC (rev 7071) +++ trunk/jython/build.xml 2010-06-26 06:04:00 UTC (rev 7072) @@ -188,6 +188,7 @@ <pathelement path="${extlibs.dir}/asm-3.1.jar" /> <pathelement path="${extlibs.dir}/asm-commons-3.1.jar" /> <pathelement path="${extlibs.dir}/constantine.jar" /> + <pathelement path="${extlibs.dir}/guava-r05.jar" /> <pathelement path="${extlibs.dir}/jaffl.jar"/> <pathelement path="${extlibs.dir}/jffi-Darwin.jar"/> <pathelement path="${extlibs.dir}/jffi-i386-FreeBSD.jar"/> @@ -584,6 +585,8 @@ <zipfileset src="extlibs/asm-commons-3.1.jar"/> <zipfileset src="extlibs/asm-util-3.1.jar"/> <rule pattern="org.objectweb.asm.**" result="org.python.objectweb.asm.@1"/> + <zipfileset src="extlibs/guava-r05.jar"/> + <rule pattern="com.google.**" result="org.python.google.@1"/> <zipfileset src="extlibs/jaffl.jar"/> <zipfileset src="extlibs/jffi-Darwin.jar"/> <zipfileset src="extlibs/jffi-i386-FreeBSD.jar"/> Added: trunk/jython/extlibs/guava-r05.jar =================================================================== (Binary files differ) Property changes on: trunk/jython/extlibs/guava-r05.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2010-06-26 04:03:22 UTC (rev 7071) +++ trunk/jython/src/org/python/core/PyJavaType.java 2010-06-26 06:04:00 UTC (rev 7072) @@ -59,7 +59,7 @@ private Set<String> modified; public static PyObject wrapJavaObject(Object o) { - PyObject obj = new PyObjectDerived(PyType.fromClass(o.getClass())); + PyObject obj = new PyObjectDerived(PyType.fromClass(o.getClass(), false)); obj.javaProxy = o; return obj; } Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2010-06-26 04:03:22 UTC (rev 7071) +++ trunk/jython/src/org/python/core/PyObject.java 2010-06-26 06:04:00 UTC (rev 7072) @@ -63,7 +63,7 @@ * field to correspond to the specific subclass of <code>PyObject</code> being instantiated. **/ public PyObject() { - objtype = PyType.fromClass(getClass()); + objtype = PyType.fromClass(getClass(), false); } /** Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2010-06-26 04:03:22 UTC (rev 7071) +++ trunk/jython/src/org/python/core/PyType.java 2010-06-26 06:04:00 UTC (rev 7072) @@ -22,6 +22,8 @@ import org.python.modules._weakref.WeakrefModule; import org.python.util.Generic; +import com.google.common.collect.MapMaker; + /** * The Python Type object implementation. */ @@ -97,7 +99,8 @@ /** Mapping of Java classes to their PyTypes. */ private static Map<Class<?>, PyType> class_to_type; - + private static Set<PyType> exposedTypes; + /** Mapping of Java classes to their TypeBuilders. */ private static Map<Class<?>, TypeBuilder> classToBuilder; @@ -121,7 +124,15 @@ PyObject[] args, String[] keywords) { // Special case: type(x) should return x.getType() if (args.length == 1 && keywords.length == 0) { - return args[0].getType(); + PyObject obj = args[0]; + PyType objType = obj.getType(); + + // special case for PyStringMap so that it types as a dict + PyType psmType = PyType.fromClass(PyStringMap.class); + if (objType == psmType) { + return PyDictionary.TYPE; + } + return objType; } // If that didn't trigger, we need 3 arguments. but ArgParser below may give a msg // saying type() needs exactly 3. @@ -517,7 +528,7 @@ * followed by the mro of baseClass. */ protected void computeLinearMro(Class<?> baseClass) { - base = PyType.fromClass(baseClass); + base = PyType.fromClass(baseClass, false); mro = new PyType[base.mro.length + 1]; System.arraycopy(base.mro, 0, mro, 1, base.mro.length); mro[0] = this; @@ -622,7 +633,7 @@ dict); javaProxy = proxyClass; - PyType proxyType = PyType.fromClass(proxyClass); + PyType proxyType = PyType.fromClass(proxyClass, false); List<PyObject> cleanedBases = Generic.list(); boolean addedProxyType = false; for (PyObject base : bases) { @@ -908,7 +919,7 @@ PyObject[] computeMro(MROMergeState[] toMerge, List<PyObject> mro) { boolean addedProxy = false; - PyType proxyAsType = javaProxy == null ? null : PyType.fromClass(((Class<?>)javaProxy)); + PyType proxyAsType = javaProxy == null ? null : PyType.fromClass(((Class<?>)javaProxy), false); scan : for (int i = 0; i < toMerge.length; i++) { if (toMerge[i].isMerged()) { continue scan; @@ -1164,7 +1175,7 @@ return null; } - public static void addBuilder(Class<?> forClass, TypeBuilder builder) { + public synchronized static void addBuilder(Class<?> forClass, TypeBuilder builder) { if (classToBuilder == null) { classToBuilder = Generic.map(); } @@ -1181,9 +1192,9 @@ } } - private static PyType addFromClass(Class<?> c, Set<PyJavaType> needsInners) { + private synchronized static PyType addFromClass(Class<?> c, Set<PyJavaType> needsInners) { if (ExposeAsSuperclass.class.isAssignableFrom(c)) { - PyType exposedAs = fromClass(c.getSuperclass()); + PyType exposedAs = fromClass(c.getSuperclass(), false); class_to_type.put(c, exposedAs); return exposedAs; } @@ -1227,7 +1238,7 @@ return builder; } - private static PyType createType(Class<?> c, Set<PyJavaType> needsInners) { + private synchronized static PyType createType(Class<?> c, Set<PyJavaType> needsInners) { PyType newtype; if (c == PyType.class) { newtype = new PyType(false); @@ -1251,18 +1262,25 @@ return newtype; } - // XXX what's the proper scope of this synchronization? given module import lock, might be - // ok to omit this sync here... + // re the synchronization used here: this result is cached in each type obj, + // so we just need to prevent data races. all public methods that access class_to_type + // are themselves synchronized. However, if we use Google Collections/Guava, + // MapMaker only uses ConcurrentMap anyway + public static synchronized PyType fromClass(Class<?> c) { + return fromClass(c, true); + } + + public static synchronized PyType fromClass(Class<?> c, boolean hardRef) { if (class_to_type == null) { - class_to_type = Generic.synchronizedWeakHashMap(); + class_to_type = new MapMaker().weakKeys().weakValues().makeMap(); addFromClass(PyType.class, null); } PyType type = class_to_type.get(c); if (type != null) { return type; } - // We haven't seen this class before, so it's type needs to be created. If it's being + // We haven't seen this class before, so its type needs to be created. If it's being // exposed as a Java class, defer processing its inner types until it's completely // created in case the inner class references a class that references this class. Set<PyJavaType> needsInners = Generic.set(); @@ -1284,10 +1302,17 @@ || ExposeAsSuperclass.class.isAssignableFrom(inner)) { Py.BOOTSTRAP_TYPES.add(inner); } - javaType.dict.__setitem__(inner.getSimpleName(), PyType.fromClass(inner)); + javaType.dict.__setitem__(inner.getSimpleName(), PyType.fromClass(inner, hardRef)); } } } + if (hardRef && result != null) { + if (exposedTypes == null) { + exposedTypes = Generic.set(); + } + exposedTypes.add(result) ; + } + return result; } @@ -1757,7 +1782,7 @@ private Object readResolve() { if (underlying_class != null) { - return PyType.fromClass(underlying_class); + return PyType.fromClass(underlying_class, false); } PyObject mod = imp.importName(module.intern(), false); PyObject pytyp = mod.__getattr__(name.intern()); Modified: trunk/jython/src/org/python/core/adapter/ClassicPyObjectAdapter.java =================================================================== --- trunk/jython/src/org/python/core/adapter/ClassicPyObjectAdapter.java 2010-06-26 04:03:22 UTC (rev 7071) +++ trunk/jython/src/org/python/core/adapter/ClassicPyObjectAdapter.java 2010-06-26 06:04:00 UTC (rev 7072) @@ -73,7 +73,7 @@ add(new ClassAdapter(Class.class) { public PyObject adapt(Object o) { - return PyType.fromClass((Class<?>)o); + return PyType.fromClass((Class<?>)o, false); } }); Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2010-06-26 04:03:22 UTC (rev 7071) +++ trunk/jython/src/org/python/core/imp.java 2010-06-26 06:04:00 UTC (rev 7072) @@ -399,7 +399,7 @@ throw Py.JavaError(e); } } - return PyType.fromClass(c); // xxx? + return PyType.fromClass(c, false); // xxx? } static PyObject getPathImporter(PyObject cache, PyList hooks, PyObject p) { Modified: trunk/jython/src/org/python/modules/zipimport/zipimporter.java =================================================================== --- trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2010-06-26 04:03:22 UTC (rev 7071) +++ trunk/jython/src/org/python/modules/zipimport/zipimporter.java 2010-06-26 06:04:00 UTC (rev 7072) @@ -117,7 +117,7 @@ zipimport._zip_directory_cache.__setitem__(archive, files); } } else { - throw zipimport.ZipImportError("not a Zip file"); + throw zipimport.ZipImportError("not a Zip file: " + path); } if (prefix != "" && !prefix.endsWith(File.separator)) { Modified: trunk/jython/src/org/python/util/Generic.java =================================================================== --- trunk/jython/src/org/python/util/Generic.java 2010-06-26 04:03:22 UTC (rev 7071) +++ trunk/jython/src/org/python/util/Generic.java 2010-06-26 06:04:00 UTC (rev 7072) @@ -58,11 +58,6 @@ return new HashMap<K, V>(); } - public static <K, V> Map<K, V> synchronizedWeakHashMap() { - return Collections.synchronizedMap(new WeakHashMap<K, V>()); - } - - /** * Makes a ConcurrentMap using generic types inferred from whatever this is being * assigned to. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-06-26 04:03:29
|
Revision: 7071 http://jython.svn.sourceforge.net/jython/?rev=7071&view=rev Author: zyasoft Date: 2010-06-26 04:03:22 +0000 (Sat, 26 Jun 2010) Log Message: ----------- Added test code to verify that proxies are not leaked by hard refs in PyType#class_to_test. This will cause the regrtest to fail until the patch in issue 1522 is also applied (other issues apply in its integration unfortunately). Modified Paths: -------------- trunk/jython/Lib/test/test_jy_internals.py trunk/jython/tests/java/javatests/TestSupport.java Modified: trunk/jython/Lib/test/test_jy_internals.py =================================================================== --- trunk/jython/Lib/test/test_jy_internals.py 2010-06-25 14:22:08 UTC (rev 7070) +++ trunk/jython/Lib/test/test_jy_internals.py 2010-06-26 04:03:22 UTC (rev 7071) @@ -1,6 +1,7 @@ """ test some jython internals """ +import gc import unittest import time from test.test_support import run_suite @@ -9,10 +10,59 @@ import jarray from org.python.core import Py +from org.python.util import PythonInterpreter +from javatests.TestSupport import getField from java.sql import Date, Time, Timestamp import datetime +class MemoryLeakTests(unittest.TestCase): + + def test_class_to_test_weakness(self): + # regrtest for bug 1522, adapted from test code submitted by Matt Brinkley + + # work around the fact that we can't look at PyType directly + # by using this helper function that reflects on PyType (and + # demonstrates here that it's the same as the builtin function + # `type`!) + class_to_type_map = getField(type, 'class_to_type').get(None) + + def make_clean(): + # gc a few times just to be really sure, since in this + # case we don't really care if it takes a few cycles of GC + # for the garbage to be reached + gc.collect() + time.sleep(0.1) + gc.collect() + time.sleep(0.5) + gc.collect() + + def create_proxies(): + pi = PythonInterpreter() + pi.exec(""" +from java.lang import Comparable + +class Dog(Comparable): + def compareTo(self, o): + return 0 + def bark(self): + return 'woof woof' + +Dog().bark() +""") + pi.cleanup(); + make_clean() + + # get to steady state first, then verify we don't create new proxies + for i in xrange(2): + create_proxies() + start_size = class_to_type_map.size() + for i in xrange(5): + create_proxies() + make_clean() + self.assertEqual(start_size, class_to_type_map.size()) + + class WeakIdentityMapTests(unittest.TestCase): def test_functionality(self): @@ -249,6 +299,7 @@ suite_add(IdTest) suite_add(FrameTest) suite_add(ModuleTest) + suite_add(MemoryLeakTests) run_suite(test_suite) if __name__ == "__main__": Modified: trunk/jython/tests/java/javatests/TestSupport.java =================================================================== --- trunk/jython/tests/java/javatests/TestSupport.java 2010-06-25 14:22:08 UTC (rev 7070) +++ trunk/jython/tests/java/javatests/TestSupport.java 2010-06-26 04:03:22 UTC (rev 7071) @@ -1,6 +1,9 @@ //Copyright (c) Corporation for National Research Initiatives package javatests; +import java.lang.reflect.Field; +import java.lang.NoSuchFieldException; + /** * @author updikca1 */ @@ -46,5 +49,16 @@ assertThat( !a.equals(b), message + "[not a.equals(b) failed]"); assertThat( !b.equals(a), message + "[not b.equals(a) failed]"); } + + public static Field getField(Class cls, String name) { + try { + Field f = cls.getDeclaredField(name); + f.setAccessible(true); + return f; + } catch (NoSuchFieldException ex) { + throw new RuntimeException(ex); + } + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2010-06-25 14:22:15
|
Revision: 7070 http://jython.svn.sourceforge.net/jython/?rev=7070&view=rev Author: amak Date: 2010-06-25 14:22:08 +0000 (Fri, 25 Jun 2010) Log Message: ----------- Fix for bug 1614: minidom chunks the character input on multi-line values Modified Paths: -------------- trunk/jython/Lib/test/test_minidom.py trunk/jython/Lib/xml/dom/minidom.py trunk/jython/NEWS Modified: trunk/jython/Lib/test/test_minidom.py =================================================================== --- trunk/jython/Lib/test/test_minidom.py 2010-06-25 13:16:13 UTC (rev 7069) +++ trunk/jython/Lib/test/test_minidom.py 2010-06-25 14:22:08 UTC (rev 7070) @@ -523,6 +523,29 @@ "testNormalize -- single empty node removed") doc.unlink() +def testNormalizedAfterLoad(): + """ + Introduced this test on jython because + 1. Cpython guarantees, by the use of xml.dom.expatbuilder, + that all text nodes are normalized after loading. + 2. Jython has no expat, and thus uses xml.dom.pulldom.parse + (which uses any java SAX2 compliant parser), and which makes + no guarantees about text node normalization. + Thus we have to check if text nodes are normalized after a parse. + See this bug for further information + minidom chunks the character input on multi-line values + http://bugs.jython.org/issue1614 + """ + num_lines = 2 + # Up to 16K lines should be enough to guarantee failure without normalization + while num_lines <= 2**14: + doc_content = "\n".join( ("Line %d" % i for i in xrange(num_lines)) ) + doc_text = "<document>%s</document>" % doc_content + dom = parseString(doc_text) + node_content = dom.getElementsByTagName("document")[0].childNodes[0].nodeValue + confirm(node_content == doc_content, "testNormalizedAfterLoad") + num_lines *= 2 + def testSiblings(): doc = parseString("<doc><?pi?>text?<elm/></doc>") root = doc.documentElement Modified: trunk/jython/Lib/xml/dom/minidom.py =================================================================== --- trunk/jython/Lib/xml/dom/minidom.py 2010-06-25 13:16:13 UTC (rev 7069) +++ trunk/jython/Lib/xml/dom/minidom.py 2010-06-25 14:22:08 UTC (rev 7070) @@ -1908,6 +1908,7 @@ toktype, rootNode = events.getEvent() events.expandNode(rootNode) events.clear() + rootNode.normalize() return rootNode def parse(file, parser=None, bufsize=None): Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-06-25 13:16:13 UTC (rev 7069) +++ trunk/jython/NEWS 2010-06-25 14:22:08 UTC (rev 7070) @@ -2,6 +2,7 @@ Jython 2.5.2a1 Bugs Fixed + - [ 1614 ] minidom chunks the character input on multi-line values - [ 1615 ] Can't invoke Java method that takes a variable number of arguments with zero arguments - [ 1605 ] float preference over PyComplex as arg to __call__ breaks logic - [ 1586 ] weakref reference count leak when kwargs are used This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2010-06-25 13:16:20
|
Revision: 7069 http://jython.svn.sourceforge.net/jython/?rev=7069&view=rev Author: fwierzbicki Date: 2010-06-25 13:16:13 +0000 (Fri, 25 Jun 2010) Log Message: ----------- Update for next release. Modified Paths: -------------- trunk/jython/README.txt Modified: trunk/jython/README.txt =================================================================== --- trunk/jython/README.txt 2010-06-24 22:16:42 UTC (rev 7068) +++ trunk/jython/README.txt 2010-06-25 13:16:13 UTC (rev 7069) @@ -1,11 +1,11 @@ -Welcome to Jython 2.5.1 Final +Welcome to Jython 2.5.2 Beta1 ============================= -This is the final release of the 2.5.1 version of Jython. This release fixes a -number of bugs, including some major errors when using coroutines and when -using relative imports, as well as a potential data loss bug when writing to -files in append mode. Please see the NEWS file for detailed release notes. +This is the first beta release of the 2.5.2 version of Jython. This release +fixes a number of bugs, including some Java integration problems, several modjy +bugs, a number of Python compatibility bugs, and more. See the NEWS file for +more details. -The release was compiled on Mac OS X with JDK 5 and requires JDK 5 to run. +The release was compiled on Windows XP with JDK 6 and requires JDK 5 to run. Please try this out and report any bugs at http://bugs.jython.org. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-06-24 22:16:49
|
Revision: 7068 http://jython.svn.sourceforge.net/jython/?rev=7068&view=rev Author: otmarhumbel Date: 2010-06-24 22:16:42 +0000 (Thu, 24 Jun 2010) Log Message: ----------- accept directories containing + signs, both during installation and at runtime in standalone mode Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/JarInfo.java trunk/jython/src/org/python/core/PySystemState.java Modified: trunk/installer/src/java/org/python/util/install/JarInfo.java =================================================================== --- trunk/installer/src/java/org/python/util/install/JarInfo.java 2010-06-23 20:25:08 UTC (rev 7067) +++ trunk/installer/src/java/org/python/util/install/JarInfo.java 2010-06-24 22:16:42 UTC (rev 7068) @@ -111,7 +111,13 @@ URL url = getClass().getResource(className + ".class"); // we expect an URL like: // jar:file:/C:/stuff/jython21i.jar!/org/python/util/install/JarInfo.class - String urlString = URLDecoder.decode(url.toString(), "UTF-8"); + // escape plus signs, since the URLDecoder would turn them into spaces + final String plus = "\\+"; + final String escapedPlus = "__ppluss__"; + String rawUrl = url.toString(); + rawUrl = rawUrl.replaceAll(plus, escapedPlus); + String urlString = URLDecoder.decode(rawUrl, "UTF-8"); + urlString = urlString.replaceAll(escapedPlus, plus); int jarSeparatorIndex = urlString.lastIndexOf(JAR_SEPARATOR); if (!urlString.startsWith(JAR_URL_PREFIX) || jarSeparatorIndex <= 0) { throw new InstallerException(Installation.getText(TextKeys.UNEXPECTED_URL, urlString)); Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2010-06-23 20:25:08 UTC (rev 7067) +++ trunk/jython/src/org/python/core/PySystemState.java 2010-06-24 22:16:42 UTC (rev 7068) @@ -1073,14 +1073,18 @@ // we expect an URL like jar:file:/install_dir/jython.jar!/org/python/core/PySystemState.class if (url != null) { try { - String urlString = URLDecoder.decode(url.toString(), - Charset.defaultCharset().name()); + // escape plus signs, since the URLDecoder would turn them into spaces + final String plus = "\\+"; + final String escapedPlus = "__ppluss__"; + String rawUrl = url.toString(); + rawUrl = rawUrl.replaceAll(plus, escapedPlus); + String urlString = URLDecoder.decode(rawUrl, "UTF-8"); + urlString = urlString.replaceAll(escapedPlus, plus); int jarSeparatorIndex = urlString.lastIndexOf(JAR_SEPARATOR); if (urlString.startsWith(JAR_URL_PREFIX) && jarSeparatorIndex > 0) { jarFileName = urlString.substring(JAR_URL_PREFIX.length(), jarSeparatorIndex); } - } catch (Exception e) { - } + } catch (Exception e) {} } return jarFileName; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-06-23 20:25:14
|
Revision: 7067 http://jython.svn.sourceforge.net/jython/?rev=7067&view=rev Author: zyasoft Date: 2010-06-23 20:25:08 +0000 (Wed, 23 Jun 2010) Log Message: ----------- PyType#class_to_type should only have weak ref to Java classes being so mapped - this is important so that GC can occur on these classes Modified Paths: -------------- trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/util/Generic.java Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2010-06-16 14:46:34 UTC (rev 7066) +++ trunk/jython/src/org/python/core/PyType.java 2010-06-23 20:25:08 UTC (rev 7067) @@ -1251,9 +1251,11 @@ return newtype; } + // XXX what's the proper scope of this synchronization? given module import lock, might be + // ok to omit this sync here... public static synchronized PyType fromClass(Class<?> c) { if (class_to_type == null) { - class_to_type = Generic.map(); + class_to_type = Generic.synchronizedWeakHashMap(); addFromClass(PyType.class, null); } PyType type = class_to_type.get(c); Modified: trunk/jython/src/org/python/util/Generic.java =================================================================== --- trunk/jython/src/org/python/util/Generic.java 2010-06-16 14:46:34 UTC (rev 7066) +++ trunk/jython/src/org/python/util/Generic.java 2010-06-23 20:25:08 UTC (rev 7067) @@ -6,12 +6,14 @@ import java.util.AbstractSet; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -56,6 +58,11 @@ return new HashMap<K, V>(); } + public static <K, V> Map<K, V> synchronizedWeakHashMap() { + return Collections.synchronizedMap(new WeakHashMap<K, V>()); + } + + /** * Makes a ConcurrentMap using generic types inferred from whatever this is being * assigned to. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2010-06-16 14:46:41
|
Revision: 7066 http://jython.svn.sourceforge.net/jython/?rev=7066&view=rev Author: zyasoft Date: 2010-06-16 14:46:34 +0000 (Wed, 16 Jun 2010) Log Message: ----------- Reflected method fixes: Fixes #1605 by having PyComplex#__tojava__ refuse to convert to anything but itself (restores old behavior before adding support for faux floats) Fixes #1615 by supporting varargs Java methods, so that a method marked as test(String...) can be called as either test("abc", "xyz") or, because it's reasonable in Java, test(["abc", "xyz"]) Modified Paths: -------------- trunk/jython/Lib/test/test_joverload.py trunk/jython/NEWS trunk/jython/src/org/python/core/PyComplex.java trunk/jython/src/org/python/core/PyReflectedFunction.java trunk/jython/src/org/python/core/ReflectedArgs.java Added Paths: ----------- trunk/jython/tests/java/javatests/Reflection.java Modified: trunk/jython/Lib/test/test_joverload.py =================================================================== --- trunk/jython/Lib/test/test_joverload.py 2010-06-15 06:34:16 UTC (rev 7065) +++ trunk/jython/Lib/test/test_joverload.py 2010-06-16 14:46:34 UTC (rev 7066) @@ -3,9 +3,12 @@ # (can be adapted to test alternative re-implemations even while they are developed # write a *Envl class and change/add to to_test for that) +import sys import unittest import java +from java.util import ArrayList +from javatests import JOverload, Reflection from org.python.core import PyReflectedFunction class PyReflFuncEnvl: @@ -25,7 +28,6 @@ meth_dict[name] = envl_class(name,[ m for m in meths if m.name == name ]) return meth_dict -from javatests import JOverload jo = JOverload() to_test = [extract_ov_meths(JOverload,PyReflFuncEnvl)] @@ -119,11 +121,55 @@ """) +class VarargsDispatchTests(unittest.TestCase): + + def test_strings(self): + t = Reflection.StringVarargs() + self.assertEqual(t.test("abc", "xyz"), + "String...:[abc, xyz]") + self.assertEqual(t.test("abc"), + "String...:[abc]") + self.assertEqual(t.test(), + "String...:[]") + + self.assertEqual(t.test(["abc", "xyz"]), + "String...:[abc, xyz]") + self.assertEqual(t.test(["abc"]), + "String...:[abc]") + self.assertEqual(t.test([]), + "String...:[]") + + + def test_lists(self): + t = Reflection.ListVarargs() + self.assertEqual(t.test(ArrayList([1,2,3]), ArrayList([4,5,6])), + "List...:[[1, 2, 3], [4, 5, 6]]") + self.assertEqual(t.test(ArrayList([1,2,3])), + "List...:[[1, 2, 3]]") + self.assertEqual(t.test(), + "List...:[]") + + self.assertEqual(t.test([ArrayList([1,2,3]), ArrayList([4,5,6])]), + "List...:[[1, 2, 3], [4, 5, 6]]") + self.assertEqual(t.test([ArrayList([1,2,3])]), + "List...:[[1, 2, 3]]") + self.assertEqual(t.test([]), + "List...:[]") + + +class ComplexOverloadingTests(unittest.TestCase): + + def test_complex(self): + o = Reflection.Overloaded() + self.assertEqual(o(2.), "class java.lang.Double=2.0") + self.assertEqual(o(1+2j), "class org.python.core.PyComplex=(1+2j)") + + + def printout(meth_dict,lbl,rng,args): for i in rng: print meth_dict['ov_%s%s' % (lbl,i)](jo,args) -import sys if __name__ == '__main__' and not sys.argv[1:] == ['break-out']: try: @@ -131,4 +177,4 @@ except ImportError: unittest.main() else: - test_support.run_unittest(OverloadedDispatchTests) + test_support.run_unittest(OverloadedDispatchTests, VarargsDispatchTests, ComplexOverloadingTests) Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-06-15 06:34:16 UTC (rev 7065) +++ trunk/jython/NEWS 2010-06-16 14:46:34 UTC (rev 7066) @@ -2,6 +2,8 @@ Jython 2.5.2a1 Bugs Fixed + - [ 1615 ] Can't invoke Java method that takes a variable number of arguments with zero arguments + - [ 1605 ] float preference over PyComplex as arg to __call__ breaks logic - [ 1586 ] weakref reference count leak when kwargs are used - [ 1601 ] Can't serialize PyCode object - [ 1551 ] Java objects cannot be copied by the copy module Modified: trunk/jython/src/org/python/core/PyComplex.java =================================================================== --- trunk/jython/src/org/python/core/PyComplex.java 2010-06-15 06:34:16 UTC (rev 7065) +++ trunk/jython/src/org/python/core/PyComplex.java 2010-06-16 14:46:34 UTC (rev 7066) @@ -482,7 +482,17 @@ return _divmod(coerce(left), this).__finditem__(0); } + // Special case __tojava__ for bug 1605, since we broke it with our support for faux floats. + @Override + public Object __tojava__(Class<?> c) { + if (c.isInstance(this)) { + return this; + } + return Py.NoConversion; + } + + @Override public PyObject __truediv__(PyObject right) { return complex___truediv__(right); } Modified: trunk/jython/src/org/python/core/PyReflectedFunction.java =================================================================== --- trunk/jython/src/org/python/core/PyReflectedFunction.java 2010-06-15 06:34:16 UTC (rev 7065) +++ trunk/jython/src/org/python/core/PyReflectedFunction.java 2010-06-16 14:46:34 UTC (rev 7066) @@ -55,9 +55,10 @@ private ReflectedArgs makeArgs(Method m) { return new ReflectedArgs(m, - m.getParameterTypes(), - m.getDeclaringClass(), - Modifier.isStatic(m.getModifiers())); + m.getParameterTypes(), + m.getDeclaringClass(), + Modifier.isStatic(m.getModifiers()), + m.isVarArgs()); } public PyReflectedFunction copy() { Modified: trunk/jython/src/org/python/core/ReflectedArgs.java =================================================================== --- trunk/jython/src/org/python/core/ReflectedArgs.java 2010-06-15 06:34:16 UTC (rev 7065) +++ trunk/jython/src/org/python/core/ReflectedArgs.java 2010-06-16 14:46:34 UTC (rev 7066) @@ -10,6 +10,8 @@ public boolean isStatic; + public boolean isVarArgs; + public int flags; public static final int StandardCall = 0; @@ -19,10 +21,15 @@ public static final int PyArgsKeywordsCall = 2; public ReflectedArgs(Object data, Class<?>[] args, Class<?> declaringClass, boolean isStatic) { + this(data, args, declaringClass, isStatic, false); + } + + public ReflectedArgs(Object data, Class<?>[] args, Class<?> declaringClass, boolean isStatic, boolean isVarArgs) { this.data = data; this.args = args; this.declaringClass = declaringClass; this.isStatic = isStatic; + this.isVarArgs = isVarArgs; // only used for varargs matching; it should be added after the unboxed form if (args.length == 1 && args[0] == PyObject[].class) { this.flags = PyArgsCall; @@ -90,6 +97,38 @@ } int n = this.args.length; + + // if we have a varargs method AND the last PyObject is not a list/tuple + // we need to do box (wrap with an array) the last pyArgs.length - n args + // (which might be empty) + // + // examples: + // test(String... x) + // test(List... x) + // + // in this last example, don't worry if someone is overly clever in calling this, + // they can always write their own version of PyReflectedFunction and put it in the proxy + // if that's what they need to do ;) + + if (isVarArgs) { + if (pyArgs.length == 0 || !(pyArgs[pyArgs.length - 1] instanceof PySequenceList)) { + int non_varargs_len = n - 1; + if (pyArgs.length >= non_varargs_len) { + PyObject[] boxedPyArgs = new PyObject[n]; + for (int i = 0; i < non_varargs_len; i++) { + boxedPyArgs[i] = pyArgs[i]; + } + int varargs_len = pyArgs.length - non_varargs_len; + PyObject[] varargs = new PyObject[varargs_len]; + for (int i = 0; i < varargs_len; i++) { + varargs[i] = pyArgs[non_varargs_len + i]; + } + boxedPyArgs[non_varargs_len] = new PyList(varargs); + pyArgs = boxedPyArgs; + } + } + } + if (pyArgs.length != n) { return false; } @@ -111,8 +150,11 @@ Object[] javaArgs = callData.args; for (int i = 0; i < n; i++) { - if ((javaArgs[i] = pyArgs[i].__tojava__(this.args[i])) == Py.NoConversion) { - // Make error messages clearer + PyObject pyArg = pyArgs[i]; + Class targetClass = this.args[i]; + Object javaArg = pyArg.__tojava__(targetClass); + javaArgs[i] = javaArg; + if (javaArg == Py.NoConversion) { if (i > callData.errArg) { callData.errArg = i; } @@ -253,7 +295,7 @@ @Override public String toString() { - String s = declaringClass + ", " + isStatic + ", " + flags + ", " + data + "\n"; + String s = declaringClass + ", static=" + isStatic + ", varargs=" + isVarArgs + ",flags=" + flags + ", " + data + "\n"; s = s + "\t("; for (Class<?> arg : args) { s += arg.getName() + ", "; Added: trunk/jython/tests/java/javatests/Reflection.java =================================================================== --- trunk/jython/tests/java/javatests/Reflection.java (rev 0) +++ trunk/jython/tests/java/javatests/Reflection.java 2010-06-16 14:46:34 UTC (rev 7066) @@ -0,0 +1,44 @@ +package javatests; + +import java.util.Arrays; +import java.util.List; + +import org.python.core.Py; +import org.python.core.PyComplex; +import org.python.core.PyObject; + +public class Reflection { + + public static class StringVarargs { + + public String test(String... args) { + return "String...:" + Arrays.toString(args); + } + } + + public static class ListVarargs { + + public String test(List... args) { + return "List...:" + Arrays.toString(args); + } + } + + public static class Overloaded { + + public PyObject __call__(float x) { + return dump(x); + } + + public PyObject __call__(double x) { + return dump(x); + } + + public PyObject __call__(PyComplex x) { + return dump(x); + } + + private PyObject dump(Object o) { + return Py.newString(o.getClass() + "=" + o); + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-06-15 06:34:22
|
Revision: 7065 http://jython.svn.sourceforge.net/jython/?rev=7065&view=rev Author: otmarhumbel Date: 2010-06-15 06:34:16 +0000 (Tue, 15 Jun 2010) Log Message: ----------- handle arguments containing % signs partly fixes issue #1599 Modified Paths: -------------- trunk/jython/Lib/test/test_bat_jy.py trunk/jython/src/shell/jython.bat Modified: trunk/jython/Lib/test/test_bat_jy.py =================================================================== --- trunk/jython/Lib/test/test_bat_jy.py 2010-06-15 06:33:20 UTC (rev 7064) +++ trunk/jython/Lib/test/test_bat_jy.py 2010-06-15 06:34:16 UTC (rev 7065) @@ -102,7 +102,7 @@ stdoutMonitor.start() stderrMonitor.start() while self.isAlive(process): - Thread.sleep(500) + Thread.sleep(300) return self.getOutput(outfilePath) finally: os.remove(starterPath) @@ -158,6 +158,7 @@ jythonArgs += flag else: jythonArgs = flag + jythonArgs = jythonArgs.replace('%%', '%') # workaround two .bat files args.append(flag) process = StarterProcess() out = process.run(args, javaHome, jythonHome, jythonOpts) @@ -267,11 +268,19 @@ self.assertOutput(['-J-DmyProperty=myValue']) def test_property_singlequote(self): - self.assertOutput(["-J-DmyProperty='myValue'"]) # a space inside value does not work in jython.bat + self.assertOutput(["-J-DmyProperty='myValue'"]) + # a space inside value does not work in jython.bat + def __test_property_singlequote_space(self): + self.assertOutput(["-J-DmyProperty='my Value'"]) + def test_property_doublequote(self): - self.assertOutput(['-J-DmyProperty="myValue"']) # a space inside value does not work in jython.bat + self.assertOutput(['-J-DmyProperty="myValue"']) + # a space inside value does not work in jython.bat + def __test_property_doublequote_space(self): + self.assertOutput(['-J-DmyProperty="my Value"']) + def test_property_underscore(self): self.assertOutput(['-J-Dmy_Property=my_Value']) @@ -338,6 +347,36 @@ def test_star_existing_singlequoted(self): self.assertOutput(['-c', 'import sys; print sys.argv[1:]', "'*.bat'", "'*.bat'"]) +class ArgsSpacesTest(BaseTest): + def test_doublequoted(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', '"part1 part2"', '2nd']) + + def test_singlequoted(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', "'part1 part2'", '2nd']) + + # this test currently fails + def __test_unbalanced_doublequote(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', 'Scarlet O"Hara', '2nd']) + + def test_unbalanced_singlequote(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', "Scarlet O'Hara", '2nd']) + +class ArgsSpecialCharsTest(BaseTest): + # exclamation marks are still very special ... + def __test_exclamationmark(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', 'foo!', 'ba!r', '!baz', '!']) + + # because we go through a starter.bat file, we have to simulate % with %% + def test_percentsign(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', 'foo%%1', '%%1bar', '%%1', '%%']) + + def test_colon(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', 'foo:', ':bar']) + + # a semicolon at the beginning of an arg currently fails (e.g. ;bar) + def test_semicolon(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', 'foo;']) + class DummyTest(unittest.TestCase): def test_nothing(self): pass @@ -351,7 +390,9 @@ JavaOptsTest, ArgsTest, DoubleDashTest, - GlobPatternTest) + GlobPatternTest, + ArgsSpacesTest, + ArgsSpecialCharsTest) else: # provide at least one test for the other platforms - happier build bots test_support.run_unittest(DummyTest) Modified: trunk/jython/src/shell/jython.bat =================================================================== --- trunk/jython/src/shell/jython.bat 2010-06-15 06:33:20 UTC (rev 7064) +++ trunk/jython/src/shell/jython.bat 2010-06-15 06:34:16 UTC (rev 7065) @@ -18,6 +18,8 @@ goto finish :normalstart +set _PERCENT=%% +set _EXCLAMATION=! setlocal enabledelayedexpansion rem ----- Verify and set required environment variables ----------------------- @@ -25,21 +27,21 @@ set _JAVA_CMD=java rem remove surrounding quotes from java home, to be able to safely empty-test it set _TRIMMED_JAVA_HOME=%JAVA_HOME% -for /f "useback tokens=*" %%a in ('%_TRIMMED_JAVA_HOME%') do set _TRIMMED_JAVA_HOME=%%~a +for /f "usebackq tokens=*" %%a in ('%_TRIMMED_JAVA_HOME%') do set _TRIMMED_JAVA_HOME=%%~a if not "%_TRIMMED_JAVA_HOME%"=="" ( set _JAVA_CMD="%JAVA_HOME:"=%\bin\java" ) rem remove surrounding quotes from jython opts, to be able to safely empty-test it set _TRIMMED_JYTHON_OPTS=%JYTHON_OPTS% -for /f "useback tokens=*" %%a in ('%_TRIMMED_JYTHON_OPTS%') do set _TRIMMED_JYTHON_OPTS=%%~a +for /f "usebackq tokens=*" %%a in ('%_TRIMMED_JYTHON_OPTS%') do set _TRIMMED_JYTHON_OPTS=%%~a if not "%_TRIMMED_JYTHON_OPTS%"=="" ( set _JYTHON_OPTS="%_TRIMMED_JYTHON_OPTS%" ) rem remove surrounding quotes from jython home, to be able to safely empty-test it set _TRIMMED_JYTHON_HOME=%JYTHON_HOME% -for /f "useback tokens=*" %%a in ('%_TRIMMED_JYTHON_HOME%') do set _TRIMMED_JYTHON_HOME=%%~a +for /f "usebackq tokens=*" %%a in ('%_TRIMMED_JYTHON_HOME%') do set _TRIMMED_JYTHON_HOME=%%~a if not "%_TRIMMED_JYTHON_HOME%"=="" ( set _JYTHON_HOME="%_TRIMMED_JYTHON_HOME%" goto gotHome @@ -95,6 +97,10 @@ set _ARGS=%_ARGS:_=_U% set _ARGS=%_ARGS:'=_S% set _ARGS=%_ARGS:"=_D% +rem also escape % signs +set _replaceVal=%_ARGS% +call :escape +set _ARGS=%_replaceVal% set _ARGS="%_ARGS%" set _JYTHON_ARGS= @@ -140,7 +146,10 @@ goto :nextArg ) -rem now unescape _D, _S and _U +rem now unescape everything +set _replaceVal=%_CMP% +call :escape +set _CMP=%_replaceVal% set _CMP=%_CMP:_D="% set _CMP=%_CMP:_S='% set _CMP=%_CMP:_U=_% @@ -210,6 +219,80 @@ set _TRIMMED_JAVA_HOME= set _TRIMMED_JYTHON_HOME= set _TRIMMED_JYTHON_OPTS= +goto finish + + +REM escapes or unescapes % with @@P@@, and ! with @@E@@ +REM input: a text variable named _replaceVal +REM result: _replaceVal has the new value +:escape +if not defined _replaceVal goto :EOF +set /a _index=-1 +set _replaced= + +:escapeNext +set /a _index=%_index% + 1 +call set _escapeChar=%%_replaceVal:~%_index%,1%% +if ^"==^%_escapeChar% goto noEscape +if ''=='%_escapeChar%' goto escapeEnd +if "%_escapeChar%"==" " goto noEscape +if "%_escapeChar%"=="@" goto unescapeCheck +if "%_escapeChar%"=="%_EXCLAMATION%" goto escapeExclamation +if "%_escapeChar%"=="%_PERCENT%" goto escapePercent +:noEscape +set _replaced=%_replaced%%_escapeChar% +goto escapeNext + +:escapeExclamation +set _replaced=%_replaced%@@E@@ +goto escapeNext + +:escapePercent +set _replaced=%_replaced%@@P@@ +goto escapeNext + +:unescapeCheck +set _isExclamation= +set _isPercent= +set _isUnrecognized=true +set /a _aheadIndex=%_index% + 1 +call set _aheadChar=%%_replaceVal:~%_aheadIndex%,1%% +if ^"==^%_aheadChar% goto noEscape +if "%_aheadChar%"=="@" set /a _aheadIndex=%_aheadIndex% + 1 +call set _aheadChar=%%_replaceVal:~%_aheadIndex%,1%% +if ^"==^%_aheadChar% goto noEscape +if "%_aheadChar%"=="E" set _isExclamation=true & set _isUnrecognized= +if "%_aheadChar%"=="P" set _isPercent=true & set _isUnrecognized= +if defined _isUnrecognized goto noEscape +set _isUnrecognized=true +set /a _aheadIndex=%_aheadIndex% + 1 +call set _aheadChar=%%_replaceVal:~%_aheadIndex%,1%% +if ^"==^%_aheadChar% goto noEscape +if "%_aheadChar%"=="@" set /a _aheadIndex=%_aheadIndex% + 1 +call set _aheadChar=%%_replaceVal:~%_aheadIndex%,1%% +if ^"==^%_aheadChar% goto noEscape +if "%_aheadChar%"=="@" set _isUnrecognized= +if defined _isUnrecognized goto noEscape +if defined _isExclamation goto unescapeExclamation +if defined _isPercent goto unescapePercent +goto noEscape + +:unescapeExclamation +set _replaced=%_replaced%%_EXCLAMATION% +set /a _index=%_index% + 4 +goto escapeNext + +:unescapePercent +set _replaced=%_replaced%%_PERCENT% +set /a _index=%_index% + 4 +goto escapeNext + +:escapeEnd +set _replaceVal=%_replaced% +goto :EOF + + + :finish %COMSPEC% /c exit /b %E% This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-06-15 06:33:26
|
Revision: 7064 http://jython.svn.sourceforge.net/jython/?rev=7064&view=rev Author: otmarhumbel Date: 2010-06-15 06:33:20 +0000 (Tue, 15 Jun 2010) Log Message: ----------- require subprocess again Modified Paths: -------------- trunk/jython/Lib/test/test_subprocess.py Modified: trunk/jython/Lib/test/test_subprocess.py =================================================================== --- trunk/jython/Lib/test/test_subprocess.py 2010-06-03 03:53:11 UTC (rev 7063) +++ trunk/jython/Lib/test/test_subprocess.py 2010-06-15 06:33:20 UTC (rev 7064) @@ -707,8 +707,7 @@ def test_main(): # Spawning many new jython processes takes a long time - # TODO:oti uncomment the next line as soon as the fix to #1356 is verified on the build bots - #test_support.requires('subprocess') + test_support.requires('subprocess') test_support.run_unittest(ProcessTestCase) if hasattr(test_support, "reap_children"): test_support.reap_children() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2010-06-03 03:53:18
|
Revision: 7063 http://jython.svn.sourceforge.net/jython/?rev=7063&view=rev Author: pjenvey Date: 2010-06-03 03:53:11 +0000 (Thu, 03 Jun 2010) Log Message: ----------- fix caching of packages with dir listings larger than the 64k DataOutputStream UTF-8 string limit. changes the packagecache on disk format but in a backwards compatible way fixes #1595 patch from bpedman Modified Paths: -------------- trunk/jython/NEWS trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java Added Paths: ----------- trunk/jython/tests/java/org/python/core/packagecache/ trunk/jython/tests/java/org/python/core/packagecache/CachedJarsOver64kTest.java trunk/jython/tests/java/org/python/core/packagecache/vim25-small.jar Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-06-03 02:38:42 UTC (rev 7062) +++ trunk/jython/NEWS 2010-06-03 03:53:11 UTC (rev 7063) @@ -48,6 +48,7 @@ - [ 1567 ] [Windows] Wildcard Parameter * gets expanded to filename - [ 1594 ] Glob patterns like *.txt processed incorrectly on startup - [ 1356 ] [Windows] test_subprocess test_communicate_pipe_buf fails + - [ 1595 ] [patch] CachedJarsPackageManager cannot write cache for packages in jar over 64k - Fix runtime issues during exitfuncs triggered via SystemRestart (such as during Django or Pylons development mode reloading) - Fix pickling of collections.defaultdict objects Modified: trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2010-06-03 02:38:42 UTC (rev 7062) +++ trunk/jython/src/org/python/core/packagecache/CachedJarsPackageManager.java 2010-06-03 03:53:11 UTC (rev 7063) @@ -371,6 +371,14 @@ while (true) { String packageName = istream.readUTF(); String classes = istream.readUTF(); + // XXX: Handle multiple chunks of classes and concatenate them + // together. Multiple chunks were added in 2.5.2 (for #1595) in this + // way to maintain compatibility with the pre 2.5.2 format. In the + // future we should consider changing the cache format to prepend a + // count of chunks to avoid this check + if (packs.containsKey(packageName)) { + classes = packs.get(packageName) + classes; + } packs.put(packageName, classes); } } catch (EOFException eof) { @@ -396,8 +404,12 @@ for (Entry<String,String> kv : zipPackages.entrySet()) { String classes = kv.getValue(); - ostream.writeUTF(kv.getKey()); - ostream.writeUTF(classes); + // Make sure each package is not larger than 64k + for (String part : splitString(classes, 65535)) { + // For each chunk, write the package name followed by the classes. + ostream.writeUTF(kv.getKey()); + ostream.writeUTF(part); + } } ostream.close(); } catch (IOException ioe) { @@ -406,6 +418,35 @@ } /** + * Split up a string into several chunks based on a certain size + * + * The writeCacheFile method will use the writeUTF method on a + * DataOutputStream which only allows writing 64k chunks, so use + * this utility method to split it up + * + * @param str - The string to split up into chunks + * @param maxLength - The max size a string should be + * @return - An array of strings, each of which will not be larger than maxLength + */ + protected static String[] splitString(String str, int maxLength) { + if (str == null) { + return null; + } + + int len = str.length(); + if (len <= maxLength) { + return new String[] {str}; + } + + int chunkCount = (int) Math.ceil((float) len / maxLength); + String[] chunks = new String[chunkCount]; + for (int i = 0; i < chunkCount; i++) { + chunks[i] = str.substring(i * maxLength, Math.min(i * maxLength + maxLength, len)); + } + return chunks; + } + + /** * Initializes cache. Eventually reads back cache index. Index persistent * storage is accessed through inOpenIndex(). */ Added: trunk/jython/tests/java/org/python/core/packagecache/CachedJarsOver64kTest.java =================================================================== --- trunk/jython/tests/java/org/python/core/packagecache/CachedJarsOver64kTest.java (rev 0) +++ trunk/jython/tests/java/org/python/core/packagecache/CachedJarsOver64kTest.java 2010-06-03 03:53:11 UTC (rev 7063) @@ -0,0 +1,63 @@ +package org.python.core.packagecache; + +import java.io.File; + +import org.python.core.PyJavaPackage; +import org.python.core.PyList; +import org.python.core.packagecache.CachedJarsPackageManager; + +import junit.framework.TestCase; + +public class CachedJarsOver64kTest extends TestCase { + + private TestCachePackageManager packageManager = null; + + private File jarFile = null; + + @Override + public void setUp() { + // Find the jar to use + packageManager = new TestCachePackageManager(new File(System + .getProperty("java.io.tmpdir"))); + File cwd = new File(System.getProperty("python.test.source.dir"), + getClass().getPackage().getName().replace(".", "/")); + jarFile = new File(cwd, "vim25-small.jar"); + } + + public void testJarOver64k() { + assertTrue(jarFile.exists()); + packageManager.addJarToPackages(jarFile, true); + assertFalse(packageManager.failed); + } + + private class TestCachePackageManager extends CachedJarsPackageManager { + + public boolean failed; + + public TestCachePackageManager(File cachedir) { + if (useCacheDir(cachedir)){ + initCache(); + } + } + + @Override + protected void warning(String msg){ + failed = true; + } + + @Override + public void addDirectory(File dir) {} + @Override + public void addJar(String jarfile, boolean cache) {} + @Override + public void addJarDir(String dir, boolean cache) {} + @Override + public PyList doDir(PyJavaPackage jpkg, boolean instantiate, boolean exclpkgs) { + return null; + } + @Override + public Class<?> findClass(String pkg, String name, String reason) { return null; } + @Override + public boolean packageExists(String pkg, String name) { return false; } + } +} Added: trunk/jython/tests/java/org/python/core/packagecache/vim25-small.jar =================================================================== (Binary files differ) Property changes on: trunk/jython/tests/java/org/python/core/packagecache/vim25-small.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2010-06-03 02:38:49
|
Revision: 7062 http://jython.svn.sourceforge.net/jython/?rev=7062&view=rev Author: pjenvey Date: 2010-06-03 02:38:42 +0000 (Thu, 03 Jun 2010) Log Message: ----------- simplify Modified Paths: -------------- trunk/jython/src/org/python/core/PyObject.java Modified: trunk/jython/src/org/python/core/PyObject.java =================================================================== --- trunk/jython/src/org/python/core/PyObject.java 2010-06-01 23:30:30 UTC (rev 7061) +++ trunk/jython/src/org/python/core/PyObject.java 2010-06-03 02:38:42 UTC (rev 7062) @@ -281,9 +281,9 @@ // convert faux floats // XXX: should also convert faux ints, but that breaks test_java_visibility // (ReflectedArgs resolution) - if (c == Double.TYPE || c == Double.class || c == Float.TYPE || c == Float.class) { + if (c == Double.class || c == Float.class) { try { - return __float__().getValue(); + return __float__().asDouble(); } catch (PyException pye) { if (!pye.match(Py.AttributeError)) { throw pye; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-06-01 23:30:36
|
Revision: 7061 http://jython.svn.sourceforge.net/jython/?rev=7061&view=rev Author: otmarhumbel Date: 2010-06-01 23:30:30 +0000 (Tue, 01 Jun 2010) Log Message: ----------- add the fixed #1567, #1594 and #1356 to the news Many thanks to Pekka Klaerck and Andreas Ebbert-Karroum for their analysis and suggestions! Modified Paths: -------------- trunk/jython/NEWS Modified: trunk/jython/NEWS =================================================================== --- trunk/jython/NEWS 2010-06-01 22:59:22 UTC (rev 7060) +++ trunk/jython/NEWS 2010-06-01 23:30:30 UTC (rev 7061) @@ -45,6 +45,9 @@ - [ 1385 ] generator.throw uncaught on new generator doesn't stop the generator - [ 1596 ] SynchronizedCallable does not report that it is callable [suggested fix] - [ 1557 ] jython.bat doesn't work in 4nt + - [ 1567 ] [Windows] Wildcard Parameter * gets expanded to filename + - [ 1594 ] Glob patterns like *.txt processed incorrectly on startup + - [ 1356 ] [Windows] test_subprocess test_communicate_pipe_buf fails - Fix runtime issues during exitfuncs triggered via SystemRestart (such as during Django or Pylons development mode reloading) - Fix pickling of collections.defaultdict objects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-06-01 22:59:28
|
Revision: 7060 http://jython.svn.sourceforge.net/jython/?rev=7060&view=rev Author: otmarhumbel Date: 2010-06-01 22:59:22 +0000 (Tue, 01 Jun 2010) Log Message: ----------- do not expand * in arguments any more (expected to fix #1567, #1594 and #1356) many thanks to Pekka Kl?\195?\164rck and Andreas Ebbert-Karroum for their analysis and suggestions! Modified Paths: -------------- trunk/jython/Lib/test/test_bat_jy.py trunk/jython/Lib/test/test_subprocess.py trunk/jython/src/shell/jython.bat Modified: trunk/jython/Lib/test/test_bat_jy.py =================================================================== --- trunk/jython/Lib/test/test_bat_jy.py 2010-05-31 04:36:44 UTC (rev 7059) +++ trunk/jython/Lib/test/test_bat_jy.py 2010-06-01 22:59:22 UTC (rev 7060) @@ -291,6 +291,12 @@ def test_doublequoted(self): self.assertOutput(['-c', '"print \'something\'"']) + def test_nestedquotes(self): + self.assertOutput(['-c', '"print \'something \"really\" cool\'"']) + + def test_nestedquotes2(self): + self.assertOutput(['-c', "'print \"something \'really\' cool\"'"]) + def test_underscored(self): self.assertOutput(['-jar', 'my_stuff.jar']) @@ -313,6 +319,25 @@ def test_jdb(self): self.assertOutput(['--jdb']) +class GlobPatternTest(BaseTest): + def test_star_nonexisting(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', '*.nonexisting', '*.nonexisting']) + + def test_star_nonexisting_doublequoted(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', '"*.nonexisting"', '"*.nonexisting"']) + + def test_star_nonexistingfile_singlequoted(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', "'*.nonexisting'", "'*.nonexisting'"]) + + def test_star_existing(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', '*.bat', '*.bat']) + + def test_star_existing_doublequoted(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', '"*.bat"', '"*.bat"']) + + def test_star_existing_singlequoted(self): + self.assertOutput(['-c', 'import sys; print sys.argv[1:]', "'*.bat'", "'*.bat'"]) + class DummyTest(unittest.TestCase): def test_nothing(self): pass @@ -325,7 +350,8 @@ JythonOptsTest, JavaOptsTest, ArgsTest, - DoubleDashTest) + DoubleDashTest, + GlobPatternTest) else: # provide at least one test for the other platforms - happier build bots test_support.run_unittest(DummyTest) Modified: trunk/jython/Lib/test/test_subprocess.py =================================================================== --- trunk/jython/Lib/test/test_subprocess.py 2010-05-31 04:36:44 UTC (rev 7059) +++ trunk/jython/Lib/test/test_subprocess.py 2010-06-01 22:59:22 UTC (rev 7060) @@ -707,7 +707,8 @@ def test_main(): # Spawning many new jython processes takes a long time - test_support.requires('subprocess') + # TODO:oti uncomment the next line as soon as the fix to #1356 is verified on the build bots + #test_support.requires('subprocess') test_support.run_unittest(ProcessTestCase) if hasattr(test_support, "reap_children"): test_support.reap_children() Modified: trunk/jython/src/shell/jython.bat =================================================================== --- trunk/jython/src/shell/jython.bat 2010-05-31 04:36:44 UTC (rev 7059) +++ trunk/jython/src/shell/jython.bat 2010-06-01 22:59:22 UTC (rev 7060) @@ -106,7 +106,7 @@ :getArg rem remove quotes around first arg -for %%i in (%1) do set _CMP=%%~i +set _CMP=%~1 set _ARGS=%2 goto :EOF @@ -140,7 +140,7 @@ goto :nextArg ) -rem now unescape _D, _S and _Q +rem now unescape _D, _S and _U set _CMP=%_CMP:_D="% set _CMP=%_CMP:_S='% set _CMP=%_CMP:_U=_% This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2010-05-31 04:36:50
|
Revision: 7059 http://jython.svn.sourceforge.net/jython/?rev=7059&view=rev Author: otmarhumbel Date: 2010-05-31 04:36:44 +0000 (Mon, 31 May 2010) Log Message: ----------- for the build bot, try to specify a real java home Modified Paths: -------------- trunk/jython/Lib/test/test_bat_jy.py Modified: trunk/jython/Lib/test/test_bat_jy.py =================================================================== --- trunk/jython/Lib/test/test_bat_jy.py 2010-05-25 05:40:14 UTC (rev 7058) +++ trunk/jython/Lib/test/test_bat_jy.py 2010-05-31 04:36:44 UTC (rev 7059) @@ -9,6 +9,7 @@ from java.lang import IllegalThreadStateException from java.lang import Runtime +from java.lang import System from java.lang import Thread from java.io import File from java.io import BufferedReader; @@ -210,7 +211,9 @@ class JavaHomeTest(BaseTest): def test_unquoted(self): - self.assertOutput(javaHome='C:\\Program Files\\Java\\someJava') + # for the build bot, try to specify a real java home + javaHome = System.getProperty('java.home', 'C:\\Program Files\\Java\\someJava') + self.assertOutput(javaHome=javaHome) def test_quoted(self): self.assertOutput(javaHome=self.quote('C:\\Program Files\\Java\\someJava')) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |