From: <fwi...@us...> - 2011-03-13 03:32:58
|
Revision: 7221 http://jython.svn.sourceforge.net/jython/?rev=7221&view=rev Author: fwierzbicki Date: 2011-03-13 03:32:51 +0000 (Sun, 13 Mar 2011) Log Message: ----------- Switching to CPython 2.6 Lib + get regrtest to at least have lots of fail instead of just crashing outright. Modified Paths: -------------- trunk/jython/Lib/socket.py trunk/jython/Lib/test/regrtest.py trunk/jython/src/org/python/core/__builtin__.java trunk/jython/src/org/python/modules/_functools/_functools.java Property Changed: ---------------- trunk/jython/ Property changes on: trunk/jython ___________________________________________________________________ Modified: svn:externals - CPythonLib -r70085 https://svn.python.org/projects/python/branches/release25-maint/Lib/ + CPythonLib -r88766 https://svn.python.org/projects/python/branches/release26-maint/Lib/ Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2011-03-12 20:13:35 UTC (rev 7220) +++ trunk/jython/Lib/socket.py 2011-03-13 03:32:51 UTC (rev 7221) @@ -1506,6 +1506,7 @@ raise StopIteration return line +_GLOBAL_DEFAULT_TIMEOUT = object() # Define the SSL support Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2011-03-12 20:13:35 UTC (rev 7220) +++ trunk/jython/Lib/test/regrtest.py 2011-03-13 03:32:51 UTC (rev 7221) @@ -553,11 +553,12 @@ else: cfp = cStringIO.StringIO() + from test.junit_xml import Tee, write_direct_test try: save_stdout = sys.stdout + + indirect_test = None if junit_xml_dir: - from test.junit_xml import Tee, write_direct_test - indirect_test = None save_stderr = sys.stderr sys.stdout = stdout = Tee(sys.stdout) sys.stderr = stderr = Tee(sys.stderr) @@ -1445,6 +1446,15 @@ test_winreg test_winsound test_zipfile64 + + test_gzip + test_ftplib + test_logging + test_poplib + test_pydoc + test_queue + test_smtplib + test_telnetlib """ } _expectations['freebsd5'] = _expectations['freebsd4'] Modified: trunk/jython/src/org/python/core/__builtin__.java =================================================================== --- trunk/jython/src/org/python/core/__builtin__.java 2011-03-12 20:13:35 UTC (rev 7220) +++ trunk/jython/src/org/python/core/__builtin__.java 2011-03-13 03:32:51 UTC (rev 7221) @@ -15,6 +15,8 @@ import org.python.antlr.base.mod; import org.python.core.util.RelativeFile; +import org.python.modules._functools._functools; + class BuiltinFunctions extends PyBuiltinFunctionSet { public static final PyObject module = Py.newString("__builtin__"); @@ -167,7 +169,7 @@ case 33: return __builtin__.pow(arg1, arg2); case 35: - return __builtin__.reduce(arg1, arg2); + return _functools.reduce(arg1, arg2); case 29: return fancyCall(new PyObject[] {arg1, arg2}); case 30: @@ -209,7 +211,7 @@ case 33: return __builtin__.pow(arg1, arg2, arg3); case 35: - return __builtin__.reduce(arg1, arg2, arg3); + return _functools.reduce(arg1, arg2, arg3); case 39: __builtin__.setattr(arg1, arg2, arg3); return Py.None; Modified: trunk/jython/src/org/python/modules/_functools/_functools.java =================================================================== --- trunk/jython/src/org/python/modules/_functools/_functools.java 2011-03-12 20:13:35 UTC (rev 7220) +++ trunk/jython/src/org/python/modules/_functools/_functools.java 2011-03-13 03:32:51 UTC (rev 7221) @@ -21,4 +21,35 @@ // Hide from Python dict.__setitem__("classDictInit", null); } + + public static PyString __doc__reduce = new PyString( + "reduce(function, sequence[, initial]) -> value\n\n" + + "Apply a function of two arguments cumulatively to the items of a sequence,\n" + + "from left to right, so as to reduce the sequence to a single value.\n" + + "For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates\n" + + "((((1+2)+3)+4)+5). If initial is present, it is placed before the items\n" + + "of the sequence in the calculation, and serves as a default when the\n" + + "sequence is empty."); + + public static PyObject reduce(PyObject f, PyObject l, PyObject z) { + PyObject result = z; + PyObject iter = Py.iter(l, "reduce() arg 2 must support iteration"); + + for (PyObject item; (item = iter.__iternext__()) != null;) { + if (result == null) { + result = item; + } else { + result = f.__call__(result, item); + } + } + if (result == null) { + throw Py.TypeError("reduce of empty sequence with no initial value"); + } + return result; + } + + public static PyObject reduce(PyObject f, PyObject l) { + return reduce(f, l, null); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |