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: <fwi...@us...> - 2008-09-26 14:42:17
|
Revision: 5350 http://jython.svn.sourceforge.net/jython/?rev=5350&view=rev Author: fwierzbicki Date: 2008-09-26 14:41:55 +0000 (Fri, 26 Sep 2008) Log Message: ----------- Correct this for new __class__.__name__ package truncating behavior of Java classes. Modified Paths: -------------- trunk/jython/ast/astview.py Modified: trunk/jython/ast/astview.py =================================================================== --- trunk/jython/ast/astview.py 2008-09-25 21:16:30 UTC (rev 5349) +++ trunk/jython/ast/astview.py 2008-09-26 14:41:55 UTC (rev 5350) @@ -19,11 +19,11 @@ def get_class_name(t): result = t.__class__.__name__ - if result in ("org.python.antlr.ast.expr_contextType", - "org.python.antlr.ast.boolopType", - "org.python.antlr.ast.unaryopType", - "org.python.antlr.ast.cmpopType", - "org.python.antlr.ast.operatorType"): + if result in ("expr_contextType", + "boolopType", + "unaryopType", + "cmpopType", + "operatorType"): result = str(t) if result == "AugLoad": result = "Load" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-09-25 21:16:36
|
Revision: 5349 http://jython.svn.sourceforge.net/jython/?rev=5349&view=rev Author: pjenvey Date: 2008-09-25 21:16:30 +0000 (Thu, 25 Sep 2008) Log Message: ----------- reapply previous tarfile modifications: o don't assume a reference counting GC o ensure all file handles are closed to avoid os.remove problems on windows o always use the tempdir, even when testtar is a relative path (it is when ran via the regrtest) Modified Paths: -------------- trunk/jython/Lib/tarfile.py trunk/jython/Lib/test/test_tarfile.py Modified: trunk/jython/Lib/tarfile.py =================================================================== --- trunk/jython/Lib/tarfile.py 2008-09-25 21:12:28 UTC (rev 5348) +++ trunk/jython/Lib/tarfile.py 2008-09-25 21:16:30 UTC (rev 5349) @@ -1205,12 +1205,10 @@ except (ImportError, AttributeError): raise CompressionError("gzip module is not available") - if fileobj is None: - fileobj = file(name, mode + "b") + fileobj = gzip.GzipFile(name, mode, compresslevel, fileobj) try: - t = cls.taropen(name, mode, - gzip.GzipFile(name, mode, compresslevel, fileobj)) + t = cls.taropen(name, mode, fileobj) except IOError: raise ReadError("not a gzip file") t._extfileobj = False Modified: trunk/jython/Lib/test/test_tarfile.py =================================================================== --- trunk/jython/Lib/test/test_tarfile.py 2008-09-25 21:12:28 UTC (rev 5348) +++ trunk/jython/Lib/test/test_tarfile.py 2008-09-25 21:16:30 UTC (rev 5349) @@ -31,7 +31,7 @@ def tarname(comp=""): if not comp: return testtar - return os.path.join(tempdir, "%s%s%s" % (testtar, os.extsep, comp)) + return os.path.join(dirname(), "%s%s%s" % (testtar, os.extsep, comp)) def dirname(): if not os.path.exists(tempdir): @@ -279,9 +279,14 @@ def setUp(self): name = tarname(self.comp) + self.fileobj = open(name, "rb") self.tar = tarfile.open(name, mode=self.mode, - fileobj=open(name, "rb")) + fileobj=self.fileobj) + def tearDown(self): + self.tar.close() + self.fileobj.close() + class ReadAsteriskTest(ReadTest): def setUp(self): @@ -529,6 +534,7 @@ self.assert_(tarinfo.name == member.name and \ tarinfo.linkname == member.linkname, \ "unable to read longname member") + tar.close() def test_longname_1023(self): self._test(("longnam/" * 127) + "longnam") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-09-25 21:12:35
|
Revision: 5348 http://jython.svn.sourceforge.net/jython/?rev=5348&view=rev Author: pjenvey Date: 2008-09-25 21:12:28 +0000 (Thu, 25 Sep 2008) Log Message: ----------- bump tarfile from 2.5.1 to 2.5.2, from: http://svn.python.org/projects/python/branches/release25-maint/Lib tarfile.py@60730 test/test_tarfile.py@60730 Modified Paths: -------------- trunk/jython/Lib/tarfile.py trunk/jython/Lib/test/test_tarfile.py Removed Paths: ------------- trunk/jython/Lib/test/testtar.tar Modified: trunk/jython/Lib/tarfile.py =================================================================== --- trunk/jython/Lib/tarfile.py 2008-09-25 18:52:30 UTC (rev 5347) +++ trunk/jython/Lib/tarfile.py 2008-09-25 21:12:28 UTC (rev 5348) @@ -30,17 +30,13 @@ """Read from and write to tar format archives. """ -# From CPython 2.5.1 with @classmethod decorators replaced and -# TarFile.gzopen changed to not assume CPython reference counting GC -# (make GzipFile close the underlying file) - -__version__ = "$Revision: 53162 $" +__version__ = "$Revision: 60730 $" # $Source$ version = "0.8.0" __author__ = "Lars Gust\xE4bel (la...@gu...)" -__date__ = "$Date: 2006-12-27 21:36:58 +1100 (Wed, 27 Dec 2006) $" -__cvsid__ = "$Id: tarfile.py 53162 2006-12-27 10:36:58Z lars.gustaebel $" +__date__ = "$Date: 2008-02-11 10:36:07 -0800 (Mon, 11 Feb 2008) $" +__cvsid__ = "$Id: tarfile.py 60730 2008-02-11 18:36:07Z lars.gustaebel $" __credits__ = "Gustavo Niemeyer, Niels Gust\xE4bel, Richard Townsend." #--------- @@ -143,13 +139,22 @@ """ return s[:length] + (length - len(s)) * NUL +def nts(s): + """Convert a null-terminated string field to a python string. + """ + # Use the string up to the first null char. + p = s.find("\0") + if p == -1: + return s + return s[:p] + def nti(s): """Convert a number field to a python number. """ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0200): - n = int(s.rstrip(NUL + " ") or "0", 8) + n = int(nts(s) or "0", 8) else: n = 0L for i in xrange(len(s) - 1): @@ -865,7 +870,7 @@ def __repr__(self): return "<%s %r at %#x>" % (self.__class__.__name__,self.name,id(self)) - #@classmethod + @classmethod def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ @@ -876,7 +881,7 @@ tarinfo = cls() tarinfo.buf = buf - tarinfo.name = buf[0:100].rstrip(NUL) + tarinfo.name = nts(buf[0:100]) tarinfo.mode = nti(buf[100:108]) tarinfo.uid = nti(buf[108:116]) tarinfo.gid = nti(buf[116:124]) @@ -884,12 +889,12 @@ tarinfo.mtime = nti(buf[136:148]) tarinfo.chksum = nti(buf[148:156]) tarinfo.type = buf[156:157] - tarinfo.linkname = buf[157:257].rstrip(NUL) - tarinfo.uname = buf[265:297].rstrip(NUL) - tarinfo.gname = buf[297:329].rstrip(NUL) + tarinfo.linkname = nts(buf[157:257]) + tarinfo.uname = nts(buf[265:297]) + tarinfo.gname = nts(buf[297:329]) tarinfo.devmajor = nti(buf[329:337]) tarinfo.devminor = nti(buf[337:345]) - prefix = buf[345:500].rstrip(NUL) + prefix = nts(buf[345:500]) if prefix and not tarinfo.issparse(): tarinfo.name = prefix + "/" + tarinfo.name @@ -897,7 +902,6 @@ if tarinfo.chksum not in calc_chksums(buf): raise ValueError("invalid header") return tarinfo - frombuf = classmethod(frombuf) def tobuf(self, posix=False): """Return a tar header as a string of 512 byte blocks. @@ -968,7 +972,7 @@ stn(prefix, 155) ] - buf += struct.pack("%ds" % BLOCKSIZE, "".join(parts)) + buf += "".join(parts).ljust(BLOCKSIZE, NUL) chksum = calc_chksums(buf[-BLOCKSIZE:])[0] buf = buf[:-364] + "%06o\0" % chksum + buf[-357:] self.buf = buf @@ -1049,29 +1053,29 @@ can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ - self.name = os.path.abspath(name) - if len(mode) > 1 or mode not in "raw": raise ValueError("mode must be 'r', 'a' or 'w'") self._mode = mode self.mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode] if not fileobj: - fileobj = file(self.name, self.mode) + fileobj = file(name, self.mode) self._extfileobj = False else: - if self.name is None and hasattr(fileobj, "name"): - self.name = os.path.abspath(fileobj.name) + if name is None and hasattr(fileobj, "name"): + name = fileobj.name if hasattr(fileobj, "mode"): self.mode = fileobj.mode self._extfileobj = True + self.name = os.path.abspath(name) if name else None self.fileobj = fileobj # Init datastructures self.closed = False self.members = [] # list of members as TarInfo objects self._loaded = False # flag if all members have been read - self.offset = 0L # current position in the archive file + self.offset = self.fileobj.tell() + # current position in the archive file self.inodes = {} # dictionary caching the inodes of # archive members already added @@ -1107,7 +1111,7 @@ # the super-constructor. A sub-constructor is registered and made available # by adding it to the mapping in OPEN_METH. - #@classmethod + @classmethod def open(cls, name=None, mode="r", fileobj=None, bufsize=20*512): """Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. @@ -1178,18 +1182,16 @@ return cls.taropen(name, mode, fileobj) raise ValueError("undiscernible mode") - open = classmethod(open) - #@classmethod + @classmethod def taropen(cls, name, mode="r", fileobj=None): """Open uncompressed tar archive name for reading or writing. """ if len(mode) > 1 or mode not in "raw": raise ValueError("mode must be 'r', 'a' or 'w'") return cls(name, mode, fileobj) - taropen = classmethod(taropen) - #@classmethod + @classmethod def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. @@ -1204,19 +1206,17 @@ raise CompressionError("gzip module is not available") if fileobj is None: - fileobj = gzip.GzipFile(name, mode, compresslevel) - else: - fileobj = gzip.GzipFile(name, mode, compresslevel, fileobj) + fileobj = file(name, mode + "b") try: - t = cls.taropen(name, mode, fileobj) + t = cls.taropen(name, mode, + gzip.GzipFile(name, mode, compresslevel, fileobj)) except IOError: raise ReadError("not a gzip file") t._extfileobj = False return t - gzopen = classmethod(gzopen) - #@classmethod + @classmethod def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. @@ -1240,7 +1240,6 @@ raise ReadError("not a bzip2 file") t._extfileobj = False return t - bz2open = classmethod(bz2open) # All *open() methods are registered here. OPEN_METH = { @@ -1519,15 +1518,11 @@ for tarinfo in members: if tarinfo.isdir(): - # Extract directory with a safe mode, so that - # all files below can be extracted as well. - try: - os.makedirs(os.path.join(path, tarinfo.name), 0777) - except EnvironmentError: - pass + # Extract directories with a safe mode. directories.append(tarinfo) - else: - self.extract(tarinfo, path) + tarinfo = copy.copy(tarinfo) + tarinfo.mode = 0700 + self.extract(tarinfo, path) # Reverse sort directories. directories.sort(lambda a, b: cmp(a.name, b.name)) @@ -1535,11 +1530,11 @@ # Set correct owner, mtime and filemode on directories. for tarinfo in directories: - path = os.path.join(path, tarinfo.name) + dirpath = os.path.join(path, tarinfo.name) try: - self.chown(tarinfo, path) - self.utime(tarinfo, path) - self.chmod(tarinfo, path) + self.chown(tarinfo, dirpath) + self.utime(tarinfo, dirpath) + self.chmod(tarinfo, dirpath) except ExtractError, e: if self.errorlevel > 1: raise @@ -1632,19 +1627,9 @@ # Create all upper directories. upperdirs = os.path.dirname(targetpath) if upperdirs and not os.path.exists(upperdirs): - ti = TarInfo() - ti.name = upperdirs - ti.type = DIRTYPE - ti.mode = 0777 - ti.mtime = tarinfo.mtime - ti.uid = tarinfo.uid - ti.gid = tarinfo.gid - ti.uname = tarinfo.uname - ti.gname = tarinfo.gname - try: - self._extract_member(ti, ti.name) - except: - pass + # Create directories that are not part of the archive with + # default permissions. + os.makedirs(upperdirs) if tarinfo.islnk() or tarinfo.issym(): self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname)) @@ -1680,7 +1665,9 @@ """Make a directory called targetpath. """ try: - os.mkdir(targetpath) + # Use a safe mode for the directory, the real mode is set + # later in _extract_member(). + os.mkdir(targetpath, 0700) except EnvironmentError, e: if e.errno != errno.EEXIST: raise @@ -1852,7 +1839,7 @@ tarinfo.type = DIRTYPE # Directory names should have a '/' at the end. - if tarinfo.isdir(): + if tarinfo.isdir() and not tarinfo.name.endswith("/"): tarinfo.name += "/" self.members.append(tarinfo) @@ -1914,9 +1901,9 @@ # the longname information. next.offset = tarinfo.offset if tarinfo.type == GNUTYPE_LONGNAME: - next.name = buf.rstrip(NUL) + next.name = nts(buf) elif tarinfo.type == GNUTYPE_LONGLINK: - next.linkname = buf.rstrip(NUL) + next.linkname = nts(buf) return next Modified: trunk/jython/Lib/test/test_tarfile.py =================================================================== --- trunk/jython/Lib/test/test_tarfile.py 2008-09-25 18:52:30 UTC (rev 5347) +++ trunk/jython/Lib/test/test_tarfile.py 2008-09-25 21:12:28 UTC (rev 5348) @@ -9,9 +9,6 @@ from test import test_support -# From CPython 2.5.1, with a change to tarname() to use the correct -# tempdir when the testtar path name is relative (due to regrtest) - # Check for our compression modules. try: import gzip @@ -29,12 +26,12 @@ testtar = path("testtar.tar") tempdir = os.path.join(tempfile.gettempdir(), "testtar" + os.extsep + "dir") tempname = test_support.TESTFN -membercount = 12 +membercount = 13 def tarname(comp=""): if not comp: return testtar - return os.path.join(dirname(), "%s%s%s" % (testtar, os.extsep, comp)) + return os.path.join(tempdir, "%s%s%s" % (testtar, os.extsep, comp)) def dirname(): if not os.path.exists(tempdir): @@ -194,6 +191,47 @@ except: pass + def test_dirtype(self): + for tarinfo in self.tar: + if tarinfo.isdir(): + self.assert_(tarinfo.name.endswith("/")) + self.assert_(not tarinfo.name[:-1].endswith("/")) + + def test_extractall(self): + # Test if extractall() correctly restores directory permissions + # and times (see issue1735). + if sys.platform == "win32": + # Win32 has no support for utime() on directories or + # fine grained permissions. + return + + fobj = StringIO.StringIO() + tar = tarfile.open(fileobj=fobj, mode="w:") + for name in ("foo", "foo/bar"): + tarinfo = tarfile.TarInfo(name) + tarinfo.type = tarfile.DIRTYPE + tarinfo.mtime = 07606136617 + tarinfo.mode = 0755 + tar.addfile(tarinfo) + tar.close() + fobj.seek(0) + + TEMPDIR = os.path.join(dirname(), "extract-test") + tar = tarfile.open(fileobj=fobj) + tar.extractall(TEMPDIR) + for tarinfo in tar.getmembers(): + path = os.path.join(TEMPDIR, tarinfo.name) + self.assertEqual(tarinfo.mode, os.stat(path).st_mode & 0777) + self.assertEqual(tarinfo.mtime, os.path.getmtime(path)) + tar.close() + + def test_star(self): + try: + self.tar.getmember("7-STAR") + except KeyError: + self.fail("finding 7-STAR member failed (mangled prefix?)") + + class ReadStreamTest(ReadTest): sep = "|" @@ -241,14 +279,9 @@ def setUp(self): name = tarname(self.comp) - self.fileobj = open(name, "rb") self.tar = tarfile.open(name, mode=self.mode, - fileobj=self.fileobj) + fileobj=open(name, "rb")) - def tearDown(self): - self.tar.close() - self.fileobj.close() - class ReadAsteriskTest(ReadTest): def setUp(self): @@ -261,6 +294,38 @@ mode = self.mode + self.sep + "*" self.tar = tarfile.open(tarname(self.comp), mode) +class ReadFileobjTest(BaseTest): + + def test_fileobj_with_offset(self): + # Skip the first member and store values from the second member + # of the testtar. + self.tar.next() + t = self.tar.next() + name = t.name + offset = t.offset + data = self.tar.extractfile(t).read() + self.tar.close() + + # Open the testtar and seek to the offset of the second member. + if self.comp == "gz": + _open = gzip.GzipFile + elif self.comp == "bz2": + _open = bz2.BZ2File + else: + _open = open + fobj = _open(tarname(self.comp), "rb") + fobj.seek(offset) + + # Test if the tarfile starts with the second member. + self.tar = tarfile.open(tarname(self.comp), "r:", fileobj=fobj) + t = self.tar.next() + self.assertEqual(t.name, name) + # Read to the end of fileobj and test if seeking back to the + # beginning works. + self.tar.getmembers() + self.assertEqual(self.tar.extractfile(t).read(), data, + "seek back did not work") + class WriteTest(BaseTest): mode = 'w' @@ -464,7 +529,6 @@ self.assert_(tarinfo.name == member.name and \ tarinfo.linkname == member.linkname, \ "unable to read longname member") - tar.close() def test_longname_1023(self): self._test(("longnam/" * 127) + "longnam") @@ -626,6 +690,8 @@ comp = "gz" class ReadStreamAsteriskTestGzip(ReadStreamAsteriskTest): comp = "gz" +class ReadFileobjTestGzip(ReadFileobjTest): + comp = "gz" # Filemode test cases @@ -635,15 +701,35 @@ self.assertEqual(tarfile.filemode(07111), '---s--s--t') class OpenFileobjTest(BaseTest): - # Test for SF bug #1496501. def test_opener(self): + # Test for SF bug #1496501. fobj = StringIO.StringIO("foo\n") try: - tarfile.open("", "r", fileobj=fobj) + tarfile.open("", mode="r", fileobj=fobj) except tarfile.ReadError: self.assertEqual(fobj.tell(), 0, "fileobj's position has moved") + def test_no_name_argument(self): + fobj = open(testtar, "rb") + tar = tarfile.open(fileobj=fobj, mode="r") + self.assertEqual(tar.name, os.path.abspath(fobj.name)) + + def test_no_name_attribute(self): + data = open(testtar, "rb").read() + fobj = StringIO.StringIO(data) + self.assertRaises(AttributeError, getattr, fobj, "name") + tar = tarfile.open(fileobj=fobj, mode="r") + self.assertEqual(tar.name, None) + + def test_empty_name_attribute(self): + data = open(testtar, "rb").read() + fobj = StringIO.StringIO(data) + fobj.name = "" + tar = tarfile.open(fileobj=fobj, mode="r") + self.assertEqual(tar.name, None) + + if bz2: # Bzip2 TestCases class ReadTestBzip2(ReadTestGzip): @@ -662,6 +748,8 @@ comp = "bz2" class ReadStreamAsteriskTestBzip2(ReadStreamAsteriskTest): comp = "bz2" + class ReadFileobjTestBzip2(ReadFileobjTest): + comp = "bz2" # If importing gzip failed, discard the Gzip TestCases. if not gzip: @@ -695,6 +783,7 @@ ReadDetectFileobjTest, ReadAsteriskTest, ReadStreamAsteriskTest, + ReadFileobjTest, WriteTest, Write100Test, WriteSize0Test, @@ -712,7 +801,8 @@ ReadTestGzip, ReadStreamTestGzip, WriteTestGzip, WriteStreamTestGzip, ReadDetectTestGzip, ReadDetectFileobjTestGzip, - ReadAsteriskTestGzip, ReadStreamAsteriskTestGzip + ReadAsteriskTestGzip, ReadStreamAsteriskTestGzip, + ReadFileobjTestGzip ]) if bz2: @@ -720,7 +810,8 @@ ReadTestBzip2, ReadStreamTestBzip2, WriteTestBzip2, WriteStreamTestBzip2, ReadDetectTestBzip2, ReadDetectFileobjTestBzip2, - ReadAsteriskTestBzip2, ReadStreamAsteriskTestBzip2 + ReadAsteriskTestBzip2, ReadStreamAsteriskTestBzip2, + ReadFileobjTestBzip2 ]) try: test_support.run_unittest(*tests) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2008-09-25 18:52:37
|
Revision: 5347 http://jython.svn.sourceforge.net/jython/?rev=5347&view=rev Author: thobes Date: 2008-09-25 18:52:30 +0000 (Thu, 25 Sep 2008) Log Message: ----------- Fix of the bug with "def f(): lambda x=(yield): 1". The problem was that the order of instructions were such that there was elements on the stack before the yield-point that does not get restored. I also found another problem in that the types for local variables in CodeCompiler are not proper java types, this is in error in nearly all places, and needs to be fixed in a later commit. Modified Paths: -------------- trunk/jython/src/org/python/compiler/CodeCompiler.java Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-09-24 22:12:23 UTC (rev 5346) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-09-25 18:52:30 UTC (rev 5347) @@ -331,15 +331,17 @@ if (n == 0) { code.getstatic("org/python/core/Py", "EmptyObjects", $pyObjArr); } else { - int tmp = code.getLocal("[org/python/core/PyObject"); + int tmp = code.getLocal("[Lorg/python/core/PyObject;"); code.iconst(n); code.anewarray("org/python/core/PyObject"); code.astore(tmp); for(int i=0; i<n; i++) { + visit(nodes[i]); code.aload(tmp); + code.swap(); code.iconst(i); - visit(nodes[i]); + code.swap(); code.aastore(); } code.aload(tmp); @@ -1787,16 +1789,20 @@ setline(node); + ScopeInfo scope = module.getScopeInfo(node); + + makeArray(scope.ac.getDefaults()); + code.new_("org/python/core/PyFunction"); + + code.dup_x1(); + code.swap(); - code.dup(); loadFrame(); code.getfield("org/python/core/PyFrame", "f_globals", $pyObj); + + code.swap(); - ScopeInfo scope = module.getScopeInfo(node); - - makeArray(scope.ac.getDefaults()); - scope.setup_closure(); scope.dump(); module.PyCode(retSuite, name, true, className, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <th...@us...> - 2008-09-24 22:12:32
|
Revision: 5346 http://jython.svn.sourceforge.net/jython/?rev=5346&view=rev Author: thobes Date: 2008-09-24 22:12:23 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Fixed the bug of the __exit__ method not being invoked on the outer context manager in the case of nested with statements. The problem was that the exception handlers were not properly sorted. Modified Paths: -------------- trunk/jython/src/org/python/compiler/CodeCompiler.java Modified: trunk/jython/src/org/python/compiler/CodeCompiler.java =================================================================== --- trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-09-24 21:05:39 UTC (rev 5345) +++ trunk/jython/src/org/python/compiler/CodeCompiler.java 2008-09-24 22:12:23 UTC (rev 5346) @@ -2090,7 +2090,7 @@ // mgr = (EXPR) visit(node.context_expr); - int mgr_tmp = code.getLocal("org/python/core/PyObject"); + int mgr_tmp = code.getLocal("org/python/core/PyObject"); code.astore(mgr_tmp); // exit = mgr.__exit__ # Not calling it yet, so storing in the frame @@ -2113,7 +2113,10 @@ // exc = True # not necessary, since we don't exec finally if exception // try-catch block here - code.trycatch(label_body_start, label_body_end, label_catch, "java/lang/Throwable"); + //code.trycatch(label_body_start, label_body_end, label_catch, "java/lang/Throwable"); + ExceptionHandler handler = new ExceptionHandler(); + handler.exceptionStarts.addElement(label_body_start); + exceptionHandlers.push(handler); // VAR = value # Only if "as VAR" is present code.label(label_body_start); @@ -2124,8 +2127,10 @@ // BLOCK suite(node.body); + exceptionHandlers.pop(); code.goto_(label_finally); code.label(label_body_end); + handler.exceptionEnds.addElement(label_body_end); // CATCH code.label(label_catch); @@ -2162,6 +2167,8 @@ code.athrow(); code.freeLocal(ts_tmp); + + handler.addExceptionHandlers(label_catch); // FINALLY // ordinarily with a finally, we need to duplicate the code. that's not the case here This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-24 21:05:45
|
Revision: 5345 http://jython.svn.sourceforge.net/jython/?rev=5345&view=rev Author: fwierzbicki Date: 2008-09-24 21:05:39 +0000 (Wed, 24 Sep 2008) Log Message: ----------- Switched PythonPartial.g from being a "grammar" to being a "parser grammar", plus some additional related cleanup. This fixes all of the missing Token warnings. Thanks to Terrance Parr for suggesting this fix. Modified Paths: -------------- trunk/jython/grammar/PythonPartial.g trunk/jython/src/org/python/core/ParserFacade.java trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2008-09-24 19:56:28 UTC (rev 5344) +++ trunk/jython/grammar/PythonPartial.g 2008-09-24 21:05:39 UTC (rev 5345) @@ -62,7 +62,7 @@ * an indent but no dedent. */ -grammar PythonPartial; +parser grammar PythonPartial; options { tokenVocab=Python; @@ -124,67 +124,6 @@ } } - -@lexer::header { -package org.python.antlr; -} - -@lexer::members { -/** Handles context-sensitive lexing of implicit line joining such as - * the case where newline is ignored in cases like this: - * a = [3, - * 4] - */ -int implicitLineJoiningLevel = 0; -int startPos=-1; -public boolean eofWhileNested = false; - public Token nextToken() { - while (true) { - state.token = null; - state.channel = Token.DEFAULT_CHANNEL; - state.tokenStartCharIndex = input.index(); - state.tokenStartCharPositionInLine = input.getCharPositionInLine(); - state.tokenStartLine = input.getLine(); - state.text = null; - if ( input.LA(1)==CharStream.EOF ) { - if (implicitLineJoiningLevel > 0) { - eofWhileNested = true; - } - return Token.EOF_TOKEN; - } - try { - mTokens(); - if ( state.token==null ) { - emit(); - } - else if ( state.token==Token.SKIP_TOKEN ) { - continue; - } - return state.token; - } - catch (RecognitionException re) { - throw new ParseException("failed partial", re); - } - } - } - - public void reportError(RecognitionException e) { - System.err.print("[LEXER REPORTING] "); - // if we've already reported an error and have not matched a token - // yet successfully, don't report any errors. - if ( state.errorRecovery ) { - System.err.print("[SPURIOUS] "); - return; - } - state.syntaxErrors++; // don't count spurious - state.errorRecovery = true; - - displayRecognitionError(this.getTokenNames(), e); - } - - -} - single_input : NEWLINE | simple_stmt | compound_stmt NEWLINE? Modified: trunk/jython/src/org/python/core/ParserFacade.java =================================================================== --- trunk/jython/src/org/python/core/ParserFacade.java 2008-09-24 19:56:28 UTC (rev 5344) +++ trunk/jython/src/org/python/core/ParserFacade.java 2008-09-24 21:05:39 UTC (rev 5345) @@ -26,7 +26,7 @@ import org.python.antlr.PythonTree; import org.python.antlr.PythonTree; import org.python.antlr.PythonLexer; -import org.python.antlr.PythonPartialParser; +import org.python.antlr.PythonPartial; import org.python.antlr.PythonTokenSource; import org.python.antlr.ast.modType; import org.python.core.io.StreamIO; @@ -172,7 +172,7 @@ CommonTokenStream tokens = new CommonTokenStream(lexer); PythonTokenSource indentedSource = new PythonTokenSource(tokens, filename); tokens = new CommonTokenStream(indentedSource); - PythonPartialParser parser = new PythonPartialParser(tokens); + PythonPartial parser = new PythonPartial(tokens); if (kind.equals("single")) { parser.single_input(); } else if (kind.equals("eval")) { Modified: trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java =================================================================== --- trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java 2008-09-24 19:56:28 UTC (rev 5344) +++ trunk/jython/tests/java/org/python/antlr/PythonPartialTester.java 2008-09-24 21:05:39 UTC (rev 5345) @@ -19,7 +19,7 @@ //PythonTokenSource indentedSource = new PythonTokenSource(tokens); PythonTokenSource indentedSource = new PythonTokenSource(tokens, "<test>"); tokens = new CommonTokenStream(indentedSource); - PythonPartialParser parser = new PythonPartialParser(tokens); + PythonPartial parser = new PythonPartial(tokens); parser.single_input(); System.out.println("SUCCEED"); } catch (ParseException e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-09-24 19:56:32
|
Revision: 5344 http://jython.svn.sourceforge.net/jython/?rev=5344&view=rev Author: pjenvey Date: 2008-09-24 19:56:28 +0000 (Wed, 24 Sep 2008) Log Message: ----------- revert r5343, it's broken Modified Paths: -------------- trunk/jython/src/org/python/core/PyFile.java trunk/jython/src/org/python/core/StdoutWrapper.java Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2008-09-24 19:44:25 UTC (rev 5343) +++ trunk/jython/src/org/python/core/PyFile.java 2008-09-24 19:56:28 UTC (rev 5344) @@ -411,10 +411,6 @@ } } - public void write(PyObject o) { - file_write(o); - } - final synchronized void file_write(String s) { checkClosed(); softspace = false; Modified: trunk/jython/src/org/python/core/StdoutWrapper.java =================================================================== --- trunk/jython/src/org/python/core/StdoutWrapper.java 2008-09-24 19:44:25 UTC (rev 5343) +++ trunk/jython/src/org/python/core/StdoutWrapper.java 2008-09-24 19:56:28 UTC (rev 5344) @@ -105,10 +105,11 @@ file.write(" "); file.softspace = false; } - file.write(o); + PyString string = o.__str__(); + String s = string.toString(); + int len = s.length(); + file.write(s); if (o instanceof PyString) { - String s = o.toString(); - int len = s.length(); if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) || s.charAt(len - 1) == ' ') { file.softspace = space; @@ -127,10 +128,11 @@ obj.invoke("write", Py.Space); obj.__setattr__("softspace", Py.Zero); } - obj.invoke("write", o); + PyString string = o.__str__(); + String s = o.toString(); + int len = s.length(); + obj.invoke("write", string); if (o instanceof PyString) { - String s = o.toString(); - int len = s.length(); if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) || s.charAt(len - 1) == ' ') { obj.__setattr__("softspace", space ? Py.One : Py.Zero); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2008-09-24 19:44:31
|
Revision: 5343 http://jython.svn.sourceforge.net/jython/?rev=5343&view=rev Author: pjenvey Date: 2008-09-24 19:44:25 +0000 (Wed, 24 Sep 2008) Log Message: ----------- it's more correct for StdoutWrapper to write the object being printed to the file instead of __str__'ing it refs #1130 Modified Paths: -------------- trunk/jython/src/org/python/core/PyFile.java trunk/jython/src/org/python/core/StdoutWrapper.java Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2008-09-21 00:20:23 UTC (rev 5342) +++ trunk/jython/src/org/python/core/PyFile.java 2008-09-24 19:44:25 UTC (rev 5343) @@ -411,6 +411,10 @@ } } + public void write(PyObject o) { + file_write(o); + } + final synchronized void file_write(String s) { checkClosed(); softspace = false; Modified: trunk/jython/src/org/python/core/StdoutWrapper.java =================================================================== --- trunk/jython/src/org/python/core/StdoutWrapper.java 2008-09-21 00:20:23 UTC (rev 5342) +++ trunk/jython/src/org/python/core/StdoutWrapper.java 2008-09-24 19:44:25 UTC (rev 5343) @@ -105,11 +105,10 @@ file.write(" "); file.softspace = false; } - PyString string = o.__str__(); - String s = string.toString(); - int len = s.length(); - file.write(s); + file.write(o); if (o instanceof PyString) { + String s = o.toString(); + int len = s.length(); if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) || s.charAt(len - 1) == ' ') { file.softspace = space; @@ -128,11 +127,10 @@ obj.invoke("write", Py.Space); obj.__setattr__("softspace", Py.Zero); } - PyString string = o.__str__(); - String s = o.toString(); - int len = s.length(); - obj.invoke("write", string); + obj.invoke("write", o); if (o instanceof PyString) { + String s = o.toString(); + int len = s.length(); if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) || s.charAt(len - 1) == ' ') { obj.__setattr__("softspace", space ? Py.One : Py.Zero); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-21 00:20:28
|
Revision: 5342 http://jython.svn.sourceforge.net/jython/?rev=5342&view=rev Author: leosoto Date: 2008-09-21 00:20:23 +0000 (Sun, 21 Sep 2008) Log Message: ----------- importing test_support from the test package on test_exceptions.py Modified Paths: -------------- trunk/jython/Lib/test/test_exceptions.py Modified: trunk/jython/Lib/test/test_exceptions.py =================================================================== --- trunk/jython/Lib/test/test_exceptions.py 2008-09-20 02:08:34 UTC (rev 5341) +++ trunk/jython/Lib/test/test_exceptions.py 2008-09-21 00:20:23 UTC (rev 5342) @@ -339,7 +339,7 @@ def test_main(): - import test_support + from test import test_support if test_support.is_jython: # XXX: http://bugs.jython.org/issue1063 del ExceptionTests.testInfiniteRecursion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-20 02:08:41
|
Revision: 5341 http://jython.svn.sourceforge.net/jython/?rev=5341&view=rev Author: leosoto Date: 2008-09-20 02:08:34 +0000 (Sat, 20 Sep 2008) Log Message: ----------- PyType now exposes __repr__ and __str__ as documented on <http://wiki.python.org/jython/JythonDeveloperGuide/ImplementingStrAndRepr>. This fixes #1131 Modified Paths: -------------- trunk/jython/Lib/test/test_class_jy.py trunk/jython/src/org/python/core/PyType.java Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2008-09-18 19:37:19 UTC (rev 5340) +++ trunk/jython/Lib/test/test_class_jy.py 2008-09-20 02:08:34 UTC (rev 5341) @@ -298,7 +298,18 @@ class Bar(object): self.assertEqual(__module__, module_name) +class ClassMetaclassRepr(unittest.TestCase): + """Verifies #1131 is fixed""" + def test_repr_with_metaclass(self): + class FooMetaclass(type): + def __new__(cls, name, bases, attrs): + return super(FooMetaclass, cls).__new__(cls, name, bases, attrs) + class Foo(object): + __metaclass__ = FooMetaclass + self.assertEqual("<class '%s.Foo'>" % __name__, repr(Foo)) + + def test_main(): test_support.run_unittest(ClassGeneralTestCase, ClassNamelessModuleTestCase, @@ -307,6 +318,7 @@ IsDescendentTestCase, JavaClassNamingTestCase, ClassDefinesDunderModule, + ClassMetaclassRepr, ) Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-09-18 19:37:19 UTC (rev 5340) +++ trunk/jython/src/org/python/core/PyType.java 2008-09-20 02:08:34 UTC (rev 5341) @@ -1344,7 +1344,8 @@ return numSlots; } - public String toString() { + @ExposedMethod(names = {"__repr__", "__str__"}) + public String type_toString() { String kind; if (!builtin) { kind = "class"; @@ -1358,6 +1359,10 @@ return String.format("<%s '%s'>", kind, getName()); } + public String toString() { + return type_toString(); + } + /** * Raises AttributeError on type objects. The message differs from * PyObject#noAttributeError, to mimic CPython behaviour. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-18 12:37:21
|
Revision: 5340 http://jython.svn.sourceforge.net/jython/?rev=5340&view=rev Author: fwierzbicki Date: 2008-09-18 19:37:19 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Unicode ast node is a kludge from long ago whose time has passed. I forgot to remove it when I unified str node handling in the parser. Modified Paths: -------------- trunk/jython/ast/Python.asdl trunk/jython/src/org/python/antlr/ast/VisitorBase.java trunk/jython/src/org/python/antlr/ast/VisitorIF.java Removed Paths: ------------- trunk/jython/src/org/python/antlr/ast/Unicode.java Modified: trunk/jython/ast/Python.asdl =================================================================== --- trunk/jython/ast/Python.asdl 2008-09-18 19:07:35 UTC (rev 5339) +++ trunk/jython/ast/Python.asdl 2008-09-18 19:37:19 UTC (rev 5340) @@ -68,7 +68,6 @@ | Repr(expr value) | Num(object n) -- a number as a PyObject. | Str(string s) -- need to specify raw, unicode, etc? - | Unicode(string s) -- need to specify raw, unicode, etc? -- other literals? bools? -- the following expression can appear in assignment context Deleted: trunk/jython/src/org/python/antlr/ast/Unicode.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/Unicode.java 2008-09-18 19:07:35 UTC (rev 5339) +++ trunk/jython/src/org/python/antlr/ast/Unicode.java 2008-09-18 19:37:19 UTC (rev 5340) @@ -1,57 +0,0 @@ -// Autogenerated AST node -package org.python.antlr.ast; -import org.python.antlr.PythonTree; -import org.antlr.runtime.CommonToken; -import org.antlr.runtime.Token; -import java.io.DataOutputStream; -import java.io.IOException; - -public class Unicode extends exprType { - public Object s; - - public static final String[] _fields = new String[] {"s"}; - - public Unicode(Token token, Object s) { - super(token); - this.s = s; - } - - public Unicode(int ttype, Token token, Object s) { - super(ttype, token); - this.s = s; - } - - public Unicode(PythonTree tree, Object s) { - super(tree); - this.s = s; - } - - public String toString() { - return "Unicode"; - } - - public String toStringTree() { - StringBuffer sb = new StringBuffer("Unicode("); - sb.append("s="); - sb.append(dumpThis(s)); - sb.append(","); - sb.append(")"); - return sb.toString(); - } - - public <R> R accept(VisitorIF<R> visitor) throws Exception { - return visitor.visitUnicode(this); - } - - public void traverse(VisitorIF visitor) throws Exception { - } - - public int getLineno() { - return getLine(); - } - - public int getCol_offset() { - return getCharPositionInLine(); - } - -} Modified: trunk/jython/src/org/python/antlr/ast/VisitorBase.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/VisitorBase.java 2008-09-18 19:07:35 UTC (rev 5339) +++ trunk/jython/src/org/python/antlr/ast/VisitorBase.java 2008-09-18 19:37:19 UTC (rev 5340) @@ -251,12 +251,6 @@ return ret; } - public R visitUnicode(Unicode node) throws Exception { - R ret = unhandled_node(node); - traverse(node); - return ret; - } - public R visitAttribute(Attribute node) throws Exception { R ret = unhandled_node(node); traverse(node); Modified: trunk/jython/src/org/python/antlr/ast/VisitorIF.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/VisitorIF.java 2008-09-18 19:07:35 UTC (rev 5339) +++ trunk/jython/src/org/python/antlr/ast/VisitorIF.java 2008-09-18 19:37:19 UTC (rev 5340) @@ -43,7 +43,6 @@ public R visitRepr(Repr node) throws Exception; public R visitNum(Num node) throws Exception; public R visitStr(Str node) throws Exception; - public R visitUnicode(Unicode node) throws Exception; public R visitAttribute(Attribute node) throws Exception; public R visitSubscript(Subscript node) throws Exception; public R visitName(Name node) throws Exception; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-18 12:07:38
|
Revision: 5339 http://jython.svn.sourceforge.net/jython/?rev=5339&view=rev Author: fwierzbicki Date: 2008-09-18 19:07:35 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Fixed another eof/whitespace parsing issue from Django. Turned all of these problems into a new test: test_eof_jy.py. Modified Paths: -------------- trunk/jython/grammar/Python.g trunk/jython/src/org/python/antlr/PythonTokenSource.java Added Paths: ----------- trunk/jython/Lib/test/eof_fodder1.py trunk/jython/Lib/test/eof_fodder2.py trunk/jython/Lib/test/eof_fodder3.py trunk/jython/Lib/test/eof_fodder4.py trunk/jython/Lib/test/eof_fodder5.py trunk/jython/Lib/test/eof_fodder6.py trunk/jython/Lib/test/test_eof_jy.py Added: trunk/jython/Lib/test/eof_fodder1.py =================================================================== --- trunk/jython/Lib/test/eof_fodder1.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder1.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,3 @@ +def d(): + def e(): + pass \ No newline at end of file Added: trunk/jython/Lib/test/eof_fodder2.py =================================================================== --- trunk/jython/Lib/test/eof_fodder2.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder2.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,4 @@ +def f(): + def g(): + pass + \ No newline at end of file Added: trunk/jython/Lib/test/eof_fodder3.py =================================================================== --- trunk/jython/Lib/test/eof_fodder3.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder3.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,4 @@ +def f(): + def g(): + pass + Added: trunk/jython/Lib/test/eof_fodder5.py =================================================================== --- trunk/jython/Lib/test/eof_fodder5.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder5.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,3 @@ +def f(): + pass +# just a comment \ No newline at end of file Added: trunk/jython/Lib/test/eof_fodder6.py =================================================================== --- trunk/jython/Lib/test/eof_fodder6.py (rev 0) +++ trunk/jython/Lib/test/eof_fodder6.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,5 @@ +def f(): + def g(): + pass + + \ No newline at end of file Added: trunk/jython/Lib/test/test_eof_jy.py =================================================================== --- trunk/jython/Lib/test/test_eof_jy.py (rev 0) +++ trunk/jython/Lib/test/test_eof_jy.py 2008-09-18 19:07:35 UTC (rev 5339) @@ -0,0 +1,55 @@ +import unittest +from test import test_support + +class TestEof(unittest.TestCase): + """ + Oddities originally found in Django involving whitespace and newlines or + lack thereof at the end of files. I can't use __builtin__.compile() + because newlines get added and hide these problems, so I have opted to + import Python files containing these oddities. + """ + + def test_indented_no_newline(self): + try: + import eof_fodder1 + except ImportError, cause: + self.fail(cause) + + def test_trailing_ws_no_newline(self): + try: + import eof_fodder2 + except ImportError, cause: + self.fail(cause) + + def test_trailing_ws(self): + try: + import eof_fodder3 + except ImportError, cause: + self.fail(cause) + + def test_empty(self): + try: + import eof_fodder4 + except ImportError, cause: + self.fail(cause) + + def test_just_a_comment_no_newline(self): + try: + import eof_fodder5 + except ImportError, cause: + self.fail(cause) + + def test_junky_ws_after_indent(self): + try: + import eof_fodder6 + except ImportError, cause: + self.fail(cause) + +#============================================================================== + +def test_main(verbose=None): + test_classes = [TestEof] + test_support.run_unittest(*test_classes) + +if __name__ == "__main__": + test_main(verbose=True) Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-09-17 22:37:23 UTC (rev 5338) +++ trunk/jython/grammar/Python.g 2008-09-18 19:07:35 UTC (rev 5339) @@ -1785,7 +1785,7 @@ )+ ( ('\r')? '\n' {newlines++; } )* { - if (input.LA(1) != -1) { + if (input.LA(1) != -1 || newlines == 0) { // make a string of n spaces where n is column number - 1 char[] indentation = new char[spaces]; for (int i=0; i<spaces; i++) { Modified: trunk/jython/src/org/python/antlr/PythonTokenSource.java =================================================================== --- trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-17 22:37:23 UTC (rev 5338) +++ trunk/jython/src/org/python/antlr/PythonTokenSource.java 2008-09-18 19:07:35 UTC (rev 5339) @@ -167,11 +167,18 @@ Token prev = stream.LT(-1); handleEOF((CommonToken)t, (CommonToken)prev); if (!inSingle) { - if (prev == null || prev.getType() != PythonLexer.NEWLINE) { + if (prev == null) { generateNewline(t); + } else if (prev.getType() == PythonLexer.LEADING_WS) { + handleDedents(-1, (CommonToken)t); + generateNewline(t); + } else if (prev.getType() != PythonLexer.NEWLINE) { + generateNewline(t); + handleDedents(-1, (CommonToken)t); } + } else { + handleDedents(-1, (CommonToken)t); } - handleDedents(-1, (CommonToken)t); enqueue(t); } else if (t.getType() == PythonLexer.NEWLINE) { // save NEWLINE in the queue This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-09-17 15:37:25
|
Revision: 5338 http://jython.svn.sourceforge.net/jython/?rev=5338&view=rev Author: otmarhumbel Date: 2008-09-17 22:37:23 +0000 (Wed, 17 Sep 2008) Log Message: ----------- all installer junit tests now pass Modified Paths: -------------- trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java Modified: trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java =================================================================== --- trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java 2008-09-17 22:36:45 UTC (rev 5337) +++ trunk/installer/test/java/org/python/util/install/StartScriptGeneratorTest.java 2008-09-17 22:37:23 UTC (rev 5338) @@ -12,93 +12,98 @@ public class StartScriptGeneratorTest extends TestCase { private static final String AT_DATE = "@DATE"; + private static final String WIN_CR_LF = StartScriptGenerator.WIN_CR_LF; private StartScriptGenerator _generator; + private File _targetDir; + protected void setUp() throws Exception { - _generator = new StartScriptGenerator(new File("C:\\target"), new File("C:\\java")); // dummy values here + String userDirName = System.getProperty("user.dir"); // only true in eclipse ? + File userDir = new File(userDirName); + File parentDir = userDir.getParentFile(); + assertTrue(parentDir.exists()); + _targetDir = new File(parentDir, "jython"); + if (!_targetDir.exists()) { + _targetDir = new File(parentDir, "jython-trunk"); + } + assertTrue(_targetDir.exists()); + assertTrue(_targetDir.isDirectory()); + _targetDir = new File(_targetDir, "src"); + _targetDir = new File(_targetDir, "shell"); + assertTrue(_targetDir.exists()); + assertTrue(_targetDir.isDirectory()); + File javaHome = new File(System.getProperty("java.home")); + _generator = new StartScriptGenerator(_targetDir, javaHome); } + // TODO: test on Solaris public void testUnix() throws IOException { _generator.setFlavour(StartScriptGenerator.UNIX_FLAVOUR); StringBuffer buf = new StringBuffer(100); - buf.append("#!/bin/sh\n"); + buf.append("#!/usr/bin/env bash\n"); buf.append("\n"); buf.append("# This file was generated by the Jython installer\n"); buf.append("# Created on " + AT_DATE + " by " + System.getProperty("user.name") + "\n"); buf.append("\n"); - buf.append("CP=\"C:\\target/" + JarInstaller.JYTHON_JAR + "\"\n"); - buf.append("if [ ! -z \"$CLASSPATH\" ]\n"); // quotes around $CLASSPATH are essential for Solaris - buf.append("then\n"); - buf.append(" CP=$CP:$CLASSPATH\n"); - buf.append("fi\n"); - buf.append("\"C:\\java/bin/java\" -Dpython.home=\"C:\\target\" -classpath \"$CP\" org.python.util.jython \"$@\"\n"); - assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator - .getJythonScript(StartScriptGenerator.UNIX_FLAVOUR)); - - buf = new StringBuffer(50); - buf.append("#!/bin/sh\n"); - buf.append("\n"); - buf.append("# This file was generated by the Jython installer\n"); - buf.append("# Created on " + AT_DATE + " by " + System.getProperty("user.name") + "\n"); - buf.append("\n"); - buf.append("\"C:\\target/jython\" \"C:\\target/Tools/jythonc/jythonc.py\" \"$@\"\n"); -// assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator -// .getJythoncScript(StartScriptGenerator.UNIX_FLAVOUR)); + buf.append("JAVA_HOME=\""); + buf.append(System.getProperty("java.home")); + buf.append("\"\n"); + buf.append("JYTHON_HOME=\""); + buf.append(_targetDir.getAbsolutePath()); + buf.append("\"\n"); + // some rudimentary tests - feel free to do more + String start = buf.toString().replaceAll(AT_DATE, new Date().toString()); + String unixScript = _generator.getJythonScript(StartScriptGenerator.UNIX_FLAVOUR); + assertTrue(unixScript.startsWith(start)); + assertTrue(unixScript.length() > 3500); + assertTrue(unixScript.indexOf("-Dpython.home=") > start.length()); + assertTrue(unixScript.indexOf("-Dpython.executable=") > start.length()); } public void testWindows() throws IOException { StringBuffer winBuf = new StringBuffer(100); - winBuf.append("@echo off"+WIN_CR_LF); - winBuf.append("rem This file was generated by the Jython installer"+WIN_CR_LF); - winBuf.append("rem Created on " + AT_DATE + " by " + System.getProperty("user.name") + ""+WIN_CR_LF); + winBuf.append("@echo off" + WIN_CR_LF); + winBuf.append("rem This file was generated by the Jython installer" + WIN_CR_LF); + winBuf.append("rem Created on " + AT_DATE + " by " + System.getProperty("user.name") + "" + + WIN_CR_LF); winBuf.append(WIN_CR_LF); - winBuf.append("set ARGS="+WIN_CR_LF); + winBuf.append("set JAVA_HOME=\""); + winBuf.append(System.getProperty("java.home")); + winBuf.append("\""); winBuf.append(WIN_CR_LF); - winBuf.append(":loop"+WIN_CR_LF); - winBuf.append("if [%1] == [] goto end"+WIN_CR_LF); - winBuf.append(" set ARGS=%ARGS% %1"+WIN_CR_LF); - winBuf.append(" shift"+WIN_CR_LF); - winBuf.append(" goto loop"+WIN_CR_LF); - winBuf.append(":end"+WIN_CR_LF); + winBuf.append("set JYTHON_HOME=\""); + winBuf.append(_targetDir.getAbsolutePath()); + winBuf.append("\""); winBuf.append(WIN_CR_LF); - - _generator.setFlavour(StartScriptGenerator.WINDOWS_FLAVOUR); - StringBuffer buf = new StringBuffer(100); - buf.append(winBuf); - buf.append("\"C:\\java\\bin\\java.exe\" -Dpython.home=\"C:\\target\" -classpath \"C:\\target\\" - + JarInstaller.JYTHON_JAR + ";%CLASSPATH%\" org.python.util.jython %ARGS%"+WIN_CR_LF); - assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator - .getJythonScript(StartScriptGenerator.WINDOWS_FLAVOUR)); - - buf = new StringBuffer(100); - buf.append(winBuf); - buf.append("\"C:\\target\\jython.bat\" \"C:\\target\\Tools\\jythonc\\jythonc.py\" %ARGS%"+WIN_CR_LF); -// assertEquals(buf.toString().replaceAll(AT_DATE, new Date().toString()), _generator -// .getJythoncScript(StartScriptGenerator.WINDOWS_FLAVOUR)); + // some rudimentary tests - feel free to do more + String start = winBuf.toString().replaceAll(AT_DATE, new Date().toString()); + String winScript = _generator.getJythonScript(StartScriptGenerator.WINDOWS_FLAVOUR); + assertTrue(winScript.startsWith(start)); + assertTrue(winScript.length() > 3500); + assertTrue(winScript.indexOf("if not [%JAVA_HOME%] == []") > start.length()); + assertTrue(winScript.indexOf("-Dpython.home=") > start.length()); + assertTrue(winScript.indexOf("-Dpython.executable=") > start.length()); } public void testFlavour() { int expectedFlavour; - expectedFlavour = StartScriptGenerator.UNIX_FLAVOUR; _generator.setFlavour(expectedFlavour); assertEquals(expectedFlavour, _generator.getFlavour()); - expectedFlavour = StartScriptGenerator.BOTH_FLAVOUR; _generator.setFlavour(expectedFlavour); assertEquals(expectedFlavour, _generator.getFlavour()); - - TestStartScriptGenerator testGenerator = new TestStartScriptGenerator(new File("dummy"), new File("dummy"), - false); + TestStartScriptGenerator testGenerator = new TestStartScriptGenerator(new File("dummy"), + new File("dummy"), + false); expectedFlavour = StartScriptGenerator.WINDOWS_FLAVOUR; testGenerator.setFlavour(expectedFlavour); assertEquals(expectedFlavour, testGenerator.getFlavour()); expectedFlavour = StartScriptGenerator.UNIX_FLAVOUR; testGenerator.setFlavour(expectedFlavour); assertEquals(expectedFlavour, testGenerator.getFlavour()); - testGenerator = new TestStartScriptGenerator(new File("dummy"), new File("dummy"), true); testGenerator.setFlavour(StartScriptGenerator.WINDOWS_FLAVOUR); assertEquals(StartScriptGenerator.BOTH_FLAVOUR, testGenerator.getFlavour()); @@ -110,21 +115,34 @@ if (!dir.exists()) { assertTrue(dir.mkdirs()); } + File bin = new File(dir, "bin"); + if (!bin.exists()) { + assertTrue(bin.mkdirs()); + } + File jython = new File(bin, "jython"); + if (!jython.exists()) { + assertTrue(jython.createNewFile()); + } + File jython_bat = new File(bin, "jython.bat"); + if (!jython_bat.exists()) { + assertTrue(jython_bat.createNewFile()); + } File javaHome = new File(System.getProperty("java.home")); - TestStartScriptGenerator testGenerator = new TestStartScriptGenerator(dir, javaHome, true); + TestStartScriptGenerator testGenerator = new TestStartScriptGenerator(dir, + javaHome, + true); // test generator constructor timing problem: do set the flavour once again testGenerator.setFlavour(StartScriptGenerator.WINDOWS_FLAVOUR); testGenerator.generateStartScripts(); String[] fileNames = dir.list(); - assertEquals(4, fileNames.length); - Set fileNamesSet = new HashSet(4); + assertEquals(3, fileNames.length); // 2 files plus the /bin subdirectory + Set<String> fileNamesSet = new HashSet<String>(4); for (int i = 0; i < fileNames.length; i++) { fileNamesSet.add(fileNames[i]); } + assertTrue(fileNamesSet.contains("bin")); assertTrue(fileNamesSet.contains("jython")); assertTrue(fileNamesSet.contains("jython.bat")); - assertTrue(fileNamesSet.contains("jythonc")); - assertTrue(fileNamesSet.contains("jythonc.bat")); } finally { if (dir.exists()) { rmdir(dir); @@ -147,6 +165,7 @@ } class TestStartScriptGenerator extends StartScriptGenerator { + private boolean _hasBothFlavours; public TestStartScriptGenerator(File targetDirectory, File javaHome, boolean hasBothFlavours) { @@ -158,5 +177,4 @@ return _hasBothFlavours; } } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-09-17 15:36:48
|
Revision: 5337 http://jython.svn.sourceforge.net/jython/?rev=5337&view=rev Author: otmarhumbel Date: 2008-09-17 22:36:45 +0000 (Wed, 17 Sep 2008) Log Message: ----------- o formatted using the coding standards in http://wiki.python.org/jython/CodingStandards?action=AttachFile&do=get&target=Eclipse_Formatting.xml o added a small deviation for junit tests in readFromFile() Modified Paths: -------------- trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java Modified: trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java =================================================================== --- trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java 2008-09-16 20:57:42 UTC (rev 5336) +++ trunk/installer/src/java/org/python/util/install/StartScriptGenerator.java 2008-09-17 22:36:45 UTC (rev 5337) @@ -10,24 +10,28 @@ public class StartScriptGenerator { protected final static int UNIX_FLAVOUR = 10; + protected final static int WINDOWS_FLAVOUR = 30; + protected final static int BOTH_FLAVOUR = 50; + protected final static String WIN_CR_LF; private final static String EXECUTABLE_MODE = "755"; private final static String JYTHON = "jython"; + private final static String JYTHON_BAT = "jython.bat"; - private final static String JYTHON_JAR = JarInstaller.JYTHON_JAR; - static { int dInt = Integer.parseInt("0d", 16); int aInt = Integer.parseInt("0a", 16); - WIN_CR_LF = new String(new char[] { (char) dInt, (char) aInt }); + WIN_CR_LF = new String(new char[] {(char)dInt, (char)aInt}); } private File _targetDirectory; + private File _javaHome; + private int _flavour; public StartScriptGenerator(File targetDirectory, File javaHome) { @@ -47,7 +51,7 @@ // check if we should create unix like scripts, too if (hasUnixlikeShell()) { _flavour = BOTH_FLAVOUR; - } + } } } @@ -75,16 +79,16 @@ } private final void generateJythonScript() throws IOException { - switch (getFlavour()) { - case BOTH_FLAVOUR: - writeToFile(JYTHON_BAT, getJythonScript(WINDOWS_FLAVOUR)); - makeExecutable(writeToFile(JYTHON, getJythonScript(BOTH_FLAVOUR))); - break; - case WINDOWS_FLAVOUR: - writeToFile(JYTHON_BAT, getJythonScript(WINDOWS_FLAVOUR)); - break; - default: - makeExecutable(writeToFile(JYTHON, getJythonScript(UNIX_FLAVOUR))); + switch(getFlavour()){ + case BOTH_FLAVOUR: + writeToFile(JYTHON_BAT, getJythonScript(WINDOWS_FLAVOUR)); + makeExecutable(writeToFile(JYTHON, getJythonScript(BOTH_FLAVOUR))); + break; + case WINDOWS_FLAVOUR: + writeToFile(JYTHON_BAT, getJythonScript(WINDOWS_FLAVOUR)); + break; + default: + makeExecutable(writeToFile(JYTHON, getJythonScript(UNIX_FLAVOUR))); } } @@ -152,7 +156,7 @@ StringBuffer buffer = getUnixHeaderTemplate(); buffer.append("JAVA_HOME=\"{2}\"\n"); buffer.append("JYTHON_HOME=\"{3}\"\n"); - buffer.append("\n"); + buffer.append("\n"); return buffer.toString(); } @@ -172,25 +176,31 @@ } /** - * @param fileName The short file name, e.g. JYTHON_BAT + * @param fileName + * The short file name, e.g. JYTHON_BAT * * @throws IOException */ private String readFromFile(String fileName) throws IOException { - File file = new File(new File(_targetDirectory, "bin"), fileName); - FileReader fileReader = new FileReader(file); - StringBuffer sb = new StringBuffer(); - char[] b = new char[8192]; - int n; - - while ( (n = fileReader.read(b)) > 0) { - sb.append(b, 0, n); - } - return sb.toString(); + // default runtime location + File file = new File(new File(_targetDirectory, "bin"), fileName); + if (!file.exists()) { + // deviation: test time location + file = new File(_targetDirectory, fileName); + } + FileReader fileReader = new FileReader(file); + StringBuffer sb = new StringBuffer(); + char[] b = new char[8192]; + int n; + while ((n = fileReader.read(b)) > 0) { + sb.append(b, 0, n); + } + return sb.toString(); } /** - * @param fileName The short file name, e.g. JYTHON_BAT + * @param fileName + * The short file name, e.g. JYTHON_BAT * @param contents * * @throws IOException @@ -230,5 +240,4 @@ t.printStackTrace(); } } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-16 11:46:00
|
Revision: 5335 http://jython.svn.sourceforge.net/jython/?rev=5335&view=rev Author: fwierzbicki Date: 2008-09-16 18:45:58 +0000 (Tue, 16 Sep 2008) Log Message: ----------- Creating an experimental branch to mess around with some jythonc ideas in code. Added Paths: ----------- branches/jythonc/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-09-16 00:36:50
|
Revision: 5334 http://jython.svn.sourceforge.net/jython/?rev=5334&view=rev Author: otmarhumbel Date: 2008-09-16 07:36:48 +0000 (Tue, 16 Sep 2008) Log Message: ----------- now the test should be more platform independent Modified Paths: -------------- trunk/installer/test/java/org/apache/commons/cli/HelpFormatterTest.java Modified: trunk/installer/test/java/org/apache/commons/cli/HelpFormatterTest.java =================================================================== --- trunk/installer/test/java/org/apache/commons/cli/HelpFormatterTest.java 2008-09-15 23:57:05 UTC (rev 5333) +++ trunk/installer/test/java/org/apache/commons/cli/HelpFormatterTest.java 2008-09-16 07:36:48 UTC (rev 5334) @@ -23,8 +23,8 @@ * the setUp above used to print [-a | -b] [-a] [-b] */ public void testOptionGroupDuplication() { - String help = getFormattedHelp(); - String expectedHelp = new String("usage: syntax [-a | -b]\n-a,--Aa option A\n-b,--Bb option B\n"); + String help = unifyNewLines(getFormattedHelp()); + String expectedHelp = unifyNewLines(new String("usage: syntax [-a | -b]\n-a,--Aa option A\n-b,--Bb option B\n")); assertEquals("expected usage to be '" + expectedHelp + "' instead of '" + help + "'", expectedHelp, help); @@ -53,4 +53,30 @@ String usage = baos.toString(); return usage; } + + /** + * replace the windows specific \r\n line endings with java like \n line endings + * + * @param in + * The string to be transformed + * @return The string with unified line endings + */ + private String unifyNewLines(String in) { + char[] inChars = in.toCharArray(); + StringBuilder b = new StringBuilder(inChars.length); + for (int i = 0; i < inChars.length; i++) { + char current = inChars[i]; + if (current == '\r') { + if (i < inChars.length) { + char next = inChars[i + 1]; + if (next == '\n') { + i++; + current = next; + } + } + } + b.append(current); + } + return b.toString(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-09-15 16:57:07
|
Revision: 5333 http://jython.svn.sourceforge.net/jython/?rev=5333&view=rev Author: fwierzbicki Date: 2008-09-15 23:57:05 +0000 (Mon, 15 Sep 2008) Log Message: ----------- make accept and traverse no-ops for error nodes. Modified Paths: -------------- trunk/jython/src/org/python/antlr/ast/ErrorExpr.java trunk/jython/src/org/python/antlr/ast/ErrorMod.java trunk/jython/src/org/python/antlr/ast/ErrorSlice.java trunk/jython/src/org/python/antlr/ast/ErrorStmt.java Modified: trunk/jython/src/org/python/antlr/ast/ErrorExpr.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ErrorExpr.java 2008-09-15 22:54:07 UTC (rev 5332) +++ trunk/jython/src/org/python/antlr/ast/ErrorExpr.java 2008-09-15 23:57:05 UTC (rev 5333) @@ -25,4 +25,12 @@ return getCharPositionInLine(); } + public <R> R accept(VisitorIF<R> visitor) { + return null; + } + + public void traverse(VisitorIF visitor) throws Exception { + //no op. + } + } Modified: trunk/jython/src/org/python/antlr/ast/ErrorMod.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ErrorMod.java 2008-09-15 22:54:07 UTC (rev 5332) +++ trunk/jython/src/org/python/antlr/ast/ErrorMod.java 2008-09-15 23:57:05 UTC (rev 5333) @@ -25,4 +25,12 @@ return getCharPositionInLine(); } + public <R> R accept(VisitorIF<R> visitor) { + return null; + } + + public void traverse(VisitorIF visitor) throws Exception { + //no op. + } + } Modified: trunk/jython/src/org/python/antlr/ast/ErrorSlice.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ErrorSlice.java 2008-09-15 22:54:07 UTC (rev 5332) +++ trunk/jython/src/org/python/antlr/ast/ErrorSlice.java 2008-09-15 23:57:05 UTC (rev 5333) @@ -29,4 +29,12 @@ return getCharPositionInLine(); } + public <R> R accept(VisitorIF<R> visitor) { + return null; + } + + public void traverse(VisitorIF visitor) throws Exception { + //no op. + } + } Modified: trunk/jython/src/org/python/antlr/ast/ErrorStmt.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ErrorStmt.java 2008-09-15 22:54:07 UTC (rev 5332) +++ trunk/jython/src/org/python/antlr/ast/ErrorStmt.java 2008-09-15 23:57:05 UTC (rev 5333) @@ -29,4 +29,12 @@ return getCharPositionInLine(); } + public <R> R accept(VisitorIF<R> visitor) { + return null; + } + + public void traverse(VisitorIF visitor) throws Exception { + //no op. + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <otm...@us...> - 2008-09-15 15:54:09
|
Revision: 5332 http://jython.svn.sourceforge.net/jython/?rev=5332&view=rev Author: otmarhumbel Date: 2008-09-15 22:54:07 +0000 (Mon, 15 Sep 2008) Log Message: ----------- generified Modified Paths: -------------- trunk/installer/test/java/org/AllTests.java Modified: trunk/installer/test/java/org/AllTests.java =================================================================== --- trunk/installer/test/java/org/AllTests.java 2008-09-15 22:48:39 UTC (rev 5331) +++ trunk/installer/test/java/org/AllTests.java 2008-09-15 22:54:07 UTC (rev 5332) @@ -9,7 +9,6 @@ import java.util.Iterator; import java.util.List; -import junit.framework.Assert; import junit.framework.Test; import junit.framework.TestSuite; @@ -28,7 +27,7 @@ * @throws Exception */ public static Test suite() throws Exception { - Class suiteClass = AllTests.class; + Class<AllTests> suiteClass = AllTests.class; String testSuiteClassName = suiteClass.getName(); File suiteFile = new File(suiteClass.getClassLoader().getResource( testSuiteClassName.replace('.', '/').concat(".class")).getFile()); @@ -45,7 +44,7 @@ private static void buildSuite(int prefixLength, String basePackage, File currentDir, FilenameFilter filter, TestSuite currentSuite) throws Exception { - List potentialDirectories = Arrays.asList(currentDir.listFiles(filter)); + List<File> potentialDirectories = Arrays.asList(currentDir.listFiles(filter)); if (potentialDirectories.size() == 0) { return; } @@ -54,9 +53,9 @@ currentPackageName.append(currentDir.getAbsolutePath().substring(prefixLength).replace('\\', '.').replace('/', '.')); - List classFiles = new ArrayList(potentialDirectories.size()); + List<File> classFiles = new ArrayList<File>(potentialDirectories.size()); Collections.sort(potentialDirectories, new FileComparator()); - Iterator directoryIterator = potentialDirectories.iterator(); + Iterator<File> directoryIterator = potentialDirectories.iterator(); while (directoryIterator.hasNext()) { File potentialDirectory = (File) directoryIterator.next(); if (potentialDirectory.isDirectory()) { @@ -70,7 +69,7 @@ classFiles.add(potentialDirectory); } } - Iterator fileIterator = classFiles.iterator(); + Iterator<File> fileIterator = classFiles.iterator(); while (fileIterator.hasNext()) { File file = (File) fileIterator.next(); StringBuffer className = new StringBuffer(200); @@ -93,11 +92,9 @@ } } - private static class FileComparator implements Comparator { - public int compare(Object o1, Object o2) { - Assert.assertTrue(o1 instanceof File); - Assert.assertTrue(o2 instanceof File); - return ((File) o1).getAbsolutePath().compareTo(((File) o2).getAbsolutePath()); + private static class FileComparator implements Comparator<File> { + public int compare(File f1, File f2) { + return f1.getAbsolutePath().compareTo(f2.getAbsolutePath()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-09-14 00:08:31
|
Revision: 5328 http://jython.svn.sourceforge.net/jython/?rev=5328&view=rev Author: zyasoft Date: 2008-09-14 00:08:28 +0000 (Sun, 14 Sep 2008) Log Message: ----------- Adds tests: test_copy, test_profilehooks, test_random, test_syntax, test_trace that should be reasonable for Jython (possibly with modifications) Provides coverage for #1738411 Modified Paths: -------------- trunk/jython/Lib/test/regrtest.py Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2008-09-13 19:02:55 UTC (rev 5327) +++ trunk/jython/Lib/test/regrtest.py 2008-09-14 00:08:28 UTC (rev 5328) @@ -1476,19 +1476,13 @@ test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw - test_copy test_dis test_eof test_frozen test_gc test_iterlen test_marshal - test_profilehooks test_pyclbr - test_quopri - test_random - test_syntax - test_trace test_ucn test_xml_etree test_zipimport This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zy...@us...> - 2008-09-13 19:02:59
|
Revision: 5327 http://jython.svn.sourceforge.net/jython/?rev=5327&view=rev Author: zyasoft Date: 2008-09-13 19:02:55 +0000 (Sat, 13 Sep 2008) Log Message: ----------- Tests that __module__ is available during class definition time, for #1022 Modified Paths: -------------- trunk/jython/Lib/test/test_class_jy.py Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2008-09-13 18:37:31 UTC (rev 5326) +++ trunk/jython/Lib/test/test_class_jy.py 2008-09-13 19:02:55 UTC (rev 5327) @@ -288,14 +288,26 @@ self.assertEqual(String.__module__, "java.lang") +module_name = __name__ +class ClassDefinesDunderModule(unittest.TestCase): + """Verifies http://bugs.jython.org/issue1022 is fixed""" + def test_dundermodule_in_classdef(self): + class Foo: + self.assertEqual(__module__, module_name) + class Bar(object): + self.assertEqual(__module__, module_name) + + def test_main(): test_support.run_unittest(ClassGeneralTestCase, ClassNamelessModuleTestCase, BrokenNameTestCase, ClassLocalsTestCase, IsDescendentTestCase, - JavaClassNamingTestCase) + JavaClassNamingTestCase, + ClassDefinesDunderModule, + ) if __name__ == "__main__": This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-09-13 18:37:33
|
Revision: 5326 http://jython.svn.sourceforge.net/jython/?rev=5326&view=rev Author: amak Date: 2008-09-13 18:37:31 +0000 (Sat, 13 Sep 2008) Log Message: ----------- Change of mind on behaviour when shutting down server sockets. Instead to raising an exception, best to let the failure pass silently, as cpython does. http://bugs.jython.org/issue1121 Modified Paths: -------------- branches/Release_2_2maint/jython/Lib/socket.py branches/Release_2_2maint/jython/Lib/test/test_socket.py Modified: branches/Release_2_2maint/jython/Lib/socket.py =================================================================== --- branches/Release_2_2maint/jython/Lib/socket.py 2008-09-13 18:31:07 UTC (rev 5325) +++ branches/Release_2_2maint/jython/Lib/socket.py 2008-09-13 18:37:31 UTC (rev 5326) @@ -254,7 +254,7 @@ try: self.jsocket.shutdownInput() except AttributeError, ax: - raise error(errno.ENOTCONN, "Transport endpoint is not connected") + pass # Fail silently server sockets except java.lang.Exception, jlx: raise _map_exception(jlx) @@ -262,7 +262,7 @@ try: self.jsocket.shutdownOutput() except AttributeError, ax: - raise error(errno.ENOTCONN, "Transport endpoint is not connected") + pass # Fail silently server sockets except java.lang.Exception, jlx: raise _map_exception(jlx) Modified: branches/Release_2_2maint/jython/Lib/test/test_socket.py =================================================================== --- branches/Release_2_2maint/jython/Lib/test/test_socket.py 2008-09-13 18:31:07 UTC (rev 5325) +++ branches/Release_2_2maint/jython/Lib/test/test_socket.py 2008-09-13 18:37:31 UTC (rev 5326) @@ -1466,12 +1466,10 @@ self.socket.listen() # socket is now a server socket try: self.socket.shutdown(socket.SHUT_RDWR) - except socket.error, se: - self.failUnlessEqual(se[0], errno.ENOTCONN, "Shutdown on listening socket should have raised errno.ENOTCONN, not %s" % str(se[0])) except Exception, x: - self.fail("Shutdown on listening socket should have raised socket exception, not %s" % str(x)) + self.fail("Shutdown on listening socket should not have raised socket exception, not %s" % str(x)) else: - self.fail("Shutdown on listening socket should have raised socket exception") + pass def testShutdownOnUnconnectedSocket(self): try: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-09-13 18:31:11
|
Revision: 5325 http://jython.svn.sourceforge.net/jython/?rev=5325&view=rev Author: amak Date: 2008-09-13 18:31:07 +0000 (Sat, 13 Sep 2008) Log Message: ----------- Change of mind on behaviour when shutting down server sockets. Instead to raising an exception, best to let the failure pass silently, as cpython does. http://bugs.jython.org/issue1121 Modified Paths: -------------- trunk/jython/Lib/socket.py trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2008-09-13 18:09:58 UTC (rev 5324) +++ trunk/jython/Lib/socket.py 2008-09-13 18:31:07 UTC (rev 5325) @@ -258,7 +258,7 @@ try: self.jsocket.shutdownInput() except AttributeError, ax: - raise error(errno.ENOTCONN, "Transport endpoint is not connected") + pass # Fail silently server sockets except java.lang.Exception, jlx: raise _map_exception(jlx) @@ -266,7 +266,7 @@ try: self.jsocket.shutdownOutput() except AttributeError, ax: - raise error(errno.ENOTCONN, "Transport endpoint is not connected") + pass # Fail silently server sockets except java.lang.Exception, jlx: raise _map_exception(jlx) Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2008-09-13 18:09:58 UTC (rev 5324) +++ trunk/jython/Lib/test/test_socket.py 2008-09-13 18:31:07 UTC (rev 5325) @@ -1474,12 +1474,10 @@ self.socket.listen() # socket is now a server socket try: self.socket.shutdown(socket.SHUT_RDWR) - except socket.error, se: - self.failUnlessEqual(se[0], errno.ENOTCONN, "Shutdown on listening socket should have raised errno.ENOTCONN, not %s" % str(se[0])) except Exception, x: - self.fail("Shutdown on listening socket should have raised socket exception, not %s" % str(x)) + self.fail("Shutdown on listening socket should not have raised socket exception, not %s" % str(x)) else: - self.fail("Shutdown on listening socket should have raised socket exception") + pass def testShutdownOnUnconnectedSocket(self): try: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-09-13 18:10:01
|
Revision: 5324 http://jython.svn.sourceforge.net/jython/?rev=5324&view=rev Author: amak Date: 2008-09-13 18:09:58 +0000 (Sat, 13 Sep 2008) Log Message: ----------- Checking in fixes for 3 bugs http://bugs.jython.org/issue1119 - socket module has no attribute SO_ERROR http://bugs.jython.org/issue1120 - invalid socket shutdown gives AssertionError, should be "transport endpoint not connected" socket.error http://bugs.jython.org/issue1121 - listening socket shutdown expects the wrong kind of socket Modified Paths: -------------- trunk/jython/Lib/socket.py trunk/jython/Lib/test/test_socket.py Modified: trunk/jython/Lib/socket.py =================================================================== --- trunk/jython/Lib/socket.py 2008-09-13 17:04:58 UTC (rev 5323) +++ trunk/jython/Lib/socket.py 2008-09-13 18:09:58 UTC (rev 5324) @@ -149,7 +149,7 @@ __all__ = ['AF_UNSPEC', 'AF_INET', 'AF_INET6', 'AI_PASSIVE', 'SOCK_DGRAM', 'SOCK_RAW', 'SOCK_RDM', 'SOCK_SEQPACKET', 'SOCK_STREAM', 'SOL_SOCKET', - 'SO_BROADCAST', 'SO_KEEPALIVE', 'SO_LINGER', 'SO_OOBINLINE', + 'SO_BROADCAST', 'SO_ERROR', 'SO_KEEPALIVE', 'SO_LINGER', 'SO_OOBINLINE', 'SO_RCVBUF', 'SO_REUSEADDR', 'SO_SNDBUF', 'SO_TIMEOUT', 'TCP_NODELAY', 'SocketType', 'error', 'herror', 'gaierror', 'timeout', 'getfqdn', 'gethostbyaddr', 'gethostbyname', 'gethostname', @@ -183,6 +183,23 @@ TCP_NODELAY = 256 +# Options with negative constants are not supported +# They are being added here so that code that refers to them +# will not break with an AttributeError + +SO_ACCEPTCONN = -1 +SO_DEBUG = -2 +SO_DONTROUTE = -4 +SO_ERROR = -8 +SO_EXCLUSIVEADDRUSE = -16 +SO_RCVLOWAT = -32 +SO_RCVTIMEO = -64 +SO_REUSEPORT = -128 +SO_SNDLOWAT = -256 +SO_SNDTIMEO = -512 +SO_TYPE = -1024 +SO_USELOOPBACK = -2048 + class _nio_impl: timeout = None @@ -240,12 +257,16 @@ def shutdownInput(self): try: self.jsocket.shutdownInput() + except AttributeError, ax: + raise error(errno.ENOTCONN, "Transport endpoint is not connected") except java.lang.Exception, jlx: raise _map_exception(jlx) def shutdownOutput(self): try: self.jsocket.shutdownOutput() + except AttributeError, ax: + raise error(errno.ENOTCONN, "Transport endpoint is not connected") except java.lang.Exception, jlx: raise _map_exception(jlx) @@ -806,8 +827,9 @@ raise _map_exception(jlx) def shutdown(self, how): + if not self.sock_impl: + raise error(errno.ENOTCONN, "Transport endpoint is not connected") assert how in (SHUT_RD, SHUT_WR, SHUT_RDWR) - assert self.sock_impl if how in (SHUT_RD, SHUT_RDWR): self.sock_impl.shutdownInput() if how in (SHUT_WR, SHUT_RDWR): Modified: trunk/jython/Lib/test/test_socket.py =================================================================== --- trunk/jython/Lib/test/test_socket.py 2008-09-13 17:04:58 UTC (rev 5323) +++ trunk/jython/Lib/test/test_socket.py 2008-09-13 18:09:58 UTC (rev 5324) @@ -567,8 +567,10 @@ else: self.fail("Setting unsupported option should have raised an exception") +class TestSupportedOptions(TestSocketOptions): + def testSO_BROADCAST(self): - self.test_udp = 1 ; + self.test_udp = 1 self._testOption(socket.SO_BROADCAST, [0, 1]) def testSO_KEEPALIVE(self): @@ -612,28 +614,49 @@ self.test_tcp_client = 1 self._testOption(socket.TCP_NODELAY, [0, 1]) -class AsYetUnsupportedOptions: +class TestUnsupportedOptions(TestSocketOptions): - def testSO_ACCEPTCONN(self): pass - def testSO_DEBUG(self): pass - def testSO_DONTROUTE(self): pass - def testSO_ERROR(self): pass + def testSO_ACCEPTCONN(self): + self.failUnless(hasattr(socket, 'SO_ACCEPTCONN')) + + def testSO_DEBUG(self): + self.failUnless(hasattr(socket, 'SO_DEBUG')) + + def testSO_DONTROUTE(self): + self.failUnless(hasattr(socket, 'SO_DONTROUTE')) + + def testSO_ERROR(self): + self.failUnless(hasattr(socket, 'SO_ERROR')) + def testSO_EXCLUSIVEADDRUSE(self): # this is an MS specific option that will not be appearing on java # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6421091 # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6402335 - pass - def testSO_RCVLOWAT(self): pass - def testSO_RCVTIMEO(self): pass + self.failUnless(hasattr(socket, 'SO_EXCLUSIVEADDRUSE')) + + def testSO_RCVLOWAT(self): + self.failUnless(hasattr(socket, 'SO_RCVLOWAT')) + + def testSO_RCVTIMEO(self): + self.failUnless(hasattr(socket, 'SO_RCVTIMEO')) + def testSO_REUSEPORT(self): # not yet supported on java # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6432031 - pass - def testSO_SNDLOWAT(self): pass - def testSO_SNDTIMEO(self): pass - def testSO_TYPE(self): pass - def testSO_USELOOPBACK(self): pass + self.failUnless(hasattr(socket, 'SO_REUSEPORT')) + def testSO_SNDLOWAT(self): + self.failUnless(hasattr(socket, 'SO_SNDLOWAT')) + + def testSO_SNDTIMEO(self): + self.failUnless(hasattr(socket, 'SO_SNDTIMEO')) + + def testSO_TYPE(self): + self.failUnless(hasattr(socket, 'SO_TYPE')) + + def testSO_USELOOPBACK(self): + self.failUnless(hasattr(socket, 'SO_USELOOPBACK')) + class BasicTCPTest(SocketConnectedTest): def __init__(self, methodName='runTest'): @@ -1441,15 +1464,43 @@ def _testUnicodeHostname(self): self.cli.connect((unicode(HOST), PORT)) - + +class TestInvalidUsage(unittest.TestCase): + + def setUp(self): + self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + def testShutdownIOOnListener(self): + self.socket.listen() # socket is now a server socket + try: + self.socket.shutdown(socket.SHUT_RDWR) + except socket.error, se: + self.failUnlessEqual(se[0], errno.ENOTCONN, "Shutdown on listening socket should have raised errno.ENOTCONN, not %s" % str(se[0])) + except Exception, x: + self.fail("Shutdown on listening socket should have raised socket exception, not %s" % str(x)) + else: + self.fail("Shutdown on listening socket should have raised socket exception") + + def testShutdownOnUnconnectedSocket(self): + try: + self.socket.shutdown(socket.SHUT_RDWR) + except socket.error, se: + self.failUnlessEqual(se[0], errno.ENOTCONN, "Shutdown on unconnected socket should have raised errno.ENOTCONN, not %s" % str(se[0])) + except Exception, x: + self.fail("Shutdown on unconnected socket should have raised socket exception, not %s" % str(x)) + else: + self.fail("Shutdown on unconnected socket should have raised socket exception") + def test_main(): tests = [ GeneralModuleTests, - TestSocketOptions, + TestSupportedOptions, + TestUnsupportedOptions, BasicTCPTest, TCPTimeoutTest, TCPClientTimeoutTest, TestExceptions, + TestInvalidUsage, TestTCPAddressParameters, TestUDPAddressParameters, BasicUDPTest, @@ -1464,7 +1515,7 @@ UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase, - UnicodeTest + UnicodeTest, ] if hasattr(socket, "socketpair"): tests.append(BasicSocketPairTest) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <le...@us...> - 2008-09-13 17:05:00
|
Revision: 5323 http://jython.svn.sourceforge.net/jython/?rev=5323&view=rev Author: leosoto Date: 2008-09-13 17:04:58 +0000 (Sat, 13 Sep 2008) Log Message: ----------- Test for the 'feature' described on #1089: cStringIO.StringIO.read always returns string objects Added Paths: ----------- trunk/jython/Lib/test/test_StringIO_jy.py Added: trunk/jython/Lib/test/test_StringIO_jy.py =================================================================== --- trunk/jython/Lib/test/test_StringIO_jy.py (rev 0) +++ trunk/jython/Lib/test/test_StringIO_jy.py 2008-09-13 17:04:58 UTC (rev 5323) @@ -0,0 +1,20 @@ +import unittest +import cStringIO +from test import test_support + +class TestUnicodeInput(unittest.TestCase): + def test_differences_handling_unicode(self): + # Test for the "feature" described on #1089. + # + # Basically, StringIO returns unicode objects if you feed it unicode, + # but cStringIO don't. This should change in future versions of + # CPython and Jython. + self.assertEqual(u'foo', cStringIO.StringIO(u'foo').read()) + self.assertEqual('foo', cStringIO.StringIO(u'foo').read()) + + +def test_main(): + test_support.run_unittest(TestUnicodeInput) + +if __name__ == '__main__': + test_main() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <am...@us...> - 2008-09-13 14:10:15
|
Revision: 5322 http://jython.svn.sourceforge.net/jython/?rev=5322&view=rev Author: amak Date: 2008-09-13 14:10:12 +0000 (Sat, 13 Sep 2008) Log Message: ----------- Checking in fixes for 3 bugs http://bugs.jython.org/issue1119 - socket module has no attribute SO_ERROR http://bugs.jython.org/issue1120 - invalid socket shutdown gives AssertionError, should be "transport endpoint not connected" socket.error http://bugs.jython.org/issue1121 - listening socket shutdown expects the wrong kind of socket Will port fixes to trunk also. Modified Paths: -------------- branches/Release_2_2maint/jython/Lib/socket.py branches/Release_2_2maint/jython/Lib/test/test_socket.py Modified: branches/Release_2_2maint/jython/Lib/socket.py =================================================================== --- branches/Release_2_2maint/jython/Lib/socket.py 2008-09-11 20:18:43 UTC (rev 5321) +++ branches/Release_2_2maint/jython/Lib/socket.py 2008-09-13 14:10:12 UTC (rev 5322) @@ -145,7 +145,7 @@ __all__ = ['AF_UNSPEC', 'AF_INET', 'AF_INET6', 'AI_PASSIVE', 'SOCK_DGRAM', 'SOCK_RAW', 'SOCK_RDM', 'SOCK_SEQPACKET', 'SOCK_STREAM', 'SOL_SOCKET', - 'SO_BROADCAST', 'SO_KEEPALIVE', 'SO_LINGER', 'SO_OOBINLINE', + 'SO_BROADCAST', 'SO_ERROR', 'SO_KEEPALIVE', 'SO_LINGER', 'SO_OOBINLINE', 'SO_RCVBUF', 'SO_REUSEADDR', 'SO_SNDBUF', 'SO_TIMEOUT', 'TCP_NODELAY', 'SocketType', 'error', 'herror', 'gaierror', 'timeout', 'getfqdn', 'gethostbyaddr', 'gethostbyname', 'gethostname', @@ -179,6 +179,23 @@ TCP_NODELAY = 256 +# Options with negative constants are not supported +# They are being added here so that code that refers to them +# will not break with an AttributeError + +SO_ACCEPTCONN = -1 +SO_DEBUG = -2 +SO_DONTROUTE = -4 +SO_ERROR = -8 +SO_EXCLUSIVEADDRUSE = -16 +SO_RCVLOWAT = -32 +SO_RCVTIMEO = -64 +SO_REUSEPORT = -128 +SO_SNDLOWAT = -256 +SO_SNDTIMEO = -512 +SO_TYPE = -1024 +SO_USELOOPBACK = -2048 + class _nio_impl: timeout = None @@ -236,12 +253,16 @@ def shutdownInput(self): try: self.jsocket.shutdownInput() + except AttributeError, ax: + raise error(errno.ENOTCONN, "Transport endpoint is not connected") except java.lang.Exception, jlx: raise _map_exception(jlx) def shutdownOutput(self): try: self.jsocket.shutdownOutput() + except AttributeError, ax: + raise error(errno.ENOTCONN, "Transport endpoint is not connected") except java.lang.Exception, jlx: raise _map_exception(jlx) @@ -786,8 +807,9 @@ raise _map_exception(jlx) def shutdown(self, how): + if not self.sock_impl: + raise error(errno.ENOTCONN, "Transport endpoint is not connected") assert how in (SHUT_RD, SHUT_WR, SHUT_RDWR) - assert self.sock_impl if how in (SHUT_RD, SHUT_RDWR): self.sock_impl.shutdownInput() if how in (SHUT_WR, SHUT_RDWR): Modified: branches/Release_2_2maint/jython/Lib/test/test_socket.py =================================================================== --- branches/Release_2_2maint/jython/Lib/test/test_socket.py 2008-09-11 20:18:43 UTC (rev 5321) +++ branches/Release_2_2maint/jython/Lib/test/test_socket.py 2008-09-13 14:10:12 UTC (rev 5322) @@ -1,5 +1,3 @@ -from __future__ import nested_scopes - """ AMAK: 20050515: This module is the test_socket.py from cpython 2.4, ported to jython. """ @@ -569,8 +567,10 @@ else: self.fail("Setting unsupported option should have raised an exception") +class TestSupportedOptions(TestSocketOptions): + def testSO_BROADCAST(self): - self.test_udp = 1 ; + self.test_udp = 1 self._testOption(socket.SO_BROADCAST, [0, 1]) def testSO_KEEPALIVE(self): @@ -614,28 +614,49 @@ self.test_tcp_client = 1 self._testOption(socket.TCP_NODELAY, [0, 1]) -class AsYetUnsupportedOptions: +class TestUnsupportedOptions(TestSocketOptions): - def testSO_ACCEPTCONN(self): pass - def testSO_DEBUG(self): pass - def testSO_DONTROUTE(self): pass - def testSO_ERROR(self): pass + def testSO_ACCEPTCONN(self): + self.failUnless(hasattr(socket, 'SO_ACCEPTCONN')) + + def testSO_DEBUG(self): + self.failUnless(hasattr(socket, 'SO_DEBUG')) + + def testSO_DONTROUTE(self): + self.failUnless(hasattr(socket, 'SO_DONTROUTE')) + + def testSO_ERROR(self): + self.failUnless(hasattr(socket, 'SO_ERROR')) + def testSO_EXCLUSIVEADDRUSE(self): # this is an MS specific option that will not be appearing on java # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6421091 # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6402335 - pass - def testSO_RCVLOWAT(self): pass - def testSO_RCVTIMEO(self): pass + self.failUnless(hasattr(socket, 'SO_EXCLUSIVEADDRUSE')) + + def testSO_RCVLOWAT(self): + self.failUnless(hasattr(socket, 'SO_RCVLOWAT')) + + def testSO_RCVTIMEO(self): + self.failUnless(hasattr(socket, 'SO_RCVTIMEO')) + def testSO_REUSEPORT(self): # not yet supported on java # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6432031 - pass - def testSO_SNDLOWAT(self): pass - def testSO_SNDTIMEO(self): pass - def testSO_TYPE(self): pass - def testSO_USELOOPBACK(self): pass + self.failUnless(hasattr(socket, 'SO_REUSEPORT')) + def testSO_SNDLOWAT(self): + self.failUnless(hasattr(socket, 'SO_SNDLOWAT')) + + def testSO_SNDTIMEO(self): + self.failUnless(hasattr(socket, 'SO_SNDTIMEO')) + + def testSO_TYPE(self): + self.failUnless(hasattr(socket, 'SO_TYPE')) + + def testSO_USELOOPBACK(self): + self.failUnless(hasattr(socket, 'SO_USELOOPBACK')) + class BasicTCPTest(SocketConnectedTest): def __init__(self, methodName='runTest'): @@ -1436,14 +1457,42 @@ def setUp(self): self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +class TestInvalidUsage(unittest.TestCase): + + def setUp(self): + self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + def testShutdownIOOnListener(self): + self.socket.listen() # socket is now a server socket + try: + self.socket.shutdown(socket.SHUT_RDWR) + except socket.error, se: + self.failUnlessEqual(se[0], errno.ENOTCONN, "Shutdown on listening socket should have raised errno.ENOTCONN, not %s" % str(se[0])) + except Exception, x: + self.fail("Shutdown on listening socket should have raised socket exception, not %s" % str(x)) + else: + self.fail("Shutdown on listening socket should have raised socket exception") + + def testShutdownOnUnconnectedSocket(self): + try: + self.socket.shutdown(socket.SHUT_RDWR) + except socket.error, se: + self.failUnlessEqual(se[0], errno.ENOTCONN, "Shutdown on unconnected socket should have raised errno.ENOTCONN, not %s" % str(se[0])) + except Exception, x: + self.fail("Shutdown on unconnected socket should have raised socket exception, not %s" % str(x)) + else: + self.fail("Shutdown on unconnected socket should have raised socket exception") + def test_main(): tests = [ GeneralModuleTests, - TestSocketOptions, + TestSupportedOptions, + TestUnsupportedOptions, BasicTCPTest, TCPTimeoutTest, TCPClientTimeoutTest, TestExceptions, + TestInvalidUsage, TestTCPAddressParameters, TestUDPAddressParameters, BasicUDPTest, @@ -1457,7 +1506,7 @@ PrivateFileObjectTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, - SmallBufferedFileObjectClassTestCase + SmallBufferedFileObjectClassTestCase, ] if hasattr(socket, "socketpair"): tests.append(BasicSocketPairTest) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |