From: <fwi...@us...> - 2009-03-02 03:29:34
|
Revision: 6054 http://jython.svn.sourceforge.net/jython/?rev=6054&view=rev Author: fwierzbicki Date: 2009-03-02 03:29:30 +0000 (Mon, 02 Mar 2009) Log Message: ----------- Merged revisions 5934-5947,5950-5951,5953-5957,5959,5961,5965-5966,5971-5976,5978-5979,5981-5983,5992,6001,6003,6006-6014,6023,6031-6037,6039-6040,6045-6047,6049-6052 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ................ r5934 | fwierzbicki | 2009-01-14 22:36:09 -0500 (Wed, 14 Jan 2009) | 3 lines Change negate so that -0 and -0.0 behave as CPython behaves (no USub node, just negate zero). ................ r5935 | cgroves | 2009-01-16 03:11:48 -0500 (Fri, 16 Jan 2009) | 6 lines underlying_class is the class of instances of this type, so PyJavaType shouldn't store the class it's wrapping in it. Instead, it should use the general javaProxy field on PyObject and leave underlying_class up to its bases. Without this, Python classes can't subclass a Java interface and a Python class subclassing a Java class or interface. ................ r5936 | cgroves | 2009-01-16 04:17:19 -0500 (Fri, 16 Jan 2009) | 4 lines Check for parent beans of the same name to fill in missing getters or setters when adding beans for a type. Fixes bug #1132. Thanks to garyh for tracking it down and supplying a test case. ................ r5937 | zyasoft | 2009-01-17 13:12:57 -0500 (Sat, 17 Jan 2009) | 6 lines Fixes #1227 where for cStringIO.StringIO, orderings of method calls like write-seek-write did not properly work. This also addresses a problem for PyAMF support. Thanks go to Nick Joyce for the patch! ................ r5938 | zyasoft | 2009-01-17 13:31:06 -0500 (Sat, 17 Jan 2009) | 6 lines Fixes #1217 where we report the underlying Java error (java.util.zip.DataFormatException) instead of the standard Python one (zlib.error). This also helps support PyAMF on Jython. Thanks Nick Joyce for the patch. ................ r5939 | cgroves | 2009-01-17 13:42:14 -0500 (Sat, 17 Jan 2009) | 1 line Shoulda gone out with r5607. ................ r5940 | cgroves | 2009-01-17 15:35:09 -0500 (Sat, 17 Jan 2009) | 3 lines Add some tests for overriding attribute lookup and adding mapping methods to wrapped Java types. ................ r5941 | cgroves | 2009-01-17 15:56:28 -0500 (Sat, 17 Jan 2009) | 5 lines Implement Iterable in PyIterator. This means generators are usable in foreach loops. The implementation could be moved up to PyObject, but I feel like implementing the interface says that the object will be iterable, and not all PyObjects provide an __iter__. ................ r5942 | cgroves | 2009-01-17 17:36:27 -0500 (Sat, 17 Jan 2009) | 3 lines Resurrect some PyJavaClass code to fix bug #1235. ................ r5943 | cgroves | 2009-01-17 18:57:54 -0500 (Sat, 17 Jan 2009) | 1 line Match the statuses from CPython ................ r5944 | cgroves | 2009-01-17 19:53:10 -0500 (Sat, 17 Jan 2009) | 1 line ecj likes this, but javac disputes that it's compilable, so go back to the old way ................ r5945 | cgroves | 2009-01-18 05:04:29 -0500 (Sun, 18 Jan 2009) | 7 lines Add an Ant task to compile .py files to $py.class. It runs on Lib as part of developer-build to exercise it a little bit. Also, only rename the xerces parts of org.apache. Otherwise our ant imports get renamed when jarjaring. ................ r5946 | otmarhumbel | 2009-01-18 08:46:12 -0500 (Sun, 18 Jan 2009) | 9 lines enable running jython from a directory with an exclamation mark in it's name due to jdk limitations this is only possible for + jdk 1.6 and higher + directory names not ending with an exclamation mark due to the special treatment of exclamation marks in enabledelayedexpansion, this is currently not possible for jython.bat on windows installer autotests now use an exclamation mark if possible ................ r5947 | otmarhumbel | 2009-01-19 16:43:36 -0500 (Mon, 19 Jan 2009) | 2 lines add xercesImpl as zipfileset to jarjar again: without this, there are no org.python.apache.* packages in jython.jar ................ r5950 | zyasoft | 2009-01-20 13:28:03 -0500 (Tue, 20 Jan 2009) | 4 lines Added os.getcwdu. This fixes #1219 (necessary for Django 1.0.2 support), but not the larger question of better Unicode handling in the os module, specifically around os.path. ................ r5951 | leosoto | 2009-01-20 14:29:17 -0500 (Tue, 20 Jan 2009) | 1 line Use the new getcwdu on POSIXHandler, to avoid unnecesary conversions from unicode to bytestring. Also added getcwdu to os.__all__ ................ r5953 | cgroves | 2009-01-21 15:47:19 -0500 (Wed, 21 Jan 2009) | 1 line Break out the compile method for use in subclasses ................ r5954 | cgroves | 2009-01-21 16:26:50 -0500 (Wed, 21 Jan 2009) | 1 line Turn includeJavaStackInExceptions on by default as it was always done in previous versions. ................ r5955 | cgroves | 2009-01-21 18:32:55 -0500 (Wed, 21 Jan 2009) | 8 lines Add a jython initializer service. If META-INF/services/org.python.core.JythonInitializer is on the classpath, the class named in that file will be instantiated and used in Jython's initialization. This is useful when Jython is initialized by a library outside of your control, but some customization still needs to be done to Jython's environment. I promise not to add a JythonFactory or a JythonFactoryFactory. ................ r5956 | fwierzbicki | 2009-01-21 21:21:08 -0500 (Wed, 21 Jan 2009) | 4 lines Fix for http://bugs.jython.org/issue1239. When jars where added to sys.path, they did not always trigger package caching, leading to unexpected import failures. This is Charlie Grove's fix, which was much better than mine. ................ r5957 | fwierzbicki | 2009-01-21 23:16:47 -0500 (Wed, 21 Jan 2009) | 7 lines Thanks to Marc Downie for this patch that fixes http://bugs.jython.org/issue1230 importing with '*' from java packages does not work with 2.5b1. Also added a test to test_java_integration.py. ................ r5959 | cgroves | 2009-01-22 14:50:18 -0500 (Thu, 22 Jan 2009) | 1 line Expose rich comparision methods on Java classes implementing Comparable ................ r5961 | fwierzbicki | 2009-01-22 20:03:39 -0500 (Thu, 22 Jan 2009) | 3 lines Over-ride pyset in PyTuple so our tuples go back to being immutable. Fixes http://bugs.jython.org/issue1242. ................ r5965 | pjenvey | 2009-01-23 18:40:46 -0500 (Fri, 23 Jan 2009) | 2 lines more java.lang.Strings to regular str instead of unicode ................ r5966 | pjenvey | 2009-01-23 19:17:40 -0500 (Fri, 23 Jan 2009) | 3 lines merge from: http://svn.python.org/projects/python/branches/release25-maint/Lib/platform.py -c 66214 ................ r5971 | cgroves | 2009-01-24 15:10:59 -0500 (Sat, 24 Jan 2009) | 1 line Run the java import * test from a sub-interpreter to allow regrtest to be run with python.cachedir.skip=true ................ r5972 | cgroves | 2009-01-24 15:11:54 -0500 (Sat, 24 Jan 2009) | 1 line Try the current classloader for places where the context classloader isn't set ................ r5973 | cgroves | 2009-01-24 15:17:39 -0500 (Sat, 24 Jan 2009) | 1 line Exclude the xerces service declaration as our jarjar'd version doesn't match the names in the declaration ................ r5974 | cgroves | 2009-01-25 07:15:25 -0500 (Sun, 25 Jan 2009) | 1 line Bring up to the current state of affairs ................ r5975 | cgroves | 2009-01-25 07:19:27 -0500 (Sun, 25 Jan 2009) | 3 lines Use Python's mro to determine an mro for Java classes and interfaces. If the Java class has an mro conflict, resolve it by arbitrarily choosing an interface or class. If an interface or class involved in an mro conflict has had its dict modified, or has its dict modified, raise a TypeError. ................ r5976 | cgroves | 2009-01-25 07:19:58 -0500 (Sun, 25 Jan 2009) | 1 line Test support classes for the last commit ................ r5978 | nriley | 2009-01-25 16:06:04 -0500 (Sun, 25 Jan 2009) | 1 line Typo fix. ................ r5979 | cgroves | 2009-01-25 19:33:21 -0500 (Sun, 25 Jan 2009) | 4 lines Include Python Java subclasses as bases as well as the Java proxy type, as it may have additional methods in its Python. Return the proxyClass directly from getProxyType as we're setting that on Python subclasses now. ................ r5981 | cgroves | 2009-01-25 21:21:05 -0500 (Sun, 25 Jan 2009) | 1 line Defer resolving inner classes till the containing class is fully resolved. Fixes issue #1234. ................ r5982 | cgroves | 2009-01-25 22:10:36 -0500 (Sun, 25 Jan 2009) | 1 line Try to assign to a static field for a given name in __setattr__ on a Java type before filling something in on the dict. Fixes bug #1241 ................ r5983 | cgroves | 2009-01-25 22:36:25 -0500 (Sun, 25 Jan 2009) | 1 line Fix javatests ................ r5992 | amak | 2009-01-28 11:05:59 -0500 (Wed, 28 Jan 2009) | 3 lines Fix and unit test for bug 1244. Problem letting system choose the port for binding UDP socket http://bugs.jython.org/issue1244 ................ r6001 | amak | 2009-01-29 12:59:04 -0500 (Thu, 29 Jan 2009) | 2 lines Re-arranging the socket shutdown methods. TCP client sockets can shutdown their input streams, but this is not appropriate for either TCP server sockets or UDP sockets, which don't have input and output streams. For these latter two types, the shutdown method should have the same effect as the close method, and thus the shutdown method is a no-op for these types. I have documented this difference between cpython and jython on the wiki. This should finally resolve bug 1121: listening socket shutdown expects the wrong kind of socket http://bugs.jython.org/issue1121 ................ r6003 | pjenvey | 2009-01-30 21:20:48 -0500 (Fri, 30 Jan 2009) | 1 line make --version resemble CPython ................ r6006 | amak | 2009-02-02 10:50:25 -0500 (Mon, 02 Feb 2009) | 4 lines Fix for bug 1258. select() semantics differ from CPython, causing pydoc HTTPd to fail http://bugs.jython.org/issue1258 Thanks to Ryan Blair for reporting the bug and providing a patch. ................ r6007 | amak | 2009-02-03 07:01:46 -0500 (Tue, 03 Feb 2009) | 2 lines Committing the latest version of modjy. See the release notes for details. ................ r6008 | pjenvey | 2009-02-03 15:19:57 -0500 (Tue, 03 Feb 2009) | 1 line fix test_version per r6003 ................ r6009 | pjenvey | 2009-02-03 16:25:23 -0500 (Tue, 03 Feb 2009) | 2 lines include PATH for platforms lacking bash in /bin ................ r6010 | leosoto | 2009-02-03 19:51:47 -0500 (Tue, 03 Feb 2009) | 1 line PyObject#reduce_2: Use invoke("iteritems") instead of this.iteritems() to avoid problems with dict subclasses which override iteritems on python code. Fixes #1257 ................ r6011 | amak | 2009-02-04 10:20:56 -0500 (Wed, 04 Feb 2009) | 4 lines Our asyncore is completely broken; see bug 1237. Asnycore does not seem to work in Jython 2.5 (b0 or b1) http://bugs.jython.org/issue1237 Starting again from scratch; Step 1: remove existing module. ................ r6012 | amak | 2009-02-04 10:22:21 -0500 (Wed, 04 Feb 2009) | 1 line Fresh start with asyncore; step 2: copy over asyncore from cpython 2.5.2. ................ r6013 | amak | 2009-02-04 10:27:59 -0500 (Wed, 04 Feb 2009) | 3 lines Fresh start with asycnore; step 3: make necessary changes to cpython 2.5 module to work on jython 2.5. The code in this bug report now works identically to cpython. http://bugs.jython.org/issue1237 ................ r6014 | otmarhumbel | 2009-02-05 13:08:10 -0500 (Thu, 05 Feb 2009) | 1 line added dummy_thread.py and dummy_threading.py ................ r6023 | fwierzbicki | 2009-02-08 20:40:53 -0500 (Sun, 08 Feb 2009) | 2 lines Fix for http://bugs.jython.org/issue1243. Thanks RJ Ryan for suggesting the fix. ................ r6031 | fwierzbicki | 2009-02-15 09:23:28 -0500 (Sun, 15 Feb 2009) | 3 lines Fix potential infinite loop (and wrong slice behavior) -- found with FindBugs ................ r6032 | fwierzbicki | 2009-02-15 13:22:18 -0500 (Sun, 15 Feb 2009) | 2 lines Fixed two infinite recursions found with FindBugs. ................ r6033 | fwierzbicki | 2009-02-15 13:31:27 -0500 (Sun, 15 Feb 2009) | 2 lines Fixed NPE found with FindBugs. ................ r6034 | amak | 2009-02-15 13:35:41 -0500 (Sun, 15 Feb 2009) | 2 lines A new version of modjy, containing some bug fixes kindly contributed by Philip Jenvey; see contained release notes for more information. http://github.com/pjenvey/modjy-pjenvey ................ r6035 | pjenvey | 2009-02-15 18:27:44 -0500 (Sun, 15 Feb 2009) | 3 lines double antlr's conversiontimeout for slower environments, in particular the hudson buildot ................ r6036 | fwierzbicki | 2009-02-16 10:41:50 -0500 (Mon, 16 Feb 2009) | 2 lines Useless double assignment. ................ r6037 | fwierzbicki | 2009-02-16 21:38:09 -0500 (Mon, 16 Feb 2009) | 2 lines Make the public adapters in AstAdapters final. ................ r6039 | amak | 2009-02-18 08:21:13 -0500 (Wed, 18 Feb 2009) | 1 line Updating the zip file for modjy 0.25.3; previously checked in version had the wrong version of modjy.jar in WEB-INF/lib. ................ r6040 | fwierzbicki | 2009-02-19 15:16:18 -0500 (Thu, 19 Feb 2009) | 4 lines Our handling of writes after a seek beyond the end of cStringIO was not consistent with CPython (or even our own use of StringIO). Found while trying to get Mercurial to respond to "hg log". ................ r6045 | zyasoft | 2009-02-24 00:04:05 -0500 (Tue, 24 Feb 2009) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-5948" from https://jython.svn.sourceforge.net/svnroot/jython/branches/pbcvm ................ r6046 | zyasoft | 2009-02-24 00:45:38 -0500 (Tue, 24 Feb 2009) | 206 lines Merged revisions 5949,5952,5962,5964,5967-5970,5980,5984,5987-5989,5998-5999,6004-6005,6015-6022,6024-6030,6038,6041-6042 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/branches/pbcvm ........ r5949 | zyasoft | 2009-01-20 06:56:46 -0700 (Tue, 20 Jan 2009) | 2 lines Initial commit. ........ r5952 | zyasoft | 2009-01-20 22:02:29 -0700 (Tue, 20 Jan 2009) | 3 lines Fixed binary and inplace bytecodes to use the proper methods. Added block support to support iteration. ........ r5962 | zyasoft | 2009-01-22 21:40:26 -0700 (Thu, 22 Jan 2009) | 3 lines Added support for try/except and try/finally blocks (and their combination). ........ r5964 | zyasoft | 2009-01-23 08:30:09 -0700 (Fri, 23 Jan 2009) | 2 lines Basic generators are almost supported. ........ r5967 | zyasoft | 2009-01-23 19:49:52 -0700 (Fri, 23 Jan 2009) | 2 lines Now supports generators, via the standard PyGenerator protocol. ........ r5968 | zyasoft | 2009-01-23 21:36:06 -0700 (Fri, 23 Jan 2009) | 2 lines Added support for keyword args, *arg, and **kwarg calling conventions. ........ r5969 | zyasoft | 2009-01-24 09:47:59 -0700 (Sat, 24 Jan 2009) | 3 lines Added support for basic coroutines (no support for throw) and generator expressions. ........ r5970 | zyasoft | 2009-01-24 11:02:37 -0700 (Sat, 24 Jan 2009) | 2 lines Supports throwing exceptions into generators. ........ r5980 | zyasoft | 2009-01-25 18:19:12 -0700 (Sun, 25 Jan 2009) | 4 lines Properly handles *args, **kwargs for the receiver function. func_code can now be set to a PyBytecode (or other extender of PyBaseCode). Turned off debugging by default for PyBytecode objects. ........ r5984 | zyasoft | 2009-01-25 22:02:21 -0700 (Sun, 25 Jan 2009) | 2 lines Added extract tool (to be run by CPython) for creating test modules. ........ r5987 | zyasoft | 2009-01-26 18:45:48 -0700 (Mon, 26 Jan 2009) | 2 lines Fixed raising of exceptions and PyStack.rot ........ r5988 | zyasoft | 2009-01-26 19:16:49 -0700 (Mon, 26 Jan 2009) | 2 lines Fixed opcode support for LOAD/STORE/DELETE_NAME and BUILD_CLASS. ........ r5989 | zyasoft | 2009-01-26 19:26:20 -0700 (Mon, 26 Jan 2009) | 2 lines Fixed RAISE_VARARGS opcode to raise exceptions properly. ........ r5998 | zyasoft | 2009-01-28 20:44:58 -0700 (Wed, 28 Jan 2009) | 3 lines extract.py now creates modules where codeobjects respect their dependency relationships (via a tsort). ........ r5999 | zyasoft | 2009-01-29 07:24:33 -0700 (Thu, 29 Jan 2009) | 6 lines Extract script now processes most/all of the test.test_* modules with a test_main and importable by CPython. May want to consider generalizing support for instance methods and closure setup with respect to new.function (= PyFunction), but this seems purely a testing nicety for top-level defs. ........ r6004 | zyasoft | 2009-02-01 01:12:13 -0700 (Sun, 01 Feb 2009) | 3 lines From http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_marshal@27825 ........ r6005 | zyasoft | 2009-02-01 01:24:06 -0700 (Sun, 01 Feb 2009) | 13 lines Added _marshal, a Java implementation of the Python module, and made current. test_marshal now passes (with minor modifications around GC and floating point accuracy on to/from string representation), except for support of code objects. That's next. Pulled IOFile (now PyIOFile) from cPickle to share its duck typing with _marshal A historical note: from what I can discern in the log, the original marshal.py was written by Guido van Rossum specifically for "JPython" in 1997, one of the few bits he apparently did. Now it survives only as a shell, to import in _marshal. ........ r6015 | zyasoft | 2009-02-05 20:50:10 -0700 (Thu, 05 Feb 2009) | 5 lines Changed read/write binary_float so that it doesn't go through struct but instead j.l.Double's support for converting to/from bits. This also resolves endian ordering issues so that it follows the native endian ordering. ........ r6016 | zyasoft | 2009-02-06 00:07:45 -0700 (Fri, 06 Feb 2009) | 7 lines Fixed some cellvar/freevar nested scope issues, with work to continue. Added a slightly modified version of pycimport.py from Tobias' pyasm implementation in the sandbox. This, in conjunction with compileall (run from CPython; compileall.compile_dir against the unit tests) is allowing a significant fraction of the regrtest to run against PBC-VM. ........ r6017 | zyasoft | 2009-02-06 00:42:15 -0700 (Fri, 06 Feb 2009) | 2 lines Fixed slice, exec support. ........ r6018 | zyasoft | 2009-02-06 21:04:54 -0700 (Fri, 06 Feb 2009) | 2 lines Fixed stack ops (DUP_TOPX, ROT_THREE, ROT_FOUR), INPLACE_POWER. ........ r6019 | zyasoft | 2009-02-06 23:29:37 -0700 (Fri, 06 Feb 2009) | 5 lines Fixed IMPORT_STAR for nested modules. sys.exc_info now returns Py.None for the traceback (this fixes an issue in PBC where null is being used as both a sentinel value by __getitem__ AND an actual value for exception handling). ........ r6020 | zyasoft | 2009-02-07 10:47:19 -0700 (Sat, 07 Feb 2009) | 2 lines Fixes nested scope treatment of free variables. ........ r6021 | zyasoft | 2009-02-07 11:14:33 -0700 (Sat, 07 Feb 2009) | 2 lines Further refinement of nested scopes. ........ r6022 | zyasoft | 2009-02-07 14:26:31 -0700 (Sat, 07 Feb 2009) | 3 lines Fixed control flow by pushing the wrapped Why onto the stack (instead of its string representation from the earliest version of this code). ........ r6024 | zyasoft | 2009-02-10 20:11:10 -0700 (Tue, 10 Feb 2009) | 7 lines Support tostring/fromstring of unsigned types so that they can be stored in the same size as their signed representation. This fixes an issues with peak.util.assembler where it expects that unsigned bytes (typecode 'B') take one byte to store and therefore are directly interoperable with co_code. ........ r6025 | zyasoft | 2009-02-11 21:38:04 -0700 (Wed, 11 Feb 2009) | 2 lines Beginning of PBC compilation support. Pretty much a shell for now. ........ r6026 | zyasoft | 2009-02-14 02:23:58 -0700 (Sat, 14 Feb 2009) | 7 lines Now interns names in co_names, etc., when unmarshalling, which fixes equality tests on special case like __class__, __dict__, etc. Fix instanceof test in eval and exec so that it looks at PyBaseCode, not PyTableCode. Also, exec cannot be called with Py.None instead of null. Fixes test_scope. ........ r6027 | zyasoft | 2009-02-14 03:44:17 -0700 (Sat, 14 Feb 2009) | 3 lines Set the traceback when intercepting an exception. Set __doc__ strings for functions from the constant pool (if available). ........ r6028 | zyasoft | 2009-02-14 04:17:17 -0700 (Sat, 14 Feb 2009) | 3 lines LOAD_DEREF needs to do the same lookup as LOAD_CLOSURE. Populate doc strings for MAKE_CLOSURE. ........ r6029 | zyasoft | 2009-02-14 04:58:48 -0700 (Sat, 14 Feb 2009) | 3 lines Fixed WITH_CLEANUP so that it properly calls __exit__ with the exception components off the stack. ........ r6030 | zyasoft | 2009-02-14 12:17:04 -0700 (Sat, 14 Feb 2009) | 3 lines Fixed UNPACK_SEQUENCE so that ValueError is raised if too few/too many values to unpack. ........ r6038 | zyasoft | 2009-02-17 17:06:55 -0700 (Tue, 17 Feb 2009) | 8 lines Added support for code.getlineno (using co_lnotab), co_code, co_consts, co_lnotab. co_code and co_lnotab now use byte[] for a more compact representation and then manage accessing as if it were an unsigned representation. This enables a good chunk of the peak.util.assembler unit tests to pass; the remainder seem to have a dictionary traversal dependency. ........ r6041 | zyasoft | 2009-02-22 07:40:49 -0700 (Sun, 22 Feb 2009) | 4 lines Inlined PyTableCode#interpret into #call(PyFrame,PyClosure) (which restores this method to what it was before the PBC-VM work). This change restores the performance as tested by test/pystone.py. ........ r6042 | zyasoft | 2009-02-23 21:25:13 -0700 (Mon, 23 Feb 2009) | 8 lines LineCache implementation to support efficient setline edge detection, as necessary for tracing. No longer looks up the ThreadState twice, in the caller of PyBytecode#interpret and interpret itself, so this should provide for some optimization. ........ ................ r6047 | fwierzbicki | 2009-02-24 15:42:25 -0500 (Tue, 24 Feb 2009) | 6 lines Added a target and infrastructure for compiling the ctypes_test.c needed for test__rawffi.py. So far only tested on OS X. Used cpptasks from http://ant-contrib.sourceforge.net/cpptasks/index.html ................ r6049 | fwierzbicki | 2009-03-01 15:42:46 -0500 (Sun, 01 Mar 2009) | 3 lines Update to antlr 3.1.2. This required deleting mismatch() override in Python.g and PythonPartial.g. ................ r6050 | fwierzbicki | 2009-03-01 19:59:05 -0500 (Sun, 01 Mar 2009) | 2 lines Bump CPython version to 70085. ................ r6051 | fwierzbicki | 2009-03-01 20:00:34 -0500 (Sun, 01 Mar 2009) | 3 lines from http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_new@52060 ................ r6052 | fwierzbicki | 2009-03-01 20:04:20 -0500 (Sun, 01 Mar 2009) | 2 lines maybe 'never' was too strong for new.code in Jython. Disable test for now. ................ Modified Paths: -------------- trunk/sandbox/wierzbicki/grammar26/CPythonLib.includes trunk/sandbox/wierzbicki/grammar26/Lib/marshal.py trunk/sandbox/wierzbicki/grammar26/Lib/new.py trunk/sandbox/wierzbicki/grammar26/Lib/os.py trunk/sandbox/wierzbicki/grammar26/Lib/platform.py trunk/sandbox/wierzbicki/grammar26/Lib/pydoc.py trunk/sandbox/wierzbicki/grammar26/Lib/socket.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_StringIO_jy.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_array.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_builtin_jy.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_classpathimporter.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_cmd_line.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_import_jy.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_java_integration.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_java_subclasses.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_java_visibility.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_socket.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_tuple.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_zlib.py trunk/sandbox/wierzbicki/grammar26/Lib/threading.py trunk/sandbox/wierzbicki/grammar26/Lib/zlib.py trunk/sandbox/wierzbicki/grammar26/build.xml trunk/sandbox/wierzbicki/grammar26/grammar/Python.g trunk/sandbox/wierzbicki/grammar26/grammar/PythonPartial.g trunk/sandbox/wierzbicki/grammar26/registry trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/GrammarActions.java trunk/sandbox/wierzbicki/grammar26/src/org/python/antlr/adapter/AstAdapters.java trunk/sandbox/wierzbicki/grammar26/src/org/python/compiler/Future.java trunk/sandbox/wierzbicki/grammar26/src/org/python/compiler/JavaMaker.java trunk/sandbox/wierzbicki/grammar26/src/org/python/compiler/Module.java trunk/sandbox/wierzbicki/grammar26/src/org/python/compiler/ScopesCompiler.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/AstList.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/BytecodeLoader.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/ClasspathPyImporter.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/Options.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/Py.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyArray.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyBuiltinMethodNarrow.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyFrame.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyFunction.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyIterator.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyJavaType.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyList.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyNewWrapper.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyObject.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PySequence.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PySystemState.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyTableCode.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyTuple.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyType.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/SyspathJavaLoader.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/ThreadStateMapping.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/__builtin__.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/codecs.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/imp.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/packagecache/PackageManager.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/packagecache/PathPackageManager.java trunk/sandbox/wierzbicki/grammar26/src/org/python/expose/generate/ExposeTask.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/Setup.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/_csv/PyWriter.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/_py_compile.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/cPickle.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/cStringIO.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/struct.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/thread/PyLocal.java trunk/sandbox/wierzbicki/grammar26/src/org/python/util/Generic.java trunk/sandbox/wierzbicki/grammar26/src/org/python/util/jython.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/expose/generate/TypeExposerTest.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/Coercions.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/Visible.java Added Paths: ----------- trunk/sandbox/wierzbicki/grammar26/Lib/asyncore.py trunk/sandbox/wierzbicki/grammar26/Lib/pycimport.py trunk/sandbox/wierzbicki/grammar26/Lib/test/bug1239.jar trunk/sandbox/wierzbicki/grammar26/Lib/test/check_for_initializer_in_syspath.py trunk/sandbox/wierzbicki/grammar26/Lib/test/import_star_from_java.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_jython_initializer.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_marshal.py trunk/sandbox/wierzbicki/grammar26/Lib/test/test_new.py trunk/sandbox/wierzbicki/grammar26/Tools/pbcvm/ trunk/sandbox/wierzbicki/grammar26/Tools/pbcvm/extract.py trunk/sandbox/wierzbicki/grammar26/extlibs/antlr-3.1.2.jar trunk/sandbox/wierzbicki/grammar26/extlibs/antlr-runtime-3.1.2.jar trunk/sandbox/wierzbicki/grammar26/extlibs/cpptasks/ trunk/sandbox/wierzbicki/grammar26/extlibs/cpptasks/cpptasks.jar trunk/sandbox/wierzbicki/grammar26/extlibs/modjy_0_25_3.zip trunk/sandbox/wierzbicki/grammar26/src/org/python/compiler/pbc/ trunk/sandbox/wierzbicki/grammar26/src/org/python/compiler/pbc/Bytecode.java trunk/sandbox/wierzbicki/grammar26/src/org/python/compiler/pbc/BytecodeCompiler.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/JythonInitializer.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/Opcode.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyBaseCode.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/PyBytecode.java trunk/sandbox/wierzbicki/grammar26/src/org/python/core/WrappedIterIterator.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/PyIOFile.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/PyIOFileFactory.java trunk/sandbox/wierzbicki/grammar26/src/org/python/modules/_marshal.java trunk/sandbox/wierzbicki/grammar26/src/org/python/util/GlobMatchingTask.java trunk/sandbox/wierzbicki/grammar26/src/org/python/util/JycompileAntTask.java trunk/sandbox/wierzbicki/grammar26/tests/data/ trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/ trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/META-INF/ trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/META-INF/services/ trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/META-INF/services/org.python.core.JythonInitializer trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/SyspathAppendingInitializer.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/Child.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/CustomizableMapHolder.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/Parent.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/inbred/ trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/inbred/Metis.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/inbred/Zeus.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/ trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/ConfusedOnGetitemAdd.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/ConfusedOnImport.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/FirstAndPost.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/FirstAndSecond.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/FirstPredefinedGetitem.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/GetitemAdder.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/PostAndFirst.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/PostdefinedGetitem.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/SecondAndFirst.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/SecondPredefinedGetitem.java Removed Paths: ------------- trunk/sandbox/wierzbicki/grammar26/Lib/asyncore.py trunk/sandbox/wierzbicki/grammar26/Tools/pbcvm/extract.py trunk/sandbox/wierzbicki/grammar26/extlibs/antlr-3.1.1-runtime.jar trunk/sandbox/wierzbicki/grammar26/extlibs/antlr-3.1.1.jar trunk/sandbox/wierzbicki/grammar26/extlibs/cpptasks/cpptasks.jar trunk/sandbox/wierzbicki/grammar26/extlibs/modjy_0_25_1.zip trunk/sandbox/wierzbicki/grammar26/src/org/python/compiler/pbc/Bytecode.java trunk/sandbox/wierzbicki/grammar26/src/org/python/compiler/pbc/BytecodeCompiler.java trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/ trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/META-INF/ trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/META-INF/services/ trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/META-INF/services/org.python.core.JythonInitializer trunk/sandbox/wierzbicki/grammar26/tests/data/initializer/SyspathAppendingInitializer.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/inbred/Metis.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/inbred/Zeus.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/ConfusedOnGetitemAdd.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/ConfusedOnImport.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/FirstAndPost.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/FirstAndSecond.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/FirstPredefinedGetitem.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/GetitemAdder.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/PostAndFirst.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/PostdefinedGetitem.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/SecondAndFirst.java trunk/sandbox/wierzbicki/grammar26/tests/java/org/python/tests/mro/SecondPredefinedGetitem.java Property Changed: ---------------- trunk/sandbox/wierzbicki/grammar26/ Property changes on: trunk/sandbox/wierzbicki/grammar26 ___________________________________________________________________ Modified: svn:externals - CPythonLib -r68460 http://svn.python.org/projects/python/branches/release25-maint/Lib/ + CPythonLib -r70085 http://svn.python.org/projects/python/branches/release25-maint/Lib/ Modified: svnmerge-integrated - /trunk/jython:1-5932 + /trunk/jython:1-6053 Modified: trunk/sandbox/wierzbicki/grammar26/CPythonLib.includes =================================================================== --- trunk/sandbox/wierzbicki/grammar26/CPythonLib.includes 2009-03-02 02:26:09 UTC (rev 6053) +++ trunk/sandbox/wierzbicki/grammar26/CPythonLib.includes 2009-03-02 03:29:30 UTC (rev 6054) @@ -52,6 +52,8 @@ DocXMLRPCServer.py dospath.py dumbdbm.py +dummy_thread.py +dummy_threading.py exceptions.py fileinput.py fnmatch.py Deleted: trunk/sandbox/wierzbicki/grammar26/Lib/asyncore.py =================================================================== --- trunk/sandbox/wierzbicki/grammar26/Lib/asyncore.py 2009-03-02 02:26:09 UTC (rev 6053) +++ trunk/sandbox/wierzbicki/grammar26/Lib/asyncore.py 2009-03-02 03:29:30 UTC (rev 6054) @@ -1,561 +0,0 @@ -# -*- Mode: Python -*- -# Id: asyncore.py,v 2.51 2000/09/07 22:29:26 rushing Exp -# Author: Sam Rushing <ru...@ni...> - -# ====================================================================== -# Copyright 1996 by Sam Rushing -# -# All Rights Reserved -# -# Permission to use, copy, modify, and distribute this software and -# its documentation for any purpose and without fee is hereby -# granted, provided that the above copyright notice appear in all -# copies and that both that copyright notice and this permission -# notice appear in supporting documentation, and that the name of Sam -# Rushing not be used in advertising or publicity pertaining to -# distribution of the software without specific, written prior -# permission. -# -# SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN -# NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR -# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, -# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# ====================================================================== - -"""Basic infrastructure for asynchronous socket service clients and servers. - -There are only two ways to have a program on a single processor do "more -than one thing at a time". Multi-threaded programming is the simplest and -most popular way to do it, but there is another very different technique, -that lets you have nearly all the advantages of multi-threading, without -actually using multiple threads. it's really only practical if your program -is largely I/O bound. If your program is CPU bound, then pre-emptive -scheduled threads are probably what you really need. Network servers are -rarely CPU-bound, however. - -If your operating system supports the select() system call in its I/O -library (and nearly all do), then you can use it to juggle multiple -communication channels at once; doing other work while your I/O is taking -place in the "background." Although this strategy can seem strange and -complex, especially at first, it is in many ways easier to understand and -control than multi-threaded programming. The module documented here solves -many of the difficult problems for you, making the task of building -sophisticated high-performance network servers and clients a snap. -""" - -import exceptions -import select -import socket -import sys -import time - -import os -from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \ - ENOTCONN, ESHUTDOWN, EINTR, EISCONN - -try: - socket_map -except NameError: - socket_map = {} - -class ExitNow(exceptions.Exception): - pass - -def read(obj): - try: - obj.handle_read_event() - except ExitNow: - raise - except: - obj.handle_error() - -def write(obj): - try: - obj.handle_write_event() - except ExitNow: - raise - except: - obj.handle_error() - -def readwrite(obj, flags): - try: - if flags & select.POLLIN: - obj.handle_read_event() - if flags & select.POLLOUT: - obj.handle_write_event() - except ExitNow: - raise - except: - obj.handle_error() - -def poll(timeout=0.0, map=None): - if map is None: - map = socket_map - if map: - r = []; w = []; e = [] - for fd, obj in map.items(): - if obj.readable(): - r.append(fd) - if obj.writable(): - w.append(fd) - if [] == r == w == e: - time.sleep(timeout) - else: - try: - r, w, e = select.select(r, w, e, timeout) - except select.error, err: - if err[0] != EINTR: - raise - else: - return - - for fd in r: - obj = map.get(fd) - if obj is None: - continue - read(obj) - - for fd in w: - obj = map.get(fd) - if obj is None: - continue - write(obj) - -def poll2(timeout=0.0, map=None): - import poll - if map is None: - map = socket_map - if timeout is not None: - # timeout is in milliseconds - timeout = int(timeout*1000) - if map: - l = [] - for fd, obj in map.items(): - flags = 0 - if obj.readable(): - flags = poll.POLLIN - if obj.writable(): - flags = flags | poll.POLLOUT - if flags: - l.append((fd, flags)) - r = poll.poll(l, timeout) - for fd, flags in r: - obj = map.get(fd) - if obj is None: - continue - readwrite(obj, flags) - -def poll3(timeout=0.0, map=None): - # Use the poll() support added to the select module in Python 2.0 - if map is None: - map = socket_map - if timeout is not None: - # timeout is in milliseconds - timeout = int(timeout*1000) - pollster = select.poll() - if map: - for fd, obj in map.items(): - flags = 0 - if obj.readable(): - flags = select.POLLIN - if obj.writable(): - flags = flags | select.POLLOUT - if flags: - pollster.register(fd, flags) - try: - r = pollster.poll(timeout) - except select.error, err: - if err[0] != EINTR: - raise - r = [] - for fd, flags in r: - obj = map.get(fd) - if obj is None: - continue - readwrite(obj, flags) - -def loop(timeout=30.0, use_poll=0, map=None): - if map is None: - map = socket_map - - if use_poll: - if hasattr(select, 'poll'): - poll_fun = poll3 - else: - poll_fun = poll2 - else: - poll_fun = poll - - while map: - poll_fun(timeout, map) - -class dispatcher: - - debug = 0 - connected = 0 - accepting = 0 - closing = 0 - addr = None - - def __init__(self, sock=None, map=None): - if sock: - self.set_socket(sock, map) - # I think it should inherit this anyway - self.socket.setblocking(0) - self.connected = 1 - # XXX Does the constructor require that the socket passed - # be connected? - try: - self.addr = sock.getpeername() - except socket.error: - # The addr isn't crucial - pass - else: - self.socket = None - - def __repr__(self): - status = [self.__class__.__module__+"."+self.__class__.__name__] - if self.accepting and self.addr: - status.append('listening') - elif self.connected: - status.append('connected') - if self.addr is not None: - try: - status.append('%s:%d' % self.addr) - except TypeError: - status.append(repr(self.addr)) - # On some systems (RH10) id() can be a negative number. - # work around this. - MAX = 2L*sys.maxint+1 - return '<%s at %#x>' % (' '.join(status), id(self)&MAX) - - def add_channel(self, map=None): - #self.log_info('adding channel %s' % self) - if map is None: - if hasattr(self, '_map'): - map = self._map - del self._map - else: - map = socket_map - if not hasattr(self, '_fileno'): - self._fileno = self.socket.fileno() - map[self._fileno] = self - - def del_channel(self, map=None): - fd = self._fileno - if map is None: - map = socket_map - if map.has_key(fd): - #self.log_info('closing channel %d:%s' % (fd, self)) - del map[fd] - - def create_socket(self, family, type): - self.family_and_type = family, type - self.socket = socket.socket(family, type) - self.socket.setblocking(0) - - def set_socket(self, sock, map=None): - self.socket = sock -## self.__dict__['socket'] = sock - if sock.fileno(): - self.add_channel(map) - else: - self._map = map - - def set_reuse_addr(self): - # try to re-use a server port if possible - try: - self.socket.setsockopt( - socket.SOL_SOCKET, socket.SO_REUSEADDR, - self.socket.getsockopt(socket.SOL_SOCKET, - socket.SO_REUSEADDR) | 1 - ) - except socket.error: - pass - - # ================================================== - # predicates for select() - # these are used as filters for the lists of sockets - # to pass to select(). - # ================================================== - - def readable(self): - return True - - if os.name == 'mac': - # The macintosh will select a listening socket for - # write if you let it. What might this mean? - def writable(self): - return not self.accepting - else: - def writable(self): - return True - - # ================================================== - # socket object methods. - # ================================================== - - def listen(self, num): - self.accepting = 1 - if os.name == 'nt' and num > 5: - num = 1 - ret = self.socket.listen(num) - self.add_channel() - return ret - - def bind(self, addr): - self.addr = addr - return self.socket.bind(addr) - - def connect(self, address): - self.connected = 0 - err = self.socket.connect_ex(address) - # XXX Should interpret Winsock return values - if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): - return - if err in (0, EISCONN): - self.add_channel() - self.addr = address - self.connected = 1 - self.handle_connect() - else: - raise socket.error, err - - def accept(self): - # XXX can return either an address pair or None - try: - conn, addr = self.socket.accept() - self.add_channel() - return conn, addr - except socket.error, why: - if why[0] == EWOULDBLOCK: - pass - else: - raise socket.error, why - - def send(self, data): - try: - result = self.socket.send(data) - return result - except socket.error, why: - if why[0] == EWOULDBLOCK: - return 0 - else: - raise socket.error, why - return 0 - - def recv(self, buffer_size): - try: - data = self.socket.recv(buffer_size) - if not data: - # a closed connection is indicated by signaling - # a read condition, and having recv() return 0. - self.handle_close() - return '' - else: - return data - except socket.error, why: - # winsock sometimes throws ENOTCONN - if why[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN]: - self.handle_close() - return '' - else: - raise socket.error, why - - def close(self): - self.del_channel() - self.socket.close() - - # cheap inheritance, used to pass all other attribute - # references to the underlying socket object. - def __getattr__(self, attr): - return getattr(self.socket, attr) - - # log and log_info may be overridden to provide more sophisticated - # logging and warning methods. In general, log is for 'hit' logging - # and 'log_info' is for informational, warning and error logging. - - def log(self, message): - sys.stderr.write('log: %s\n' % str(message)) - - def log_info(self, message, type='info'): - if __debug__ or type != 'info': - print '%s: %s' % (type, message) - - def handle_read_event(self): - if self.accepting: - # for an accepting socket, getting a read implies - # that we are connected - if not self.connected: - self.connected = 1 - self.handle_accept() - elif not self.connected: - self.handle_connect() - self.connected = 1 - self.handle_read() - else: - self.handle_read() - - def handle_write_event(self): - # getting a write implies that we are connected - if not self.connected: - self.handle_connect() - self.connected = 1 - self.handle_write() - - def handle_expt_event(self): - self.handle_expt() - - def handle_error(self): - nil, t, v, tbinfo = compact_traceback() - - # sometimes a user repr method will crash. - try: - self_repr = repr(self) - except: - self_repr = '<__repr__(self) failed for object at %0x>' % id(self) - - self.log_info( - 'uncaptured python exception, closing channel %s (%s:%s %s)' % ( - self_repr, - t, - v, - tbinfo - ), - 'error' - ) - self.close() - - def handle_expt(self): - self.log_info('unhandled exception', 'warning') - - def handle_read(self): - self.log_info('unhandled read event', 'warning') - - def handle_write(self): - self.log_info('unhandled write event', 'warning') - - def handle_connect(self): - self.log_info('unhandled connect event', 'warning') - - def handle_accept(self): - self.log_info('unhandled accept event', 'warning') - - def handle_close(self): - self.log_info('unhandled close event', 'warning') - self.close() - -# --------------------------------------------------------------------------- -# adds simple buffered output capability, useful for simple clients. -# [for more sophisticated usage use asynchat.async_chat] -# --------------------------------------------------------------------------- - -class dispatcher_with_send(dispatcher): - - def __init__(self, sock=None): - dispatcher.__init__(self, sock) - self.out_buffer = '' - - def initiate_send(self): - num_sent = 0 - num_sent = dispatcher.send(self, self.out_buffer[:512]) - self.out_buffer = self.out_buffer[num_sent:] - - def handle_write(self): - self.initiate_send() - - def writable(self): - return (not self.connected) or len(self.out_buffer) - - def send(self, data): - if self.debug: - self.log_info('sending %s' % repr(data)) - self.out_buffer = self.out_buffer + data - self.initiate_send() - -# --------------------------------------------------------------------------- -# used for debugging. -# --------------------------------------------------------------------------- - -def compact_traceback(): - t, v, tb = sys.exc_info() - tbinfo = [] - assert tb # Must have a traceback - while tb: - tbinfo.append(( - tb.tb_frame.f_code.co_filename, - tb.tb_frame.f_code.co_name, - str(tb.tb_lineno) - )) - tb = tb.tb_next - - # just to be safe - del tb - - file, function, line = tbinfo[-1] - info = ' '.join(['[%s|%s|%s]' % x for x in tbinfo]) - return (file, function, line), t, v, info - -def close_all(map=None): - if map is None: - map = socket_map - for x in map.values(): - x.socket.close() - map.clear() - -# Asynchronous File I/O: -# -# After a little research (reading man pages on various unixen, and -# digging through the linux kernel), I've determined that select() -# isn't meant for doing asynchronous file i/o. -# Heartening, though - reading linux/mm/filemap.c shows that linux -# supports asynchronous read-ahead. So _MOST_ of the time, the data -# will be sitting in memory for us already when we go to read it. -# -# What other OS's (besides NT) support async file i/o? [VMS?] -# -# Regardless, this is useful for pipes, and stdin/stdout... - -if os.name == 'posix': - import fcntl - - class file_wrapper: - # here we override just enough to make a file - # look like a socket for the purposes of asyncore. - - def __init__(self, fd): - self.fd = fd - - def recv(self, *args): - return os.read(self.fd, *args) - - def send(self, *args): - return os.write(self.fd, *args) - - read = recv - write = send - - def close(self): - return os.close(self.fd) - - def fileno(self): - return self.fd - - class file_dispatcher(dispatcher): - - def __init__(self, fd): - dispatcher.__init__(self) - self.connected = 1 - # set it to non-blocking mode - flags = fcntl.fcntl(fd, fcntl.F_GETFL, 0) - flags = flags | os.O_NONBLOCK - fcntl.fcntl(fd, fcntl.F_SETFL, flags) - self.set_file(fd) - - def set_file(self, fd): - self._fileno = fd - self.socket = file_wrapper(fd) - self.add_channel() Copied: trunk/sandbox/wierzbicki/grammar26/Lib/asyncore.py (from rev 6052, trunk/jython/Lib/asyncore.py) =================================================================== --- trunk/sandbox/wierzbicki/grammar26/Lib/asyncore.py (rev 0) +++ trunk/sandbox/wierzbicki/grammar26/Lib/asyncore.py 2009-03-02 03:29:30 UTC (rev 6054) @@ -0,0 +1,551 @@ +# -*- Mode: Python -*- +# Id: asyncore.py,v 2.51 2000/09/07 22:29:26 rushing Exp +# Author: Sam Rushing <ru...@ni...> + +# ====================================================================== +# Copyright 1996 by Sam Rushing +# +# All Rights Reserved +# +# Permission to use, copy, modify, and distribute this software and +# its documentation for any purpose and without fee is hereby +# granted, provided that the above copyright notice appear in all +# copies and that both that copyright notice and this permission +# notice appear in supporting documentation, and that the name of Sam +# Rushing not be used in advertising or publicity pertaining to +# distribution of the software without specific, written prior +# permission. +# +# SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN +# NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR +# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# ====================================================================== + +"""Basic infrastructure for asynchronous socket service clients and servers. + +There are only two ways to have a program on a single processor do "more +than one thing at a time". Multi-threaded programming is the simplest and +most popular way to do it, but there is another very different technique, +that lets you have nearly all the advantages of multi-threading, without +actually using multiple threads. it's really only practical if your program +is largely I/O bound. If your program is CPU bound, then pre-emptive +scheduled threads are probably what you really need. Network servers are +rarely CPU-bound, however. + +If your operating system supports the select() system call in its I/O +library (and nearly all do), then you can use it to juggle multiple +communication channels at once; doing other work while your I/O is taking +place in the "background." Although this strategy can seem strange and +complex, especially at first, it is in many ways easier to understand and +control than multi-threaded programming. The module documented here solves +many of the difficult problems for you, making the task of building +sophisticated high-performance network servers and clients a snap. +""" + +import select +import socket +import sys +import time + +import os +from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \ + ENOTCONN, ESHUTDOWN, EINTR, EISCONN, errorcode + +try: + socket_map +except NameError: + socket_map = {} + +class ExitNow(Exception): + pass + +def read(obj): + try: + obj.handle_read_event() + except ExitNow: + raise + except: + obj.handle_error() + +def write(obj): + try: + obj.handle_write_event() + except ExitNow: + raise + except: + obj.handle_error() + +def _exception (obj): + try: + obj.handle_expt_event() + except ExitNow: + raise + except: + obj.handle_error() + +def readwrite(obj, flags): + try: + if flags & (select.POLLIN | select.POLLPRI): + obj.handle_read_event() + if flags & select.POLLOUT: + obj.handle_write_event() + if flags & (select.POLLERR | select.POLLHUP | select.POLLNVAL): + obj.handle_expt_event() + except ExitNow: + raise + except: + obj.handle_error() + +def poll(timeout=0.0, map=None): + if map is None: + map = socket_map + if map: + r = []; w = []; e = [] + for fd, obj in map.items(): + is_r = obj.readable() + is_w = obj.writable() + if is_r: + r.append(fd) + if is_w: + w.append(fd) + if is_r or is_w: + e.append(fd) + if [] == r == w == e: + time.sleep(timeout) + else: + try: + r, w, e = select.select(r, w, e, timeout) + except select.error, err: + if err[0] != EINTR: + raise + else: + return + + for fd in r: + obj = map.get(fd) + if obj is None: + continue + read(obj) + + for fd in w: + obj = map.get(fd) + if obj is None: + continue + write(obj) + + for fd in e: + obj = map.get(fd) + if obj is None: + continue + _exception(obj) + +def poll2(timeout=0.0, map=None): + # Use the poll() support added to the select module in Python 2.0 + if map is None: + map = socket_map + if timeout is not None: + # timeout is in milliseconds + timeout = int(timeout*1000) + pollster = select.poll() + if map: + for fd, obj in map.items(): + flags = 0 + if obj.readable(): + flags |= select.POLLIN | select.POLLPRI + if obj.writable(): + flags |= select.POLLOUT + if flags: + # Only check for exceptions if object was either readable + # or writable. + flags |= select.POLLERR | select.POLLHUP | select.POLLNVAL + pollster.register(fd, flags) + try: + r = pollster.poll(timeout) + except select.error, err: + if err[0] != EINTR: + raise + r = [] + for fd, flags in r: + obj = map.get(fd) + if obj is None: + continue + readwrite(obj, flags) + +poll3 = poll2 # Alias for backward compatibility + +def loop(timeout=30.0, use_poll=True, map=None, count=None): + if map is None: + map = socket_map + + if use_poll and hasattr(select, 'poll'): + poll_fun = poll2 + else: + poll_fun = poll + + if count is None: + while map: + ... [truncated message content] |