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: <cg...@us...> - 2009-01-05 07:08:58
|
Revision: 5846 http://jython.svn.sourceforge.net/jython/?rev=5846&view=rev Author: cgroves Date: 2009-01-05 07:08:51 +0000 (Mon, 05 Jan 2009) Log Message: ----------- >From http://svn.python.org/projects/python/branches/release25-maint/Lib/test/test_doctest.py@59127 Added Paths: ----------- trunk/jython/Lib/test/test_doctest.py Added: trunk/jython/Lib/test/test_doctest.py =================================================================== --- trunk/jython/Lib/test/test_doctest.py (rev 0) +++ trunk/jython/Lib/test/test_doctest.py 2009-01-05 07:08:51 UTC (rev 5846) @@ -0,0 +1,2437 @@ +""" +Test script for doctest. +""" + +from test import test_support +import doctest +import warnings + +###################################################################### +## Sample Objects (used by test cases) +###################################################################### + +def sample_func(v): + """ + Blah blah + + >>> print sample_func(22) + 44 + + Yee ha! + """ + return v+v + +class SampleClass: + """ + >>> print 1 + 1 + + >>> # comments get ignored. so are empty PS1 and PS2 prompts: + >>> + ... + + Multiline example: + >>> sc = SampleClass(3) + >>> for i in range(10): + ... sc = sc.double() + ... print sc.get(), + 6 12 24 48 96 192 384 768 1536 3072 + """ + def __init__(self, val): + """ + >>> print SampleClass(12).get() + 12 + """ + self.val = val + + def double(self): + """ + >>> print SampleClass(12).double().get() + 24 + """ + return SampleClass(self.val + self.val) + + def get(self): + """ + >>> print SampleClass(-5).get() + -5 + """ + return self.val + + def a_staticmethod(v): + """ + >>> print SampleClass.a_staticmethod(10) + 11 + """ + return v+1 + a_staticmethod = staticmethod(a_staticmethod) + + def a_classmethod(cls, v): + """ + >>> print SampleClass.a_classmethod(10) + 12 + >>> print SampleClass(0).a_classmethod(10) + 12 + """ + return v+2 + a_classmethod = classmethod(a_classmethod) + + a_property = property(get, doc=""" + >>> print SampleClass(22).a_property + 22 + """) + + class NestedClass: + """ + >>> x = SampleClass.NestedClass(5) + >>> y = x.square() + >>> print y.get() + 25 + """ + def __init__(self, val=0): + """ + >>> print SampleClass.NestedClass().get() + 0 + """ + self.val = val + def square(self): + return SampleClass.NestedClass(self.val*self.val) + def get(self): + return self.val + +class SampleNewStyleClass(object): + r""" + >>> print '1\n2\n3' + 1 + 2 + 3 + """ + def __init__(self, val): + """ + >>> print SampleNewStyleClass(12).get() + 12 + """ + self.val = val + + def double(self): + """ + >>> print SampleNewStyleClass(12).double().get() + 24 + """ + return SampleNewStyleClass(self.val + self.val) + + def get(self): + """ + >>> print SampleNewStyleClass(-5).get() + -5 + """ + return self.val + +###################################################################### +## Fake stdin (for testing interactive debugging) +###################################################################### + +class _FakeInput: + """ + A fake input stream for pdb's interactive debugger. Whenever a + line is read, print it (to simulate the user typing it), and then + return it. The set of lines to return is specified in the + constructor; they should not have trailing newlines. + """ + def __init__(self, lines): + self.lines = lines + + def readline(self): + line = self.lines.pop(0) + print line + return line+'\n' + +###################################################################### +## Test Cases +###################################################################### + +def test_Example(): r""" +Unit tests for the `Example` class. + +Example is a simple container class that holds: + - `source`: A source string. + - `want`: An expected output string. + - `exc_msg`: An expected exception message string (or None if no + exception is expected). + - `lineno`: A line number (within the docstring). + - `indent`: The example's indentation in the input string. + - `options`: An option dictionary, mapping option flags to True or + False. + +These attributes are set by the constructor. `source` and `want` are +required; the other attributes all have default values: + + >>> example = doctest.Example('print 1', '1\n') + >>> (example.source, example.want, example.exc_msg, + ... example.lineno, example.indent, example.options) + ('print 1\n', '1\n', None, 0, 0, {}) + +The first three attributes (`source`, `want`, and `exc_msg`) may be +specified positionally; the remaining arguments should be specified as +keyword arguments: + + >>> exc_msg = 'IndexError: pop from an empty list' + >>> example = doctest.Example('[].pop()', '', exc_msg, + ... lineno=5, indent=4, + ... options={doctest.ELLIPSIS: True}) + >>> (example.source, example.want, example.exc_msg, + ... example.lineno, example.indent, example.options) + ('[].pop()\n', '', 'IndexError: pop from an empty list\n', 5, 4, {8: True}) + +The constructor normalizes the `source` string to end in a newline: + + Source spans a single line: no terminating newline. + >>> e = doctest.Example('print 1', '1\n') + >>> e.source, e.want + ('print 1\n', '1\n') + + >>> e = doctest.Example('print 1\n', '1\n') + >>> e.source, e.want + ('print 1\n', '1\n') + + Source spans multiple lines: require terminating newline. + >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n') + >>> e.source, e.want + ('print 1;\nprint 2\n', '1\n2\n') + + >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n') + >>> e.source, e.want + ('print 1;\nprint 2\n', '1\n2\n') + + Empty source string (which should never appear in real examples) + >>> e = doctest.Example('', '') + >>> e.source, e.want + ('\n', '') + +The constructor normalizes the `want` string to end in a newline, +unless it's the empty string: + + >>> e = doctest.Example('print 1', '1\n') + >>> e.source, e.want + ('print 1\n', '1\n') + + >>> e = doctest.Example('print 1', '1') + >>> e.source, e.want + ('print 1\n', '1\n') + + >>> e = doctest.Example('print', '') + >>> e.source, e.want + ('print\n', '') + +The constructor normalizes the `exc_msg` string to end in a newline, +unless it's `None`: + + Message spans one line + >>> exc_msg = 'IndexError: pop from an empty list' + >>> e = doctest.Example('[].pop()', '', exc_msg) + >>> e.exc_msg + 'IndexError: pop from an empty list\n' + + >>> exc_msg = 'IndexError: pop from an empty list\n' + >>> e = doctest.Example('[].pop()', '', exc_msg) + >>> e.exc_msg + 'IndexError: pop from an empty list\n' + + Message spans multiple lines + >>> exc_msg = 'ValueError: 1\n 2' + >>> e = doctest.Example('raise ValueError("1\n 2")', '', exc_msg) + >>> e.exc_msg + 'ValueError: 1\n 2\n' + + >>> exc_msg = 'ValueError: 1\n 2\n' + >>> e = doctest.Example('raise ValueError("1\n 2")', '', exc_msg) + >>> e.exc_msg + 'ValueError: 1\n 2\n' + + Empty (but non-None) exception message (which should never appear + in real examples) + >>> exc_msg = '' + >>> e = doctest.Example('raise X()', '', exc_msg) + >>> e.exc_msg + '\n' +""" + +def test_DocTest(): r""" +Unit tests for the `DocTest` class. + +DocTest is a collection of examples, extracted from a docstring, along +with information about where the docstring comes from (a name, +filename, and line number). The docstring is parsed by the `DocTest` +constructor: + + >>> docstring = ''' + ... >>> print 12 + ... 12 + ... + ... Non-example text. + ... + ... >>> print 'another\example' + ... another + ... example + ... ''' + >>> globs = {} # globals to run the test in. + >>> parser = doctest.DocTestParser() + >>> test = parser.get_doctest(docstring, globs, 'some_test', + ... 'some_file', 20) + >>> print test + <DocTest some_test from some_file:20 (2 examples)> + >>> len(test.examples) + 2 + >>> e1, e2 = test.examples + >>> (e1.source, e1.want, e1.lineno) + ('print 12\n', '12\n', 1) + >>> (e2.source, e2.want, e2.lineno) + ("print 'another\\example'\n", 'another\nexample\n', 6) + +Source information (name, filename, and line number) is available as +attributes on the doctest object: + + >>> (test.name, test.filename, test.lineno) + ('some_test', 'some_file', 20) + +The line number of an example within its containing file is found by +adding the line number of the example and the line number of its +containing test: + + >>> test.lineno + e1.lineno + 21 + >>> test.lineno + e2.lineno + 26 + +If the docstring contains inconsistant leading whitespace in the +expected output of an example, then `DocTest` will raise a ValueError: + + >>> docstring = r''' + ... >>> print 'bad\nindentation' + ... bad + ... indentation + ... ''' + >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) + Traceback (most recent call last): + ValueError: line 4 of the docstring for some_test has inconsistent leading whitespace: 'indentation' + +If the docstring contains inconsistent leading whitespace on +continuation lines, then `DocTest` will raise a ValueError: + + >>> docstring = r''' + ... >>> print ('bad indentation', + ... ... 2) + ... ('bad', 'indentation') + ... ''' + >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) + Traceback (most recent call last): + ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: '... 2)' + +If there's no blank space after a PS1 prompt ('>>>'), then `DocTest` +will raise a ValueError: + + >>> docstring = '>>>print 1\n1' + >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) + Traceback (most recent call last): + ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print 1' + +If there's no blank space after a PS2 prompt ('...'), then `DocTest` +will raise a ValueError: + + >>> docstring = '>>> if 1:\n...print 1\n1' + >>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0) + Traceback (most recent call last): + ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1' + +""" + +def test_DocTestFinder(): r""" +Unit tests for the `DocTestFinder` class. + +DocTestFinder is used to extract DocTests from an object's docstring +and the docstrings of its contained objects. It can be used with +modules, functions, classes, methods, staticmethods, classmethods, and +properties. + +Finding Tests in Functions +~~~~~~~~~~~~~~~~~~~~~~~~~~ +For a function whose docstring contains examples, DocTestFinder.find() +will return a single test (for that function's docstring): + + >>> finder = doctest.DocTestFinder() + +We'll simulate a __file__ attr that ends in pyc: + + >>> import test.test_doctest + >>> old = test.test_doctest.__file__ + >>> test.test_doctest.__file__ = 'test_doctest.pyc' + + >>> tests = finder.find(sample_func) + + >>> print tests # doctest: +ELLIPSIS + [<DocTest sample_func from ...:13 (1 example)>] + +The exact name depends on how test_doctest was invoked, so allow for +leading path components. + + >>> tests[0].filename # doctest: +ELLIPSIS + '...test_doctest.py' + + >>> test.test_doctest.__file__ = old + + + >>> e = tests[0].examples[0] + >>> (e.source, e.want, e.lineno) + ('print sample_func(22)\n', '44\n', 3) + +By default, tests are created for objects with no docstring: + + >>> def no_docstring(v): + ... pass + >>> finder.find(no_docstring) + [] + +However, the optional argument `exclude_empty` to the DocTestFinder +constructor can be used to exclude tests for objects with empty +docstrings: + + >>> def no_docstring(v): + ... pass + >>> excl_empty_finder = doctest.DocTestFinder(exclude_empty=True) + >>> excl_empty_finder.find(no_docstring) + [] + +If the function has a docstring with no examples, then a test with no +examples is returned. (This lets `DocTestRunner` collect statistics +about which functions have no tests -- but is that useful? And should +an empty test also be created when there's no docstring?) + + >>> def no_examples(v): + ... ''' no doctest examples ''' + >>> finder.find(no_examples) # doctest: +ELLIPSIS + [<DocTest no_examples from ...:1 (no examples)>] + +Finding Tests in Classes +~~~~~~~~~~~~~~~~~~~~~~~~ +For a class, DocTestFinder will create a test for the class's +docstring, and will recursively explore its contents, including +methods, classmethods, staticmethods, properties, and nested classes. + + >>> finder = doctest.DocTestFinder() + >>> tests = finder.find(SampleClass) + >>> for t in tests: + ... print '%2s %s' % (len(t.examples), t.name) + 3 SampleClass + 3 SampleClass.NestedClass + 1 SampleClass.NestedClass.__init__ + 1 SampleClass.__init__ + 2 SampleClass.a_classmethod + 1 SampleClass.a_property + 1 SampleClass.a_staticmethod + 1 SampleClass.double + 1 SampleClass.get + +New-style classes are also supported: + + >>> tests = finder.find(SampleNewStyleClass) + >>> for t in tests: + ... print '%2s %s' % (len(t.examples), t.name) + 1 SampleNewStyleClass + 1 SampleNewStyleClass.__init__ + 1 SampleNewStyleClass.double + 1 SampleNewStyleClass.get + +Finding Tests in Modules +~~~~~~~~~~~~~~~~~~~~~~~~ +For a module, DocTestFinder will create a test for the class's +docstring, and will recursively explore its contents, including +functions, classes, and the `__test__` dictionary, if it exists: + + >>> # A module + >>> import new + >>> m = new.module('some_module') + >>> def triple(val): + ... ''' + ... >>> print triple(11) + ... 33 + ... ''' + ... return val*3 + >>> m.__dict__.update({ + ... 'sample_func': sample_func, + ... 'SampleClass': SampleClass, + ... '__doc__': ''' + ... Module docstring. + ... >>> print 'module' + ... module + ... ''', + ... '__test__': { + ... 'd': '>>> print 6\n6\n>>> print 7\n7\n', + ... 'c': triple}}) + + >>> finder = doctest.DocTestFinder() + >>> # Use module=test.test_doctest, to prevent doctest from + >>> # ignoring the objects since they weren't defined in m. + >>> import test.test_doctest + >>> tests = finder.find(m, module=test.test_doctest) + >>> for t in tests: + ... print '%2s %s' % (len(t.examples), t.name) + 1 some_module + 3 some_module.SampleClass + 3 some_module.SampleClass.NestedClass + 1 some_module.SampleClass.NestedClass.__init__ + 1 some_module.SampleClass.__init__ + 2 some_module.SampleClass.a_classmethod + 1 some_module.SampleClass.a_property + 1 some_module.SampleClass.a_staticmethod + 1 some_module.SampleClass.double + 1 some_module.SampleClass.get + 1 some_module.__test__.c + 2 some_module.__test__.d + 1 some_module.sample_func + +Duplicate Removal +~~~~~~~~~~~~~~~~~ +If a single object is listed twice (under different names), then tests +will only be generated for it once: + + >>> from test import doctest_aliases + >>> tests = excl_empty_finder.find(doctest_aliases) + >>> print len(tests) + 2 + >>> print tests[0].name + test.doctest_aliases.TwoNames + + TwoNames.f and TwoNames.g are bound to the same object. + We can't guess which will be found in doctest's traversal of + TwoNames.__dict__ first, so we have to allow for either. + + >>> tests[1].name.split('.')[-1] in ['f', 'g'] + True + +Empty Tests +~~~~~~~~~~~ +By default, an object with no doctests doesn't create any tests: + + >>> tests = doctest.DocTestFinder().find(SampleClass) + >>> for t in tests: + ... print '%2s %s' % (len(t.examples), t.name) + 3 SampleClass + 3 SampleClass.NestedClass + 1 SampleClass.NestedClass.__init__ + 1 SampleClass.__init__ + 2 SampleClass.a_classmethod + 1 SampleClass.a_property + 1 SampleClass.a_staticmethod + 1 SampleClass.double + 1 SampleClass.get + +By default, that excluded objects with no doctests. exclude_empty=False +tells it to include (empty) tests for objects with no doctests. This feature +is really to support backward compatibility in what doctest.master.summarize() +displays. + + >>> tests = doctest.DocTestFinder(exclude_empty=False).find(SampleClass) + >>> for t in tests: + ... print '%2s %s' % (len(t.examples), t.name) + 3 SampleClass + 3 SampleClass.NestedClass + 1 SampleClass.NestedClass.__init__ + 0 SampleClass.NestedClass.get + 0 SampleClass.NestedClass.square + 1 SampleClass.__init__ + 2 SampleClass.a_classmethod + 1 SampleClass.a_property + 1 SampleClass.a_staticmethod + 1 SampleClass.double + 1 SampleClass.get + +Turning off Recursion +~~~~~~~~~~~~~~~~~~~~~ +DocTestFinder can be told not to look for tests in contained objects +using the `recurse` flag: + + >>> tests = doctest.DocTestFinder(recurse=False).find(SampleClass) + >>> for t in tests: + ... print '%2s %s' % (len(t.examples), t.name) + 3 SampleClass + +Line numbers +~~~~~~~~~~~~ +DocTestFinder finds the line number of each example: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... + ... some text + ... + ... >>> # examples are not created for comments & bare prompts. + ... >>> + ... ... + ... + ... >>> for x in range(10): + ... ... print x, + ... 0 1 2 3 4 5 6 7 8 9 + ... >>> x//2 + ... 6 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> [e.lineno for e in test.examples] + [1, 9, 12] +""" + +def test_DocTestParser(): r""" +Unit tests for the `DocTestParser` class. + +DocTestParser is used to parse docstrings containing doctest examples. + +The `parse` method divides a docstring into examples and intervening +text: + + >>> s = ''' + ... >>> x, y = 2, 3 # no output expected + ... >>> if 1: + ... ... print x + ... ... print y + ... 2 + ... 3 + ... + ... Some text. + ... >>> x+y + ... 5 + ... ''' + >>> parser = doctest.DocTestParser() + >>> for piece in parser.parse(s): + ... if isinstance(piece, doctest.Example): + ... print 'Example:', (piece.source, piece.want, piece.lineno) + ... else: + ... print ' Text:', `piece` + Text: '\n' + Example: ('x, y = 2, 3 # no output expected\n', '', 1) + Text: '' + Example: ('if 1:\n print x\n print y\n', '2\n3\n', 2) + Text: '\nSome text.\n' + Example: ('x+y\n', '5\n', 9) + Text: '' + +The `get_examples` method returns just the examples: + + >>> for piece in parser.get_examples(s): + ... print (piece.source, piece.want, piece.lineno) + ('x, y = 2, 3 # no output expected\n', '', 1) + ('if 1:\n print x\n print y\n', '2\n3\n', 2) + ('x+y\n', '5\n', 9) + +The `get_doctest` method creates a Test from the examples, along with the +given arguments: + + >>> test = parser.get_doctest(s, {}, 'name', 'filename', lineno=5) + >>> (test.name, test.filename, test.lineno) + ('name', 'filename', 5) + >>> for piece in test.examples: + ... print (piece.source, piece.want, piece.lineno) + ('x, y = 2, 3 # no output expected\n', '', 1) + ('if 1:\n print x\n print y\n', '2\n3\n', 2) + ('x+y\n', '5\n', 9) +""" + +class test_DocTestRunner: + def basics(): r""" +Unit tests for the `DocTestRunner` class. + +DocTestRunner is used to run DocTest test cases, and to accumulate +statistics. Here's a simple DocTest case we can use: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print x + ... 12 + ... >>> x//2 + ... 6 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + +The main DocTestRunner interface is the `run` method, which runs a +given DocTest case in a given namespace (globs). It returns a tuple +`(f,t)`, where `f` is the number of failed tests and `t` is the number +of tried tests. + + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 3) + +If any example produces incorrect output, then the test runner reports +the failure and proceeds to the next example: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print x + ... 14 + ... >>> x//2 + ... 6 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=True).run(test) + ... # doctest: +ELLIPSIS + Trying: + x = 12 + Expecting nothing + ok + Trying: + print x + Expecting: + 14 + ********************************************************************** + File ..., line 4, in f + Failed example: + print x + Expected: + 14 + Got: + 12 + Trying: + x//2 + Expecting: + 6 + ok + (1, 3) +""" + def verbose_flag(): r""" +The `verbose` flag makes the test runner generate more detailed +output: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print x + ... 12 + ... >>> x//2 + ... 6 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + + >>> doctest.DocTestRunner(verbose=True).run(test) + Trying: + x = 12 + Expecting nothing + ok + Trying: + print x + Expecting: + 12 + ok + Trying: + x//2 + Expecting: + 6 + ok + (0, 3) + +If the `verbose` flag is unspecified, then the output will be verbose +iff `-v` appears in sys.argv: + + >>> # Save the real sys.argv list. + >>> old_argv = sys.argv + + >>> # If -v does not appear in sys.argv, then output isn't verbose. + >>> sys.argv = ['test'] + >>> doctest.DocTestRunner().run(test) + (0, 3) + + >>> # If -v does appear in sys.argv, then output is verbose. + >>> sys.argv = ['test', '-v'] + >>> doctest.DocTestRunner().run(test) + Trying: + x = 12 + Expecting nothing + ok + Trying: + print x + Expecting: + 12 + ok + Trying: + x//2 + Expecting: + 6 + ok + (0, 3) + + >>> # Restore sys.argv + >>> sys.argv = old_argv + +In the remaining examples, the test runner's verbosity will be +explicitly set, to ensure that the test behavior is consistent. + """ + def exceptions(): r""" +Tests of `DocTestRunner`'s exception handling. + +An expected exception is specified with a traceback message. The +lines between the first line and the type/value may be omitted or +replaced with any other string: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print x//0 + ... Traceback (most recent call last): + ... ZeroDivisionError: integer division or modulo by zero + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 2) + +An example may not generate output before it raises an exception; if +it does, then the traceback message will not be recognized as +signaling an expected exception, so the example will be reported as an +unexpected exception: + + >>> def f(x): + ... ''' + ... >>> x = 12 + ... >>> print 'pre-exception output', x//0 + ... pre-exception output + ... Traceback (most recent call last): + ... ZeroDivisionError: integer division or modulo by zero + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 4, in f + Failed example: + print 'pre-exception output', x//0 + Exception raised: + ... + ZeroDivisionError: integer division or modulo by zero + (1, 2) + +Exception messages may contain newlines: + + >>> def f(x): + ... r''' + ... >>> raise ValueError, 'multi\nline\nmessage' + ... Traceback (most recent call last): + ... ValueError: multi + ... line + ... message + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 1) + +If an exception is expected, but an exception with the wrong type or +message is raised, then it is reported as a failure: + + >>> def f(x): + ... r''' + ... >>> raise ValueError, 'message' + ... Traceback (most recent call last): + ... ValueError: wrong message + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 3, in f + Failed example: + raise ValueError, 'message' + Expected: + Traceback (most recent call last): + ValueError: wrong message + Got: + Traceback (most recent call last): + ... + ValueError: message + (1, 1) + +However, IGNORE_EXCEPTION_DETAIL can be used to allow a mismatch in the +detail: + + >>> def f(x): + ... r''' + ... >>> raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL + ... Traceback (most recent call last): + ... ValueError: wrong message + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 1) + +But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type: + + >>> def f(x): + ... r''' + ... >>> raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL + ... Traceback (most recent call last): + ... TypeError: wrong type + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 3, in f + Failed example: + raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL + Expected: + Traceback (most recent call last): + TypeError: wrong type + Got: + Traceback (most recent call last): + ... + ValueError: message + (1, 1) + +If an exception is raised but not expected, then it is reported as an +unexpected exception: + + >>> def f(x): + ... r''' + ... >>> 1//0 + ... 0 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 3, in f + Failed example: + 1//0 + Exception raised: + Traceback (most recent call last): + ... + ZeroDivisionError: integer division or modulo by zero + (1, 1) +""" + def optionflags(): r""" +Tests of `DocTestRunner`'s option flag handling. + +Several option flags can be used to customize the behavior of the test +runner. These are defined as module constants in doctest, and passed +to the DocTestRunner constructor (multiple constants should be or-ed +together). + +The DONT_ACCEPT_TRUE_FOR_1 flag disables matches between True/False +and 1/0: + + >>> def f(x): + ... '>>> True\n1\n' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.DONT_ACCEPT_TRUE_FOR_1 + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 2, in f + Failed example: + True + Expected: + 1 + Got: + True + (1, 1) + +The DONT_ACCEPT_BLANKLINE flag disables the match between blank lines +and the '<BLANKLINE>' marker: + + >>> def f(x): + ... '>>> print "a\\n\\nb"\na\n<BLANKLINE>\nb\n' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.DONT_ACCEPT_BLANKLINE + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 2, in f + Failed example: + print "a\n\nb" + Expected: + a + <BLANKLINE> + b + Got: + a + <BLANKLINE> + b + (1, 1) + +The NORMALIZE_WHITESPACE flag causes all sequences of whitespace to be +treated as equal: + + >>> def f(x): + ... '>>> print 1, 2, 3\n 1 2\n 3' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 2, in f + Failed example: + print 1, 2, 3 + Expected: + 1 2 + 3 + Got: + 1 2 3 + (1, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.NORMALIZE_WHITESPACE + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + (0, 1) + + An example from the docs: + >>> print range(20) #doctest: +NORMALIZE_WHITESPACE + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] + +The ELLIPSIS flag causes ellipsis marker ("...") in the expected +output to match any substring in the actual output: + + >>> def f(x): + ... '>>> print range(15)\n[0, 1, 2, ..., 14]\n' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 2, in f + Failed example: + print range(15) + Expected: + [0, 1, 2, ..., 14] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] + (1, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.ELLIPSIS + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + (0, 1) + + ... also matches nothing: + + >>> for i in range(100): + ... print i**2, #doctest: +ELLIPSIS + 0 1...4...9 16 ... 36 49 64 ... 9801 + + ... can be surprising; e.g., this test passes: + + >>> for i in range(21): #doctest: +ELLIPSIS + ... print i, + 0 1 2 ...1...2...0 + + Examples from the docs: + + >>> print range(20) # doctest:+ELLIPSIS + [0, 1, ..., 18, 19] + + >>> print range(20) # doctest: +ELLIPSIS + ... # doctest: +NORMALIZE_WHITESPACE + [0, 1, ..., 18, 19] + +The SKIP flag causes an example to be skipped entirely. I.e., the +example is not run. It can be useful in contexts where doctest +examples serve as both documentation and test cases, and an example +should be included for documentation purposes, but should not be +checked (e.g., because its output is random, or depends on resources +which would be unavailable.) The SKIP flag can also be used for +'commenting out' broken examples. + + >>> import unavailable_resource # doctest: +SKIP + >>> unavailable_resource.do_something() # doctest: +SKIP + >>> unavailable_resource.blow_up() # doctest: +SKIP + Traceback (most recent call last): + ... + UncheckedBlowUpError: Nobody checks me. + + >>> import random + >>> print random.random() # doctest: +SKIP + 0.721216923889 + +The REPORT_UDIFF flag causes failures that involve multi-line expected +and actual outputs to be displayed using a unified diff: + + >>> def f(x): + ... r''' + ... >>> print '\n'.join('abcdefg') + ... a + ... B + ... c + ... d + ... f + ... g + ... h + ... ''' + + >>> # Without the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 3, in f + Failed example: + print '\n'.join('abcdefg') + Expected: + a + B + c + d + f + g + h + Got: + a + b + c + d + e + f + g + (1, 1) + + >>> # With the flag: + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.REPORT_UDIFF + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 3, in f + Failed example: + print '\n'.join('abcdefg') + Differences (unified diff with -expected +actual): + @@ -1,7 +1,7 @@ + a + -B + +b + c + d + +e + f + g + -h + (1, 1) + +The REPORT_CDIFF flag causes failures that involve multi-line expected +and actual outputs to be displayed using a context diff: + + >>> # Reuse f() from the REPORT_UDIFF example, above. + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.REPORT_CDIFF + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 3, in f + Failed example: + print '\n'.join('abcdefg') + Differences (context diff with expected followed by actual): + *************** + *** 1,7 **** + a + ! B + c + d + f + g + - h + --- 1,7 ---- + a + ! b + c + d + + e + f + g + (1, 1) + + +The REPORT_NDIFF flag causes failures to use the difflib.Differ algorithm +used by the popular ndiff.py utility. This does intraline difference +marking, as well as interline differences. + + >>> def f(x): + ... r''' + ... >>> print "a b c d e f g h i j k l m" + ... a b c d e f g h i j k 1 m + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.REPORT_NDIFF + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 3, in f + Failed example: + print "a b c d e f g h i j k l m" + Differences (ndiff with -expected +actual): + - a b c d e f g h i j k 1 m + ? ^ + + a b c d e f g h i j k l m + ? + ++ ^ + (1, 1) + +The REPORT_ONLY_FIRST_FAILURE supresses result output after the first +failing example: + + >>> def f(x): + ... r''' + ... >>> print 1 # first success + ... 1 + ... >>> print 2 # first failure + ... 200 + ... >>> print 3 # second failure + ... 300 + ... >>> print 4 # second success + ... 4 + ... >>> print 5 # third failure + ... 500 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.REPORT_ONLY_FIRST_FAILURE + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 5, in f + Failed example: + print 2 # first failure + Expected: + 200 + Got: + 2 + (3, 5) + +However, output from `report_start` is not supressed: + + >>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + Trying: + print 1 # first success + Expecting: + 1 + ok + Trying: + print 2 # first failure + Expecting: + 200 + ********************************************************************** + File ..., line 5, in f + Failed example: + print 2 # first failure + Expected: + 200 + Got: + 2 + (3, 5) + +For the purposes of REPORT_ONLY_FIRST_FAILURE, unexpected exceptions +count as failures: + + >>> def f(x): + ... r''' + ... >>> print 1 # first success + ... 1 + ... >>> raise ValueError(2) # first failure + ... 200 + ... >>> print 3 # second failure + ... 300 + ... >>> print 4 # second success + ... 4 + ... >>> print 5 # third failure + ... 500 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> flags = doctest.REPORT_ONLY_FIRST_FAILURE + >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 5, in f + Failed example: + raise ValueError(2) # first failure + Exception raised: + ... + ValueError: 2 + (3, 5) + +New option flags can also be registered, via register_optionflag(). Here +we reach into doctest's internals a bit. + + >>> unlikely = "UNLIKELY_OPTION_NAME" + >>> unlikely in doctest.OPTIONFLAGS_BY_NAME + False + >>> new_flag_value = doctest.register_optionflag(unlikely) + >>> unlikely in doctest.OPTIONFLAGS_BY_NAME + True + +Before 2.4.4/2.5, registering a name more than once erroneously created +more than one flag value. Here we verify that's fixed: + + >>> redundant_flag_value = doctest.register_optionflag(unlikely) + >>> redundant_flag_value == new_flag_value + True + +Clean up. + >>> del doctest.OPTIONFLAGS_BY_NAME[unlikely] + + """ + + def option_directives(): r""" +Tests of `DocTestRunner`'s option directive mechanism. + +Option directives can be used to turn option flags on or off for a +single example. To turn an option on for an example, follow that +example with a comment of the form ``# doctest: +OPTION``: + + >>> def f(x): r''' + ... >>> print range(10) # should fail: no ellipsis + ... [0, 1, ..., 9] + ... + ... >>> print range(10) # doctest: +ELLIPSIS + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 2, in f + Failed example: + print range(10) # should fail: no ellipsis + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (1, 2) + +To turn an option off for an example, follow that example with a +comment of the form ``# doctest: -OPTION``: + + >>> def f(x): r''' + ... >>> print range(10) + ... [0, 1, ..., 9] + ... + ... >>> # should fail: no ellipsis + ... >>> print range(10) # doctest: -ELLIPSIS + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False, + ... optionflags=doctest.ELLIPSIS).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 6, in f + Failed example: + print range(10) # doctest: -ELLIPSIS + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (1, 2) + +Option directives affect only the example that they appear with; they +do not change the options for surrounding examples: + + >>> def f(x): r''' + ... >>> print range(10) # Should fail: no ellipsis + ... [0, 1, ..., 9] + ... + ... >>> print range(10) # doctest: +ELLIPSIS + ... [0, 1, ..., 9] + ... + ... >>> print range(10) # Should fail: no ellipsis + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 2, in f + Failed example: + print range(10) # Should fail: no ellipsis + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + ********************************************************************** + File ..., line 8, in f + Failed example: + print range(10) # Should fail: no ellipsis + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (2, 3) + +Multiple options may be modified by a single option directive. They +may be separated by whitespace, commas, or both: + + >>> def f(x): r''' + ... >>> print range(10) # Should fail + ... [0, 1, ..., 9] + ... >>> print range(10) # Should succeed + ... ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 2, in f + Failed example: + print range(10) # Should fail + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (1, 2) + + >>> def f(x): r''' + ... >>> print range(10) # Should fail + ... [0, 1, ..., 9] + ... >>> print range(10) # Should succeed + ... ... # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 2, in f + Failed example: + print range(10) # Should fail + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (1, 2) + + >>> def f(x): r''' + ... >>> print range(10) # Should fail + ... [0, 1, ..., 9] + ... >>> print range(10) # Should succeed + ... ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + ... # doctest: +ELLIPSIS + ********************************************************************** + File ..., line 2, in f + Failed example: + print range(10) # Should fail + Expected: + [0, 1, ..., 9] + Got: + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + (1, 2) + +The option directive may be put on the line following the source, as +long as a continuation prompt is used: + + >>> def f(x): r''' + ... >>> print range(10) + ... ... # doctest: +ELLIPSIS + ... [0, 1, ..., 9] + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 1) + +For examples with multi-line source, the option directive may appear +at the end of any line: + + >>> def f(x): r''' + ... >>> for x in range(10): # doctest: +ELLIPSIS + ... ... print x, + ... 0 1 2 ... 9 + ... + ... >>> for x in range(10): + ... ... print x, # doctest: +ELLIPSIS + ... 0 1 2 ... 9 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 2) + +If more than one line of an example with multi-line source has an +option directive, then they are combined: + + >>> def f(x): r''' + ... Should fail (option directive not on the last line): + ... >>> for x in range(10): # doctest: +ELLIPSIS + ... ... print x, # doctest: +NORMALIZE_WHITESPACE + ... 0 1 2...9 + ... ''' + >>> test = doctest.DocTestFinder().find(f)[0] + >>> doctest.DocTestRunner(verbose=False).run(test) + (0, 1) + +It is an error to have a comment of the form ``# doctest:`` that is +*not* followed by words of the form ``+OPTION`` or ``-OPTION``, where +``OPTION`` is an option that has been registered with +`register_option`: + + >>> # Error: Option not registered + >>> s = '>>> print 12 #doctest: +BADOPTION' + >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) + Traceback (most recent call last): + ValueError: line 1 of the doctest for s has an invalid option: '+BADOPTION' + + >>> # Error: No + or - prefix + >>> s = '>>> print 12 #doctest: ELLIPSIS' + >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) + Traceback (most recent call last): + ValueError: line 1 of the doctest for s has an invalid option: 'ELLIPSIS' + +It is an error to use an option directive on a line that contains no +source: + + >>> s = '>>> # doctest: +ELLIPSIS' + >>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0) + Traceback (most recent call last): + ValueError: line 0 of the doctest for s has an option directive on a line with no example: '# doctest: +ELLIPSIS' +""" + +def test_testsource(): r""" +Unit tests for `testsource()`. + +The testsource() function takes a module and a name, finds the (first) +test with that name in that module, and converts it to a script. The +example code is converted to regular Python code. The surrounding +words and expected output are converted to comments: + + >>> import test.test_doctest + >>> name = 'test.test_doctest.sample_func' + >>> print doctest.testsource(test.test_doctest, name) + # Blah blah + # + print sample_func(22) + # Expected: + ## 44 + # + # Yee ha! + <BLANKLINE> + + >>> name = 'test.test_doctest.SampleNewStyleClass' + >>> print doctest.testsource(test.test_doctest, name) + print '1\n2\n3' + # Expected: + ## 1 + ## 2 + ## 3 + <BLANKLINE> + + >>> name = 'test.test_doctest.SampleClass.a_classmethod' + >>> print doctest.testsource(test.test_doctest, name) + print SampleClass.a_classmethod(10) + # Expected: + ## 12 + print SampleClass(0).a_classmethod(10) + # Expected: + ## 12 + <BLANKLINE> +""" + +def test_debug(): r""" + +Create a docstring that we want to debug: + + >>> s = ''' + ... >>> x = 12 + ... >>> print x + ... 12 + ... ''' + +Create some fake stdin input, to feed to the debugger: + + >>> import tempfile + >>> real_stdin = sys.stdin + >>> sys.stdin = _FakeInput(['next', 'print x', 'continue']) + +Run the debugger on the docstring, and then restore sys.stdin. + + >>> try: doctest.debug_src(s) + ... finally: sys.stdin = real_stdin + > <string>(1)<module>() + (Pdb) next + 12 + --Return-- + > <string>(1)<module>()->None + (Pdb) print x + 12 + (Pdb) continue + +""" + +def test_pdb_set_trace(): + """Using pdb.set_trace from a doctest. + + You can use pdb.set_trace from a doctest. To do so, you must + retrieve the set_trace function from the pdb module at the time + you use it. The doctest module changes sys.stdout so that it can + capture program output. It also temporarily replaces pdb.set_trace + with a version that restores stdout. This is necessary for you to + see debugger output. + + >>> doc = ''' + ... >>> x = 42 + ... >>> import pdb; pdb.set_trace() + ... ''' + >>> parser = doctest.DocTestParser() + >>> test = parser.get_doctest(doc, {}, "foo", "foo.py", 0) + >>> runner = doctest.DocTestRunner(verbose=False) + + To demonstrate this, we'll create a fake standard input that + captures our debugger input: + + >>> import tempfile + >>> real_stdin = sys.stdin + >>> sys.stdin = _FakeInput([ + ... 'print x', # print data defined by the example + ... 'continue', # stop debugging + ... '']) + + >>> try: runner.run(test) + ... finally: sys.stdin = real_stdin + --Return-- + > <doctest foo[1]>(1)<module>()->None + -> import pdb; pdb.set_trace() + (Pdb) print x + 42 + (Pdb) continue + (0, 2) + + You can also put pdb.set_trace in a function called from a test: + + >>> def calls_set_trace(): + ... y=2 + ... import pdb; pdb.set_trace() + + >>> doc = ''' + ... >>> x=1 + ... >>> calls_set_trace() + ... ''' + >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) + >>> real_stdin = sys.stdin + >>> sys.stdin = _FakeInput([ + ... 'print y', # print data defined in the function + ... 'up', # out of function + ... 'print x', # print data defined by the example + ... 'continue', # stop debugging + ... '']) + + >>> try: + ... runner.run(test) + ... finally: + ... sys.stdin = real_stdin + --Return-- + > <doctest test.test_doctest.test_pdb_set_trace[8]>(3)calls_set_trace()->None + -> import pdb; pdb.set_trace() + (Pdb) print y + 2 + (Pdb) up + > <doctest foo[1]>(1)<module>() + -> calls_set_trace() + (Pdb) print x + 1 + (Pdb) continue + (0, 2) + + During interactive debugging, source code is shown, even for + doctest examples: + + >>> doc = ''' + ... >>> def f(x): + ... ... g(x*2) + ... >>> def g(x): + ... ... print x+3 + ... ... import pdb; pdb.set_trace() + ... >>> f(3) + ... ''' + >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) + >>> real_stdin = sys.stdin + >>> sys.stdin = _FakeInput([ + ... 'list', # list source from example 2 + ... 'next', # return from g() + ... 'list', # list source from example 1 + ... 'next', # return from f() + ... 'list', # list source from example 3 + ... 'continue', # stop debugging + ... '']) + >>> try: runner.run(test) + ... finally: sys.stdin = real_stdin + ... # doctest: +NORMALIZE_WHITESPACE + --Return-- + > <doctest foo[1]>(3)g()->None + -> import pdb; pdb.set_trace() + (Pdb) list + 1 def g(x): + 2 print x+3 + 3 -> import pdb; pdb.set_trace() + [EOF] + (Pdb) next + --Return-- + > <doctest foo[0]>(2)f()->None + -> g(x*2) + (Pdb) list + 1 def f(x): + 2 -> g(x*2) + [EOF] + (Pdb) next + --Return-- + > <doctest foo[2]>(1)<module>()->None + -> f(3) + (Pdb) list + 1 -> f(3) + [EOF] + (Pdb) continue + ********************************************************************** + File "foo.py", line 7, in foo + Failed example: + f(3) + Expected nothing + Got: + 9 + (1, 3) + """ + +def test_pdb_set_trace_nested(): + """This illustrates more-demanding use of set_trace with nested functions. + + >>> class C(object): + ... def calls_set_trace(self): + ... y = 1 + ... import pdb; pdb.set_trace() + ... self.f1() + ... y = 2 + ... def f1(self): + ... x = 1 + ... self.f2() + ... x = 2 + ... def f2(self): + ... z = 1 + ... z = 2 + + >>> calls_set_trace = C().calls_set_trace + + >>> doc = ''' + ... >>> a = 1 + ... >>> calls_set_trace() + ... ''' + >>> parser = doctest.DocTestParser() + >>> runner = doctest.DocTestRunner(verbose=False) + >>> test = parser.get_doctest(doc, globals(), "foo", "foo.py", 0) + >>> real_stdin = sys.stdin + >>> sys.stdin = _FakeInput([ + ... 'print y', # print data defined in the function + ... 'step', 'step', 'step', 'step', 'step', 'step', 'print z', + ... 'up', 'print x', + ... 'up', 'print y', + ... 'up', 'print foo', + ... 'continue', # stop debugging + ... '']) + + >>> try: + ... runner.run(test) + ... finally: + ... sys.stdin = real_stdin + > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace() + -> self.f1() + (Pdb) print y + 1 + (Pdb) step + --Call-- + > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(7)f1() + -> def f1(self): + (Pdb) step + > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(8)f1() + -> x = 1 + (Pdb) step + > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(9)f1() + -> self.f2() + (Pdb) step + --Call-- + > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(11)f2() + -> def f2(self): + (Pdb) step + > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(12)f2() + -> z = 1 + (Pdb) step + > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(13)f2() + -> z = 2 + (Pdb) print z + 1 + (Pdb) up + > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(9)f1() + -> self.f2() + (Pdb) print x + 1 + (Pdb) up + > <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace() + -> self.f1() + (Pdb) print y + 1 + (Pdb) up + > <doctest foo[1]>(1)<module>() + -> calls_set_trace() + (Pdb) print foo + *** NameError: name 'foo' is not defined + (Pdb) continue + (0, 2) +""" + +def test_DocTestSuite(): + """DocTestSuite creates a unittest test suite from a doctest. + + We create a Suite by providing a module. A module can be provided + by passing a module object: + + >>> import unittest + >>> import test.sample_doctest + >>> suite = doctest.DocTestSuite(test.sample_doctest) + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=9 errors=0 failures=4> + + We can also supply the module by name: + + >>> suite = doctest.DocTestSuite('test.sample_doctest') + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=9 errors=0 failures=4> + + We can use the current module: + + >>> suite = test.sample_doctest.test_suite() + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=9 errors=0 failures=4> + + We can supply global variables. If we pass globs, they will be + used instead of the module globals. Here we'll pass an empty + globals, triggering an extra error: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', globs={}) + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=9 errors=0 failures=5> + + Alternatively, we can provide extra globals. Here we'll make an + error go away by providing an extra global variable: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... extraglobs={'y': 1}) + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=9 errors=0 failures=3> + + You can pass option flags. Here we'll cause an extra error + by disabling the blank-line feature: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... optionflags=doctest.DONT_ACCEPT_BLANKLINE) + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=9 errors=0 failures=5> + + You can supply setUp and tearDown functions: + + >>> def setUp(t): + ... import test.test_doctest + ... test.test_doctest.sillySetup = True + + >>> def tearDown(t): + ... import test.test_doctest + ... del test.test_doctest.sillySetup + + Here, we installed a silly variable that the test expects: + + >>> suite = doctest.DocTestSuite('test.sample_doctest', + ... setUp=setUp, tearDown=tearDown) + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=9 errors=0 failures=3> + + But the tearDown restores sanity: + + >>> import test.test_doctest + >>> test.test_doctest.sillySetup + Traceback (most recent call last): + ... + AttributeError: 'module' object has no attribute 'sillySetup' + + The setUp and tearDown funtions are passed test objects. Here + we'll use the setUp function to supply the missing variable y: + + >>> def setUp(test): + ... test.globs['y'] = 1 + + >>> suite = doctest.DocTestSuite('test.sample_doctest', setUp=setUp) + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=9 errors=0 failures=3> + + Here, we didn't need to use a tearDown function because we + modified the test globals, which are a copy of the + sample_doctest module dictionary. The test globals are + automatically cleared for us after a test. + """ + +def test_DocFileSuite(): + """We can test tests found in text files using a DocFileSuite. + + We create a suite by providing the names of one or more text + files that include examples: + + >>> import unittest + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... 'test_doctest4.txt') + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=3 errors=0 failures=3> + + The test files are looked for in the directory containing the + calling module. A package keyword argument can be provided to + specify a different relative location. + + >>> import unittest + >>> suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... 'test_doctest4.txt', + ... package='test') + >>> suite.run(unittest.TestResult()) + <unittest.TestResult run=3 errors=0 failures=3> + + Support for using a package's __loader__.get_data() is also + provided. + + >>> import unittest, pkgutil, test + >>> added_loader = False + >>> if not hasattr(test, '__loader__'): + ... test.__loader__ = pkgutil.get_loader(test) + ... added_loader = True + >>> try: + ... suite = doctest.DocFileSuite('test_doctest.txt', + ... 'test_doctest2.txt', + ... 'test_doctest4.txt', + ... package='test') + ... suite.run(unittest.TestResult()) + ... finally: + ... if added_loader: + ... del test.__loader__ + <unittest.TestResult run=3 errors=0 failures=3> + + '/' should be used as a path separator. It will be converted + to a native separator at run time: + + ... [truncated message content] |
From: <cg...@us...> - 2009-01-05 03:56:32
|
Revision: 5845 http://jython.svn.sourceforge.net/jython/?rev=5845&view=rev Author: cgroves Date: 2009-01-05 03:56:25 +0000 (Mon, 05 Jan 2009) Log Message: ----------- test292 - Moved to test_java_integration test293 - Importing no longer auto-imports submodules; deleted test294 - Moved to test_java_subclasses test295 - Moved to test_traceback test296 - Moved to test_import_jy test297,301,310,313,314,315,317 - Testing jythonc; deleted test298 - Moved to test_import_jy test299,300 - Tested by test_file test303 - Moved to test_java_visibility test307,308 - Moved to test_zipimport_jy test309 - Tested by test_scope test311 - Already disabled; deleted test312 - Moved to test_sax_jy test316 - Moved to test_java_integration test318 - Tested by test_syntax test319 - Moved to test_java_visibility Modified Paths: -------------- trunk/jython/Lib/test/test_import_jy.py trunk/jython/Lib/test/test_java_integration.py trunk/jython/Lib/test/test_java_subclasses.py trunk/jython/Lib/test/test_java_visibility.py trunk/jython/Lib/test/test_traceback.py trunk/jython/Lib/test/test_traceback_jy.py trunk/jython/bugtests/test302.py trunk/jython/src/org/python/core/APIReader.java trunk/jython/src/org/python/core/imp.java trunk/jython/src/org/python/core/util/importer.java trunk/jython/tests/java/org/python/tests/BeanInterface.java Added Paths: ----------- trunk/jython/Lib/test/anygui.py trunk/jython/Lib/test/import_nonexistent.py trunk/jython/Lib/test/python_home.policy trunk/jython/Lib/test/syspath_import.jar trunk/jython/Lib/test/test_sax_jy.py trunk/jython/Lib/test/test_zipimport_jy.py trunk/jython/tests/java/org/python/tests/Matryoshka.java Removed Paths: ------------- trunk/jython/bugtests/test292.policy trunk/jython/bugtests/test292.py trunk/jython/bugtests/test293.py trunk/jython/bugtests/test293p/ trunk/jython/bugtests/test294.py trunk/jython/bugtests/test294j.java trunk/jython/bugtests/test295.py trunk/jython/bugtests/test296.py trunk/jython/bugtests/test296p/ trunk/jython/bugtests/test297.py trunk/jython/bugtests/test297c.py trunk/jython/bugtests/test298.py trunk/jython/bugtests/test298m1.py trunk/jython/bugtests/test299.py trunk/jython/bugtests/test300.py trunk/jython/bugtests/test301.py trunk/jython/bugtests/test301c.py trunk/jython/bugtests/test303.py trunk/jython/bugtests/test303j.java trunk/jython/bugtests/test307.py trunk/jython/bugtests/test307foobar.template trunk/jython/bugtests/test307m.template trunk/jython/bugtests/test307p.template trunk/jython/bugtests/test308.py trunk/jython/bugtests/test308d/ trunk/jython/bugtests/test309.py trunk/jython/bugtests/test310.py trunk/jython/bugtests/test310c.py trunk/jython/bugtests/test311.py trunk/jython/bugtests/test312.py trunk/jython/bugtests/test313.py trunk/jython/bugtests/test313c.py trunk/jython/bugtests/test314.py trunk/jython/bugtests/test314c.py trunk/jython/bugtests/test315.py trunk/jython/bugtests/test315c.py trunk/jython/bugtests/test316.py trunk/jython/bugtests/test317.py trunk/jython/bugtests/test317c.py trunk/jython/bugtests/test318.py trunk/jython/bugtests/test319.py trunk/jython/bugtests/test319j.java Added: trunk/jython/Lib/test/anygui.py =================================================================== --- trunk/jython/Lib/test/anygui.py (rev 0) +++ trunk/jython/Lib/test/anygui.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -0,0 +1,40 @@ +'''Used by test_import_jy/test_getattr_module''' +import sys + +class anygui: + __all__ = ['Window'] # Etc... + + def __init__(self): + self.__backend = None + self.__backends = ['msw', 'x', 'mac', 'wx', 'tk', 'java'] + + def __try_to_get(self, modulename): + import imp + try: + module = imp.find_module(modulename) + except (IOError, ImportError, AttributeError, AssertionError): + return None + else: + return module + + def __import_backend(self, wishlist): + candidates = self.__backends[:] + for wish in wishlist: + if wish in candidates: + candidates.remove(wish) + else: + wishlist.remove(wish) + candidates = wishlist + candidates + + for name in candidates: + backend = self.__try_to_get('%sgui' % name) + if not backend: + raise Exception, 'not able to import any GUI backends' + self.__backend = backend + + def __getattr__(self, name): + if not self.__backend: + self.__import_backend(self.__dict__.get('wishlist', [])) + return self.__backend.__dict__[name] + +sys.modules[__name__] = anygui() Added: trunk/jython/Lib/test/import_nonexistent.py =================================================================== --- trunk/jython/Lib/test/import_nonexistent.py (rev 0) +++ trunk/jython/Lib/test/import_nonexistent.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -0,0 +1,7 @@ +try: + import nonexistent_module +except ImportError: + pass # This should cause an import error, but as there's a security manager in place it hasn't + # always done so +else: + raise Error("Should've caused an import error!") Added: trunk/jython/Lib/test/python_home.policy =================================================================== --- trunk/jython/Lib/test/python_home.policy (rev 0) +++ trunk/jython/Lib/test/python_home.policy 2009-01-05 03:56:25 UTC (rev 5845) @@ -0,0 +1,5 @@ +grant codeBase "file:${python.home}/-" { + permission java.util.PropertyPermission "*", "read,write"; + permission java.io.FilePermission "<<ALL FILES>>", "read,write"; +}; + Added: trunk/jython/Lib/test/syspath_import.jar =================================================================== (Binary files differ) Property changes on: trunk/jython/Lib/test/syspath_import.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/jython/Lib/test/test_import_jy.py =================================================================== --- trunk/jython/Lib/test/test_import_jy.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/Lib/test/test_import_jy.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -89,8 +89,14 @@ # Again ensure we didn't recompile self.assertEquals(bytecode, read(init_compiled), 'bytecode was recompiled') + def test_corrupt_bytecode(self): + f = open("empty$py.class", "w") + f.close() + self.assertRaises(ImportError, __import__, "empty") + f = open("empty.py", "w") + f.close() + self.assertRaises(ImportError, __import__, "empty") - class OverrideBuiltinsImportTestCase(unittest.TestCase): def test_override(self): tests = [ @@ -136,7 +142,15 @@ (None, '__builtin__', ('', '', 6))) self.assertEqual(imp.find_module('imp'), (None, 'imp', ('', '', 6))) + def test_getattr_module(self): + '''Replacing __getattr__ in a class shouldn't lead to calls to __getitem__ + http://bugs.jython.org/issue438108''' + from test import anygui + # causes a stack overflow if the bug occurs + self.assertRaises(Exception, getattr, anygui, 'abc') + + def test_main(): test_support.run_unittest(MislabeledImportTestCase, OverrideBuiltinsImportTestCase, Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/Lib/test/test_java_integration.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,5 +1,6 @@ import os import unittest +import subprocess import sys import re @@ -279,6 +280,7 @@ def test_list_delegation(self): for c in ArrayList, Vector: a = c() + self.assertRaises(IndexError, a.__getitem__, 0) a.add("blah") self.assertTrue("blah" in a) self.assertEquals(1, len(a)) @@ -318,6 +320,14 @@ for i in v: pass +class SecurityManagerTest(unittest.TestCase): + def test_nonexistent_import_with_security(self): + policy = test_support.findfile("python_home.policy") + script = test_support.findfile("import_nonexistent.py") + self.assertEquals(subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true", + "-J-Djava.security.manager", "-J-Djava.security.policy=%s" % policy, script]), + 0) + def test_main(): test_support.run_unittest(InstantiationTest, BeanTest, @@ -331,7 +341,7 @@ BigDecimalTest, JavaStringTest, JavaDelegationTest, - ) + SecurityManagerTest) if __name__ == "__main__": test_main() Modified: trunk/jython/Lib/test/test_java_subclasses.py =================================================================== --- trunk/jython/Lib/test/test_java_subclasses.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/Lib/test/test_java_subclasses.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -12,7 +12,7 @@ from java.awt import Color, Component, Dimension, Rectangle from javax.swing.table import AbstractTableModel -from org.python.tests import Callbacker +from org.python.tests import BeanInterface, Callbacker class InterfaceTest(unittest.TestCase): def test_java_calling_python_interface_implementation(self): @@ -146,7 +146,34 @@ ht.put("a", fv) self.failUnless(fv is ht.get("a")) + def test_proxy_generates_protected_methods(self): + """Jython proxies should generate methods for protected methods on their superclasses + Tests for bug #416871""" + output = [] + class RegularBean(BeanInterface): + def __init__(self): + output.append("init") + + def getName(self): + output.append("getName") + class FinalizingBean(RegularBean): + def finalize(self): + pass + def clone(self): + return self.__class__() + + for a in FinalizingBean(), RegularBean(): + self.assertEquals("init", output.pop()) + a.getName() + self.assertEquals("getName", output.pop()) + aa = a.clone() + if isinstance(a, FinalizingBean): + self.assertEquals("init", output.pop()) + aa.name + self.assertEquals("getName", output.pop()) + + """ public abstract class Abstract { public Abstract() { Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/Lib/test/test_java_visibility.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -5,8 +5,8 @@ from test import test_support from java.lang import Byte, Class from java.util import HashMap, Observable, Observer -from org.python.tests import (Coercions, HiddenSuper, InterfaceCombination, Invisible, OnlySubclassable, - OtherSubVisible, SomePyMethods, SubVisible, Visible, VisibleOverride) +from org.python.tests import (Coercions, HiddenSuper, InterfaceCombination, Invisible, Matryoshka, + OnlySubclassable, OtherSubVisible, SomePyMethods, SubVisible, Visible, VisibleOverride) from org.python.tests import VisibilityResults as Results class VisibilityTest(unittest.TestCase): @@ -131,6 +131,17 @@ '''Bug #222847 - Can't access public member of package private base class''' self.assertEquals("hi", HiddenSuper().hi()) + def test_nested_classes(self): + """Test deeply nested classes + + Bug #440660 - using nested java cls @ level >2 fails""" + + Matryoshka.Outermost.Middle.Innermost + + def test_inner_class_identity(self): + """Bug #452947 - Class of innerclass inst <> innerclass""" + self.assertEquals(id(Matryoshka.Outermost), id(Matryoshka.makeOutermost().__class__)) + class JavaClassTest(unittest.TestCase): def test_class_methods_visible(self): self.assertFalse(HashMap.isInterface(), @@ -212,7 +223,7 @@ test_support.run_unittest(VisibilityTest, JavaClassTest, CoercionTest, -# RespectJavaAccessibilityTest, + RespectJavaAccessibilityTest, ClassloaderTest) if __name__ == "__main__": Added: trunk/jython/Lib/test/test_sax_jy.py =================================================================== --- trunk/jython/Lib/test/test_sax_jy.py (rev 0) +++ trunk/jython/Lib/test/test_sax_jy.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -0,0 +1,50 @@ +import sys +import StringIO +import unittest + +from xml.sax import saxutils +from xml.sax import make_parser +from xml.sax.handler import feature_namespaces + +from test import test_support + +file = StringIO.StringIO("""<collection> + <comic title="Sandman" number='62'> + <writer>Neil Gaiman</writer> + <penciller pages='1-9,18-24'>Glyn Dillon</penciller> + <penciller pages="10-17">Charles Vess</penciller> + </comic> + <comic title="Shade, the Changing Man" number="7"> + <writer>Peter Milligan</writer> + <penciller>Chris Bachalo</penciller> + </comic> +</collection>""") + +class FindIssue(saxutils.DefaultHandler): + def __init__(self, title, number): + self.search_title, self.search_number = title, number + self.match = 0 + + def startElement(self,name,attrs): + global match + if name != 'comic' : return + + title = attrs.get('title', None) + number = attrs.get('number',None) + if title == self.search_title and number == self.search_number: + self.match += 1 + +class SimpleSaxTest(unittest.TestCase): + def test_find_issue(self): + parser = make_parser() + parser.setFeature(feature_namespaces,0) + dh = FindIssue('Sandman', '62') + parser.setContentHandler(dh) + parser.parse(file) + self.assertEquals(1, dh.match) +def test_main(): + test_support.run_unittest(SimpleSaxTest) + +if __name__ == "__main__": + test_main() + Modified: trunk/jython/Lib/test/test_traceback.py =================================================================== --- trunk/jython/Lib/test/test_traceback.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/Lib/test/test_traceback.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -158,7 +158,6 @@ err = traceback.format_exception_only(None, None) self.assertEqual(err, ['None\n']) - def test_main(): run_unittest(TracebackCases) Modified: trunk/jython/Lib/test/test_traceback_jy.py =================================================================== --- trunk/jython/Lib/test/test_traceback_jy.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/Lib/test/test_traceback_jy.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -46,7 +46,12 @@ else: self.fail('Expected Exception') + def test_extract_stack(self): + # http://bugs.jython.org/issue437809 + traceback.extract_stack() + + try: raise Exception('foo') except Exception: Added: trunk/jython/Lib/test/test_zipimport_jy.py =================================================================== --- trunk/jython/Lib/test/test_zipimport_jy.py (rev 0) +++ trunk/jython/Lib/test/test_zipimport_jy.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -0,0 +1,31 @@ +import unittest +import sys + +from test import test_support + +class SyspathZipimportTest(unittest.TestCase): + def setUp(self): + self.orig_path = sys.path + sys.path.insert(0, test_support.findfile("syspath_import.jar")) + + def tearDown(self): + sys.path = self.orig_path + + def test_load_class_from_syspath_zip(self): + from syspathonly import Syspath + self.assertEquals(Syspath.staticCall(), "result") + + def test_load_pkg_from_syspath(self): + import syspathpkg + self.assertEquals(syspathpkg.__name__, 'syspathpkg') + self.assert_('syspath_import.jar' in syspathpkg.__file__) + from syspathpkg import module + self.assertEquals(module.__name__, 'syspathpkg.module') + +def test_main(): + test_support.run_unittest(SyspathZipimportTest) + +if __name__ == "__main__": + test_main() + + Deleted: trunk/jython/bugtests/test292.policy =================================================================== --- trunk/jython/bugtests/test292.policy 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test292.policy 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,11 +0,0 @@ - -grant codeBase "file:./classes/-" { - permission java.util.PropertyPermission "*", "read,write"; - permission java.io.FilePermission "<<ALL FILES>>", "read,write"; -}; - -grant codeBase "file:${python.home}/-" { - permission java.util.PropertyPermission "*", "read,write"; - permission java.io.FilePermission "<<ALL FILES>>", "read,write"; -}; - Deleted: trunk/jython/bugtests/test292.py =================================================================== --- trunk/jython/bugtests/test292.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test292.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,16 +0,0 @@ -""" -Test sys.path import when a security profile prevents -creating classloaders. -""" - -import support, java - -support.compileJava("classes/test292j.java") - -home = java.lang.System.getProperty("python.home") -cmd = """\ --Djava.security.manager -Djava.security.policy=test292.policy \ --Dpython.home=%s test292j""" % home - -support.runJava(cmd) - Deleted: trunk/jython/bugtests/test293.py =================================================================== --- trunk/jython/bugtests/test293.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test293.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,13 +0,0 @@ -""" -Test lost syntax error when auto importing submodules. -""" - -import support - -import test293p -try: - test293p.submod.func() -except SyntaxError: - pass -else: - raise support.TestError('should raise a syntax error') Deleted: trunk/jython/bugtests/test294.py =================================================================== --- trunk/jython/bugtests/test294.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test294.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,48 +0,0 @@ -""" -[ #416871 ] proxy fails to have all needed methods -""" - -import support - -support.compileJava('test294j.java') - -import test294j - - -class PyTestA(test294j): - def __init__(self): - output.append( "inited") - def doStart(self): - output.append( "started") - def doEnd(self): - output.append( "completed") - def finalize(self): - pass - def clone(self): - return self.__class__() - -class PyTestB(test294j): - def __init__(self): - output.append( "inited") - def doStart(self): - output.append( "started") - def doEnd(self): - output.append( "completed") - -output = [] - -a = PyTestA() -a.doStart() -aa = a.clone() -aa.doStart() - -assert output == ['inited', 'started', 'inited', 'started'] - -output = [] - -a = PyTestB() -a.doStart() -aa = a.clone() -aa.doStart() - -assert output == ['inited', 'started', 'started'] Deleted: trunk/jython/bugtests/test294j.java =================================================================== --- trunk/jython/bugtests/test294j.java 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test294j.java 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,10 +0,0 @@ -/** - * Just a simple interface to demonstrate how subclassing - * from Jython breaks because of the two protected - * methods 'finalize' and 'clone'. - */ -public interface test294j extends Cloneable { - public void doStart(); - public void doEnd(); -} - Deleted: trunk/jython/bugtests/test295.py =================================================================== --- trunk/jython/bugtests/test295.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test295.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,9 +0,0 @@ -""" -[ #437809 ] traceback error -""" - -import support - -import traceback -traceback.extract_stack() - Deleted: trunk/jython/bugtests/test296.py =================================================================== --- trunk/jython/bugtests/test296.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test296.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,15 +0,0 @@ -""" -[ #438108 ] __getitem__ called when it shouldn't? -""" - -import support -import java - -import test296p -try: - print test296p.abc -except java.lang.StackOverflowError: - raise support.TestError("Shouldn't raise a Stack overflow") -except Exception: - pass - Deleted: trunk/jython/bugtests/test297.py =================================================================== --- trunk/jython/bugtests/test297.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test297.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,11 +0,0 @@ -""" - -""" - -import support - -support.compileJPythonc("test297c.py", output="test297.err") - -if support.grep("jpywork/test297c.java", - r'TestFactory extends .*HTMLFactory', count=1) != 1: - raise support.TestError('Subclassing an inner class should be possible') Deleted: trunk/jython/bugtests/test297c.py =================================================================== --- trunk/jython/bugtests/test297c.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test297c.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,23 +0,0 @@ -from javax.swing.text.html import HTMLEditorKit, FormView - -class TestEditorKit(HTMLEditorKit): - def getViewFactory(self): - return self.TestFactory() - - class TestFactory(HTMLEditorKit.HTMLFactory): - def create(self,e): - o = e.getAttributes().getAttribute(StyleConstants.NameAttribute) - if o == HTML.Tag.INPUT: - return TestFormView(e) - return HTMLEditorKit.HTMLFactory.create(self,e) - -class TestFormView(FormView): - def __init__(self,e): - FormView.__init__(self,e) - - def test(self): - print 'hello' - - def actionPerformed(self,e): - self.test() - Deleted: trunk/jython/bugtests/test298.py =================================================================== --- trunk/jython/bugtests/test298.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test298.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,22 +0,0 @@ -""" -Test a obviously corrupt $py.class file. -""" - -import support -import java - -f = open("test298m1.py", "w") -f.close() - -f = open("test298m1$py.class", "w") -f.close() - -try: - import test298m1 -except ImportError, e: - pass -except java.lang.ArrayIndexOutOfBoundsException: - raise support.TestWarning('Should not throw an ArratIndexOutOfBound') -else: - raise support.TestError('Should throw an import error') - Deleted: trunk/jython/bugtests/test299.py =================================================================== --- trunk/jython/bugtests/test299.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test299.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,24 +0,0 @@ -""" -Test that open append position filepointer at the end -""" - -import support - -s1 = "abcdefghijklmnopqrstuvwxyz" -s2 = "0123456789" -f = open("test299.out", "wb") -f.write(s1) -f.close() -f = open("test299.out", "ab") -f.write(s2) -f.close() - -f = open("test299.out", "rb") -res = f.read() -f.close() - -if res != s1 + s2: - raise support.TestError('File did not append correctly') - - - Deleted: trunk/jython/bugtests/test300.py =================================================================== --- trunk/jython/bugtests/test300.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test300.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,39 +0,0 @@ -""" -test of double seek -""" - -import support - -s1 = "abcdefghijklmnopqrstuvwxyz" -s2 = "0123456789" -f = open("test299.out", "wb") -f.write(s1) -f.close() - -def verify(pos, res): - #print pos, res - if pos != res: - raise support.TestError, "Wrong filepos #1 (%d, %d)" % (pos, res) - - -f = open("test299.out", "rb") -f.read() -verify(f.tell(), 26) -f.seek(-10, 1) -verify(f.tell(), 16) -f.seek(-10, 1) -verify(f.tell(), 6) -f.seek(-1, 1) -verify(f.tell(), 5) -f.seek(-1, 1) -verify(f.tell(), 4) -f.close() - -#raise support.TestWarning('A test of TestWarning. It is not an error') - - - - - - - Deleted: trunk/jython/bugtests/test301.py =================================================================== --- trunk/jython/bugtests/test301.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test301.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,14 +0,0 @@ -""" -[ #434324 ] jythonc -A and dead java vars -""" - -import support - -support.compileJava("classes/test301p/B.java") -support.compileJava("classes/test301p/A.java") -support.compileJPythonc("test301c.py", jar="test301.jar", core=1, - addpackages="test301p", - output="test301.err") - -support.runJava("test301c", classpath="test301.jar", output="test301c.err") - Deleted: trunk/jython/bugtests/test301c.py =================================================================== --- trunk/jython/bugtests/test301c.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test301c.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,9 +0,0 @@ - -import test301p - -class test301c(test301p.A): - pass - -#print test301c() -#print test301p.A() - Modified: trunk/jython/bugtests/test302.py =================================================================== --- trunk/jython/bugtests/test302.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test302.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -2,16 +2,13 @@ In bug #439688 the value 0x99 does not survive the JavaCC parser. """ -import support - +import sys +print sys.defaultencoding f = open("test302s.py", "wb") f.write('v = "\x99"\n') f.close() -try: - import test302s -except SyntaxError: - raise support.TestError('Importing a file with str byte > 128 should not raise a Syntaxerror') +import test302s f = open("test302.out", "w") f.write("\x99") @@ -20,6 +17,4 @@ from java.io import FileInputStream, InputStreamReader readval = InputStreamReader(FileInputStream("test302.out"), 'ISO-8859-1').read() -if ord(test302s.v) != readval: - raise support.TestError("Module source was not decoded correctly %x %x" % - (ord(test302s.v), readval)) +print ord(test302s.v) == readval Deleted: trunk/jython/bugtests/test303.py =================================================================== --- trunk/jython/bugtests/test303.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test303.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,10 +0,0 @@ -""" -Test deeply nested classes -[ #440660 ] using nested java cls @ level >2 fails -""" - -import support -support.compileJava("test303j.java") - -import test303j.A -import test303j.A.B Deleted: trunk/jython/bugtests/test303j.java =================================================================== --- trunk/jython/bugtests/test303j.java 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test303j.java 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,10 +0,0 @@ -public class test303j { - public static class A { - public static class B { - public static class C { - } - } - } -} - - Deleted: trunk/jython/bugtests/test307.py =================================================================== --- trunk/jython/bugtests/test307.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test307.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,42 +0,0 @@ -""" -Test import of modules and packages from sys.path zipfile. -""" - -import support -import zipfile, time -from java.io import File - - -def addZipEntry(zip, name, templateName): - template = open('test307%s.template' % templateName) - entry = zipfile.ZipInfo() - entry.filename = name - entry.date_time = time.gmtime(time.time()) - zip.writestr(entry, template.read()) - template.close() - -zip = zipfile.ZipFile("test307.zip", "w") - -addZipEntry(zip, 'test307m.py', 'm') -addZipEntry(zip, 'test307p/__init__.py', 'p') -addZipEntry(zip, "foo/bar/foobar.py", "foobar") - -zip.close() - -import sys -sys.path.append("test307.zip") - -import test307m -assert test307m.__name__ == "test307m" -assert "test307.zip" in test307m.__file__ -import test307p - -sys.path.pop() -del test307p, test307m -del sys.modules['test307p'], sys.modules['test307m'] - -import java -java.lang.System.gc() -time.sleep(4) - - Deleted: trunk/jython/bugtests/test307foobar.template =================================================================== --- trunk/jython/bugtests/test307foobar.template 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test307foobar.template 2009-01-05 03:56:25 UTC (rev 5845) @@ -1 +0,0 @@ -assert __name__ == 'test307p.foobar', "__name__ should've been test307p.foobar but was %s" % __name__ Deleted: trunk/jython/bugtests/test307m.template =================================================================== --- trunk/jython/bugtests/test307m.template 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test307m.template 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,4 +0,0 @@ -assert __name__ == 'test307m', " __name__ should've been test307m but was %s" % __name__ -from java.io import File -expected = "test307.zip%stest307m.py" % File.separator -assert expected in __file__, "%s should've been in __file__ but was %s" % (expected, __file__) Deleted: trunk/jython/bugtests/test307p.template =================================================================== --- trunk/jython/bugtests/test307p.template 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test307p.template 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,7 +0,0 @@ -assert __name__ == 'test307p', " __name__ should've been test307p but was %s" % __name__ - -#compare("__file__", __file__, "test307p/__init__.py") -#compare("__path__", __path__, ["test307.zip/test307p"]) -#import test307m -__path__.append("test307.zip/foo/bar") -import foobar Deleted: trunk/jython/bugtests/test308.py =================================================================== --- trunk/jython/bugtests/test308.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test308.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,32 +0,0 @@ -""" -Test import of java class from sys.path zipfile. -""" - -import support -import zipfile, time - -support.compileJava("test308d/test308j.java") - -def addZipEntry(zip, name, data): - entry = zipfile.ZipInfo() - entry.filename = name - entry.date_time = time.gmtime(time.time()) - zip.writestr(entry, data) - - -zip = zipfile.ZipFile("test308.zip", "w", zipfile.ZIP_DEFLATED) - -addZipEntry(zip, "test308m.py", """ -import test308j -assert test308j().foo() == "bar" -""") - -zip.write("test308d/test308j.class", "test308j.class") - -zip.close() - -import sys -sys.path.append("test308.zip") - -import test308m - Deleted: trunk/jython/bugtests/test309.py =================================================================== --- trunk/jython/bugtests/test309.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test309.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,13 +0,0 @@ -""" -[ #444292 ] local var binding overrides local import -""" - -import support - -def foo(pickle): - assert pickle == 1 - import pickle - assert pickle != 1 - -foo(1) - Deleted: trunk/jython/bugtests/test310.py =================================================================== --- trunk/jython/bugtests/test310.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test310.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,10 +0,0 @@ -""" -[ #444292 ] local var binding overrides local import with jythonc -""" - -import support - -support.compileJPythonc("test310c.py", output="test310.err", - jar="test310.jar", core=1) -support.runJava("test310c", classpath="test310.jar") - Deleted: trunk/jython/bugtests/test310c.py =================================================================== --- trunk/jython/bugtests/test310c.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test310c.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,13 +0,0 @@ -""" -[ #444292 ] local var binding overrides local import -""" - -import support - -def foo(pickle): - assert pickle == 1 - import pickle - assert pickle != 1 - -foo(1) - Deleted: trunk/jython/bugtests/test311.py =================================================================== --- trunk/jython/bugtests/test311.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test311.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,22 +0,0 @@ -""" -Test DST for time.mktime -""" - -import support -import time - -def check(tup, facit): - #print tup, long(time.mktime(tup)), facit, (long(time.mktime(tup))-facit) - assert time.mktime(tup) == facit - -# These tests fail for CPython also. - -''' -check((1998, 6, 13, 0, 0, 0, 0, 0, 0), 897692400) -check((1998, 6, 13, 0, 0, 0, 0, 0, -1), 897688800) -check((1998, 6, 13, 0, 0, 0, 0, 0, 0), 897692400) -check((1998, 6, 13, 0, 0, 0, 0, 0, 1), 897688800) -check((1998, 1, 13, 0, 0, 0, 0, 0, -1), 884646000) -check((1998, 1, 13, 0, 0, 0, 0, 0, 0), 884646000) -check((1998, 1, 13, 0, 0, 0, 0, 0, 1), 884642400) -''' Deleted: trunk/jython/bugtests/test312.py =================================================================== --- trunk/jython/bugtests/test312.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test312.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,47 +0,0 @@ -""" -Simple test of xml. -""" - -import support -import sys, StringIO - -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - -#print sys.modules - -file = StringIO.StringIO("""<collection> - <comic title="Sandman" number='62'> - <writer>Neil Gaiman</writer> - <penciller pages='1-9,18-24'>Glyn Dillon</penciller> - <penciller pages="10-17">Charles Vess</penciller> - </comic> - <comic title="Shade, the Changing Man" number="7"> - <writer>Peter Milligan</writer> - <penciller>Chris Bachalo</penciller> - </comic> -</collection>""") - -class FindIssue(saxutils.DefaultHandler): - def __init__(self, title, number): - self.search_title, self.search_number = title, number - - def startElement(self,name,attrs): - global match - if name != 'comic' : return - - title = attrs.get('title', None) - number = attrs.get('number',None) - if title == self.search_title and number == self.search_number: - match += 1 - -parser = make_parser() -parser.setFeature(feature_namespaces,0) -dh = FindIssue('Sandman', '62') -parser.setContentHandler(dh) - -match = 0 -parser.parse(file) -assert match == 1 - Deleted: trunk/jython/bugtests/test313.py =================================================================== --- trunk/jython/bugtests/test313.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test313.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,10 +0,0 @@ -""" -Jythonc test of xml -""" - -import support - -support.compileJPythonc("test313c.py", output="test313.err", - jar="test313.jar", core=1) -support.runJava("test313c", classpath="test313.jar") - Deleted: trunk/jython/bugtests/test313c.py =================================================================== --- trunk/jython/bugtests/test313c.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test313c.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,46 +0,0 @@ - -import sys, StringIO - -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - -def dummy_jythonc(): - import xml.sax.drivers2.drv_xmlproc - import encodings.utf_16_be - import dumbdbm - -file = StringIO.StringIO("""<collection> - <comic title="Sandman" number='62'> - <writer>Neil Gaiman</writer> - <penciller pages='1-9,18-24'>Glyn Dillon</penciller> - <penciller pages="10-17">Charles Vess</penciller> - </comic> - <comic title="Shade, the Changing Man" number="7"> - <writer>Peter Milligan</writer> - <penciller>Chris Bachalo</penciller> - </comic> -</collection>""") - -class FindIssue(saxutils.DefaultHandler): - def __init__(self, title, number): - self.search_title, self.search_number = title, number - - def startElement(self,name,attrs): - global match - if name != 'comic' : return - - title = attrs.get('title', None) - number = attrs.get('number',None) - if title == self.search_title and number == self.search_number: - match += 1 - -parser = make_parser() -parser.setFeature(feature_namespaces,0) -dh = FindIssue('Sandman', '62') -parser.setContentHandler(dh) - -match = 0 -parser.parse(file) -assert match == 1 - Deleted: trunk/jython/bugtests/test314.py =================================================================== --- trunk/jython/bugtests/test314.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test314.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,19 +0,0 @@ -""" -[ #448485 ] Tuple unpacking raises KeyError -""" - -import support - -import string -s = "elem1 elem2" -try: - (a, b, c) = string.split(s) -except ValueError: - pass -else: - print support.TestError("Should raise a ValueError") - -support.compileJPythonc("test314c.py", output="test314.err", - jar="test314.jar", core=1) -support.runJava("test314c", classpath="test314.jar") - Deleted: trunk/jython/bugtests/test314c.py =================================================================== --- trunk/jython/bugtests/test314c.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test314c.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,13 +0,0 @@ - -import string -s = "elem1 elem2" -try: - (a, b, c) = string.split(s) - (d, e, f) = string.split(s) - pass -except ValueError: - pass -else: - print support.TestError("Should raise a ValueError") - - Deleted: trunk/jython/bugtests/test315.py =================================================================== --- trunk/jython/bugtests/test315.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test315.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,11 +0,0 @@ -""" -Basic test, just raises an TestError -""" - -import support -support.compileJPythonc("test315c.py", output="test315.err", - jar="test315.jar", core=1) -support.runJava("test315c", classpath="test315.jar") - - - Deleted: trunk/jython/bugtests/test315c.py =================================================================== --- trunk/jython/bugtests/test315c.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test315c.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,2 +0,0 @@ - -"abc".encode("ASCII") Deleted: trunk/jython/bugtests/test316.py =================================================================== --- trunk/jython/bugtests/test316.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test316.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,14 +0,0 @@ -""" -[ #449316 ] ArrayList()[0] should raise IndexError -""" - -import support - -from java.util import ArrayList -al = ArrayList() -try: - foo = al[0] -except KeyError: - pass -else: - raise support.TestError("Should raise a KeyError") Deleted: trunk/jython/bugtests/test317.py =================================================================== --- trunk/jython/bugtests/test317.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test317.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,11 +0,0 @@ -""" -[ #448485 ] Tuple unpacking raises KeyError -""" - -import support -support.compileJPythonc("test317c.py", output="test317.err", - jar="test317.jar", core=1) -support.runJava("test317c", classpath="test317.jar") - - - Deleted: trunk/jython/bugtests/test317c.py =================================================================== --- trunk/jython/bugtests/test317c.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test317c.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,7 +0,0 @@ - -import string -try: - (a, b, c) = string.split("elem1 elem2") -except ValueError: - pass - Deleted: trunk/jython/bugtests/test318.py =================================================================== --- trunk/jython/bugtests/test318.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test318.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,14 +0,0 @@ -""" -Test against AIOOB exceptions. -""" - -import support - -def go2( a, b ): - pass - -try: - go2( 1, 2, 3 ) -except TypeError: - pass - Deleted: trunk/jython/bugtests/test319.py =================================================================== --- trunk/jython/bugtests/test319.py 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test319.py 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,18 +0,0 @@ -""" -Test class identity for inner classes -[ #452947 ] Class of innerclass inst <> innerclas -""" - -import support - -support.compileJava('test319j.java') - -import test319j - -id1 = id(test319j.inner) -id2 = id(test319j.mkinner().__class__) - -if id1 != id2: - print "innerclass different", test319j.inner, test319j.mkinner().__class__ - raise support.TestWarning("innerclass different %s %s" % ( - test319j.inner, test319j.mkinner().__class__)) Deleted: trunk/jython/bugtests/test319j.java =================================================================== --- trunk/jython/bugtests/test319j.java 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/bugtests/test319j.java 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,9 +0,0 @@ - -public class test319j { - public static class inner { } - - public static inner mkinner() { - return new inner(); - } -} - Modified: trunk/jython/src/org/python/core/APIReader.java =================================================================== --- trunk/jython/src/org/python/core/APIReader.java 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/src/org/python/core/APIReader.java 2009-01-05 03:56:25 UTC (rev 5845) @@ -4,22 +4,19 @@ */ package org.python.core; +import java.io.IOException; + import org.python.objectweb.asm.AnnotationVisitor; import org.python.objectweb.asm.ClassReader; import org.python.objectweb.asm.commons.EmptyVisitor; -import java.io.InputStream; -import java.io.IOException; - /** - * This class reads a classfile from a byte array and pulls out the value of - * the class annotation for APIVersion, which can then be retrieved by a call - * to getVersion(). + * This class reads a classfile from a byte array and pulls out the value of the class annotation + * for APIVersion, which can then be retrieved by a call to getVersion(). * - * Hopefully the use of ClassReader in this implementation is not too - * expensive. I suspect it is not since EmptyVisitor is just a bag of empty - * methods so shouldn't cost too much. If it turns out to cost too much, we - * will want to implement a special purpose ClassReader that only reads out the + * Hopefully the use of ClassReader in this implementation is not too expensive. I suspect it is not + * since EmptyVisitor is just a bag of empty methods so shouldn't cost too much. If it turns out to + * cost too much, we will want to implement a special purpose ClassReader that only reads out the * APIVersion annotation I think. */ public class APIReader extends EmptyVisitor { @@ -28,17 +25,29 @@ private int version = -1; + /** + * Reads the classfile bytecode in data and to extract the version. + * @throws IOException - if the classfile is malformed. + */ public APIReader(byte[] data) throws IOException { - ClassReader r = new ClassReader(data); - r.accept(this, 0); + ClassReader r; + try { + r = new ClassReader(data); + } catch (ArrayIndexOutOfBoundsException e) { + IOException ioe = new IOException("Malformed bytecode: not enough data"); + ioe.initCause(e);// IOException didn't grow a constructor that could take a cause till + // 1.6, so do it the old fashioned way + throw ioe; + } + r.accept(this, 0); } - public AnnotationVisitor visitAnnotation(String desc, boolean visible) { + public AnnotationVisitor visitAnnotation(String desc, boolean visible) { nextVisitIsVersion = desc.equals("Lorg/python/compiler/APIVersion;"); return this; } - public void visit(String name, Object value) { + public void visit(String name, Object value) { if (nextVisitIsVersion) { version = (Integer)value; nextVisitIsVersion = false; Modified: trunk/jython/src/org/python/core/imp.java =================================================================== --- trunk/jython/src/org/python/core/imp.java 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/src/org/python/core/imp.java 2009-01-05 03:56:25 UTC (rev 5845) @@ -87,7 +87,15 @@ static PyObject createFromPyClass(String name, InputStream fp, boolean testing, String sourceName, String compiledName) { - byte[] data = readCode(name, fp, testing); + byte[] data = null; + try { + data = readCode(name, fp, testing); + } catch (IOException ioe) { + if (!testing) { + throw Py.ImportError(ioe.getMessage() + "[name=" + name + ", source=" + sourceName + + ", compiled=" + compiledName + "]"); + } + } if (testing && data == null) { return null; } @@ -108,15 +116,11 @@ return createFromCode(name, code, compiledName); } - public static byte[] readCode(String name, InputStream fp, boolean testing) { + public static byte[] readCode(String name, InputStream fp, boolean testing) throws IOException { byte[] data = readBytes(fp); int api; - try { - APIReader ar = new APIReader(data); - api = ar.getVersion(); - } catch (IOException i) { - api = -1; - } + APIReader ar = new APIReader(data); + api = ar.getVersion(); if (api != APIVersion) { if (testing) { return null; Modified: trunk/jython/src/org/python/core/util/importer.java =================================================================== --- trunk/jython/src/org/python/core/util/importer.java 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/src/org/python/core/util/importer.java 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,5 +1,6 @@ package org.python.core.util; +import java.io.IOException; import java.io.InputStream; import java.util.EnumSet; import org.python.core.BytecodeLoader; @@ -182,7 +183,11 @@ Bundle bundle = makeBundle(searchPath, tocEntry); byte[] codeBytes; if (isbytecode) { - codeBytes = imp.readCode(fullname, bundle.inputStream, true); + try { + codeBytes = imp.readCode(fullname, bundle.inputStream, true); + } catch (IOException ioe) { + throw Py.ImportError(ioe.getMessage() + "[path=" + fullPath + searchPath + "]"); + } } else { codeBytes = imp.compileSource(fullname, bundle.inputStream, fullSearchPath); } Modified: trunk/jython/tests/java/org/python/tests/BeanInterface.java =================================================================== --- trunk/jython/tests/java/org/python/tests/BeanInterface.java 2009-01-04 23:20:34 UTC (rev 5844) +++ trunk/jython/tests/java/org/python/tests/BeanInterface.java 2009-01-05 03:56:25 UTC (rev 5845) @@ -1,6 +1,6 @@ package org.python.tests; -public interface BeanInterface { +public interface BeanInterface extends Cloneable { String getName(); } Added: trunk/jython/tests/java/org/python/tests/Matryoshka.java =================================================================== --- trunk/jython/tests/java/org/python/tests/Matryoshka.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/Matryoshka.java 2009-01-05 03:56:25 UTC (rev 5845) @@ -0,0 +1,16 @@ +package org.python.tests; + +public class Matryoshka { + + public static Outermost makeOutermost() { + return new Outermost(); + } + + public static class Outermost { + + public static class Middle { + + public static class Innermost {} + } + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-04 23:20:38
|
Revision: 5844 http://jython.svn.sourceforge.net/jython/?rev=5844&view=rev Author: cgroves Date: 2009-01-04 23:20:34 +0000 (Sun, 04 Jan 2009) Log Message: ----------- One more longstanding skip Modified Paths: -------------- trunk/jython/Lib/test/regrtest.py Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2009-01-04 23:06:27 UTC (rev 5843) +++ trunk/jython/Lib/test/regrtest.py 2009-01-04 23:20:34 UTC (rev 5844) @@ -1450,6 +1450,7 @@ test_winreg test_winsound test_xml_etree_c + test_zipfile64 """ } _expectations['freebsd5'] = _expectations['freebsd4'] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-04 23:06:30
|
Revision: 5843 http://jython.svn.sourceforge.net/jython/?rev=5843&view=rev Author: cgroves Date: 2009-01-04 23:06:27 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Add tests that have been failing or skipping for the past few months to the expected lists Modified Paths: -------------- trunk/jython/Lib/test/regrtest.py Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2009-01-04 22:15:09 UTC (rev 5842) +++ trunk/jython/Lib/test/regrtest.py 2009-01-04 23:06:27 UTC (rev 5843) @@ -1380,6 +1380,7 @@ 'java': """ test__locale + test__rawffi test_aepack test_al test_applesingle @@ -1475,11 +1476,16 @@ test_gc test_iterlen test_marshal + test_multibytecodec + test_multibytecodec_support test_peepholer test_profile test_pyclbr + test_stringprep test_transformer test_ucn + test_unicode + test_unicodedata test_xml_etree test_zipimport """, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-04 22:15:14
|
Revision: 5842 http://jython.svn.sourceforge.net/jython/?rev=5842&view=rev Author: cgroves Date: 2009-01-04 22:15:09 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Split java subclassing tests out of test_java_integration into test_java_subclasses, move unduplicated bits of test_jsubclass into test_java_subclasses. Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/Lib/test/test_java_visibility.py trunk/jython/src/org/python/core/PyReflectedConstructor.java trunk/jython/tests/java/org/python/tests/Coercions.java Added Paths: ----------- trunk/jython/Lib/test/test_java_subclasses.py Removed Paths: ------------- trunk/jython/Lib/test/test_jsubclass.py trunk/jython/bugtests/classes/test288i.java trunk/jython/bugtests/classes/test288j.java trunk/jython/bugtests/test290.py trunk/jython/bugtests/test291.py trunk/jython/tests/java/javatests/MethodInvokationTest.java Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/Lib/test/test_java_integration.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -5,127 +5,32 @@ from test import test_support -from java.lang import (Boolean, Class, ClassLoader, ExceptionInInitializerError, Integer, Object, - String, Runnable, Thread, ThreadGroup, System, Runtime, Math, Byte) +from java.lang import (ExceptionInInitializerError, String, Runnable, System, Runtime, Math, Byte) from java.math import BigDecimal from java.io import (FileInputStream, FileNotFoundException, FileOutputStream, FileWriter, OutputStreamWriter, UnsupportedEncodingException) from java.util import ArrayList, Date, HashMap, Hashtable, StringTokenizer, Vector -from java.awt import Dimension, Color, Component, Container, Rectangle +from java.awt import Dimension, Color, Component, Container from java.awt.event import ComponentEvent -from javax.swing.table import AbstractTableModel from javax.swing.tree import TreePath from org.python.core.util import FileUtil -from org.python.tests import BeanImplementation, Callbacker, Listenable -from javatests import MethodInvokationTest -""" -public abstract class Abstract { - public Abstract() { - method(); - } +from org.python.tests import BeanImplementation, Listenable - public abstract void method(); -} -""" -# The following is the correspoding bytecode for Abstract compiled with javac 1.5 -ABSTRACT_CLASS = """\ -eJw1TrsKwkAQnI1nEmMe/oKdSaHYiyCClWih2F+SQyOaQDz9LxsFCz/AjxL3Am6xw8zs7O7n+3oD -GKPnQcD30ELgIHQQEexJURZ6SmgN4h1BzKtcEaJlUarV9ZyqeivTEyv2WelDlRO8TXWtM7UojBrM -0ouuZaaHR3mTPtqwfXRgE9y/Q+gZb3SS5X60To8q06LPHwiYskAmxN1hFjMSYyd5gpIHrDsT3sU9 -5IgZF4wuhCBzpnG9Ru/+AF4RJn8= -""".decode('base64').decode('zlib') - -class AbstractOnSyspathTest(unittest.TestCase): - '''Subclasses an abstract class that isn't on the startup classpath. - - Checks for http://jython.org/bugs/1861985 - ''' - def setUp(self): - out = open('Abstract.class', 'w') - out.write(ABSTRACT_CLASS) - out.close() - self.orig_syspath = sys.path[:] - sys.path.append('') - - def tearDown(self): - os.unlink('Abstract.class') - sys.path = self.orig_syspath - - def test_can_subclass_abstract(self): - import Abstract - - class A(Abstract): - def method(self): - pass - A() - -""" -public abstract class ContextAbstract { - public ContextAbstract() { - method(); - } - - public abstract void method(); -} -""" -# The following is the correspoding bytecode for ContextAbstract compiled with javac 1.5 -# Needs to be named differently than Abstract above so the class loader won't just use it -CONTEXT_ABSTRACT = '''\ -eJxdjr1uwjAUhc8lbgIh/AVegA0YQJ1BlRBSp6gdWrE7wQKjEEvBVH0tFip14AF4KMQ17YSHc3yu -vuPry/X3DOAZ3RACrRAe2gE6AWKCP9OFti8EbzBcEsTCrBShlehCvR12qSo/ZZrzJE5MJvOlLLXL -/0NhN3pP6CQLU1j1befp3pYys1N+d6fsxqwI4Yc5lJl61a7QewDHW/klIzzBjxDB58UPAKHtkEku -i/XkPd2qzIo+/1/AnQrIdVkDTlN2Yq+NfkCjEyrHO1JlbXLF3QV7lbXGKfqDEaIOCHL7ORMad7J5 -A7yvPDQ= -'''.decode('base64').decode('zlib') -class ContextClassloaderTest(unittest.TestCase): - '''Classes on the context classloader should be importable and subclassable. - - http://bugs.jython.org/issue1216''' - def setUp(self): - self.orig_context = Thread.currentThread().contextClassLoader - class AbstractLoader(ClassLoader): - def __init__(self): - ClassLoader.__init__(self) - c = self.super__defineClass("ContextAbstract", CONTEXT_ABSTRACT, 0, - len(CONTEXT_ABSTRACT), ClassLoader.protectionDomain) - self.super__resolveClass(c) - Thread.currentThread().contextClassLoader = AbstractLoader() - - def tearDown(self): - Thread.currentThread().contextClassLoader = self.orig_context - - def test_can_subclass_abstract(self): - import ContextAbstract - - called = [] - class A(ContextAbstract): - def method(self): - called.append(True) - A() - self.assertEquals(len(called), 1) - -# The no-arg constructor for proxies attempts to look up its Python class by the Python class' name, -# so the class needs to be visible at the module level or the import will fail -class ModuleVisibleJavaSubclass(Object): - pass class InstantiationTest(unittest.TestCase): - def test_can_subclass_abstract(self): - class A(Component): - pass - A() - def test_cant_instantiate_abstract(self): self.assertRaises(TypeError, Component) + def test_no_public_constructors(self): + self.assertRaises(TypeError, Math) + + def test_invalid_self_to_java_constructor(self): + self.assertRaises(TypeError, Color.__init__, 10, 10, 10) + def test_str_doesnt_coerce_to_int(self): self.assertRaises(TypeError, Date, '99-01-01', 1, 1) - def test_Class_newInstance_works_on_proxies(self): - Class.newInstance(ModuleVisibleJavaSubclass) - - class BeanTest(unittest.TestCase): def test_shared_names(self): self.failUnless(callable(Vector.size), @@ -151,51 +56,7 @@ self.assertEquals("name", b.getName()) self.assertEquals("name", b.name) -class ExtendJavaTest(unittest.TestCase): - def test_override_tostring(self): - class A(Object): - def toString(self): - return 'name' - self.assertEquals('name', String.valueOf(A())) - def test_multiple_inheritance_prohibited(self): - try: - class MultiJava(Dimension, Color): - pass - self.fail("Shouldn't be able to subclass more than one concrete java class") - except TypeError: - pass - - def test_multilevel_override(self): - class SubDate(Date): - def toString(self): - s = Date.toString(self) - return 'SubDate -> Date' - - class SubSubDate(SubDate): - def toString(self): - return 'SubSubDate -> ' + SubDate.toString(self) - self.assertEquals("SubDate -> Date", SubDate().toString()) - self.assertEquals("SubSubDate -> SubDate -> Date", SubSubDate().toString()) - - def test_passthrough(self): - class CallbackPassthrough(Callbacker.Callback): - def __init__(self, worker): - self.worker = worker - - def __getattribute__(self, name): - if name == 'call': - return getattr(self.worker, name) - return object.__getattribute__(self, name) - - collector = Callbacker.CollectingCallback() - c = CallbackPassthrough(collector) - Callbacker.callNoArg(c) - self.assertEquals("call()", collector.calls[0]) - c.call(7) - self.assertEquals("call(7)", collector.calls[1]) - - class SysIntegrationTest(unittest.TestCase): def setUp(self): self.orig_stdout = sys.stdout @@ -212,32 +73,6 @@ self.assertEquals('hello', f.read()) f.close() -class AutoSuperTest(unittest.TestCase): - def test_auto_super(self): - class R(Rectangle): - def __init__(self): - self.size = Dimension(6, 7) - self.assert_("width=6,height=7" in R().toString()) - - def test_no_default_constructor(self): - "Check autocreation when java superclass misses a default constructor." - class A(ThreadGroup): - def __init__(self): - print self.name - self.assertRaises(TypeError, A) - - def test_no_public_constructors(self): - self.assertRaises(TypeError, Math) - -class PyObjectCmpTest(unittest.TestCase): - def test_vect_cmp(self): - "Check comparing a PyJavaClass with a Object." - class X(Runnable): - pass - v = Vector() - v.addElement(1) - v.indexOf(X()) - class IOTest(unittest.TestCase): def test_io_errors(self): "Check that IOException isn't mangled into an IOError" @@ -252,20 +87,6 @@ self.assertRaises(IOError, fp.tell) -class VectorTest(unittest.TestCase): - def test_looping(self): - for i in Vector(): pass - - def test_return_proxy(self): - "Jython proxies properly return back from Java code" - class FooVector(Vector): - bar = 99 - - ht = Hashtable() - fv = FooVector() - ht.put("a", fv) - self.failUnless(fv is ht.get("a")) - class JavaReservedNamesTest(unittest.TestCase): "Access to reserved words" @@ -419,7 +240,6 @@ self.assertRaises(ExceptionInInitializerError, __import__, "org.python.tests.BadStaticInitializer") class ColorTest(unittest.TestCase): - def test_assigning_over_method(self): self.assertRaises(TypeError, setattr, Color.RED, "getRGB", 4) @@ -436,39 +256,11 @@ self.assert_(red is Color.red) class TreePathTest(unittest.TestCase): - def test_overloading(self): treePath = TreePath([1,2,3]) self.assertEquals(len(treePath.path), 3, "Object[] not passed correctly") self.assertEquals(TreePath(treePath.path).path, treePath.path, "Object[] not passed and returned correctly") -class TableModelTest(unittest.TestCase): - def test_column_classes(self): - class TableModel(AbstractTableModel): - columnNames = "First Name", "Last Name","Sport","# of Years","Vegetarian" - data = [("Mary", "Campione", "Snowboarding", 5, False)] - - def getColumnCount(self): - return len(self.columnNames) - - def getRowCount(self): - return len(self.data) - - def getColumnName(self, col): - return self.columnNames[col] - - def getValueAt(self, row, col): - return self.data[row][col] - - def getColumnClass(self, c): - return Object.getClass(self.getValueAt(0, c)) - - def isCellEditable(self, row, col): - return col >= 2 - model = TableModel() - for i, expectedClass in enumerate([String, String, String, Integer, Boolean]): - self.assertEquals(expectedClass, model.getColumnClass(i)) - class BigDecimalTest(unittest.TestCase): def test_coerced_bigdecimal(self): from javatests import BigDecimalTest @@ -478,41 +270,7 @@ self.assertEqual(type(x), type(y), "BigDecimal coerced") self.assertEqual(x, y, "coerced BigDecimal not equal to directly created version") -class MethodInvTest(unittest.TestCase): - - def test_method_invokation(self): - bar = MethodInvokationTest.foo1(Byte(10)) - - self.assertEquals(bar, "foo1 with byte arg: 10", "Wrong method called") - -class InterfaceTest(unittest.TestCase): - - def test_override(self): - class Foo(Runnable): - def run(self): pass - def toString(self): return "Foo!!!" - - foo = Foo() - s = String.valueOf(foo) - - self.assertEquals(s, "Foo!!!", "toString not overridden in interface") - - def test_java_calling_python_interface_implementation(self): - called = [] - class PyCallback(Callbacker.Callback): - def call(self, extraarg=None): - called.append(extraarg) - Callbacker.callNoArg(PyCallback()) - Callbacker.callOneArg(PyCallback(), 4294967295L) - self.assertEquals(None, called[0]) - self.assertEquals(4294967295L, called[1]) - class PyBadCallback(Callbacker.Callback): - def call(pyself, extraarg): - self.fail("Shouldn't be callable with a no args") - self.assertRaises(TypeError, Callbacker.callNoArg, PyBadCallback()) - class JavaStringTest(unittest.TestCase): - def test_string_not_iterable(self): x = String('test') self.assertRaises(TypeError, list, x) @@ -551,27 +309,26 @@ tokenizer = StringTokenizer('foo bar') self.assertEquals(list(iter(tokenizer)), ['foo', 'bar']) + def test_vector_delegation(self): + class X(Runnable): + pass + v = Vector() + v.addElement(1) + v.indexOf(X())# Compares the Java object in the vector to a Python subclass + for i in v: + pass def test_main(): - test_support.run_unittest(AbstractOnSyspathTest, - ContextClassloaderTest, - InstantiationTest, + test_support.run_unittest(InstantiationTest, BeanTest, - ExtendJavaTest, SysIntegrationTest, - AutoSuperTest, - PyObjectCmpTest, IOTest, - VectorTest, JavaReservedNamesTest, PyReservedNamesTest, ImportTest, ColorTest, - TableModelTest, TreePathTest, BigDecimalTest, - MethodInvTest, - InterfaceTest, JavaStringTest, JavaDelegationTest, ) Added: trunk/jython/Lib/test/test_java_subclasses.py =================================================================== --- trunk/jython/Lib/test/test_java_subclasses.py (rev 0) +++ trunk/jython/Lib/test/test_java_subclasses.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -0,0 +1,243 @@ +'''Tests subclassing Java classes in Python''' +import os +import sys +import unittest + +from test import test_support + +from java.lang import (Boolean, Class, ClassLoader, Integer, Object, Runnable, String, Thread, + ThreadGroup) +from java.util import Date, Hashtable, Vector + +from java.awt import Color, Component, Dimension, Rectangle +from javax.swing.table import AbstractTableModel + +from org.python.tests import Callbacker + +class InterfaceTest(unittest.TestCase): + def test_java_calling_python_interface_implementation(self): + called = [] + class PyCallback(Callbacker.Callback): + def call(self, extraarg=None): + called.append(extraarg) + Callbacker.callNoArg(PyCallback()) + Callbacker.callOneArg(PyCallback(), 4294967295L) + self.assertEquals(None, called[0]) + self.assertEquals(4294967295L, called[1]) + class PyBadCallback(Callbacker.Callback): + def call(pyself, extraarg): + self.fail("Shouldn't be callable with a no args") + self.assertRaises(TypeError, Callbacker.callNoArg, PyBadCallback()) + +class TableModelTest(unittest.TestCase): + def test_class_coercion(self): + '''Python type instances coerce to a corresponding Java wrapper type in Object.getClass''' + class TableModel(AbstractTableModel): + columnNames = "First Name", "Last Name","Sport","# of Years","Vegetarian" + data = [("Mary", "Campione", "Snowboarding", 5, False)] + + def getColumnCount(self): + return len(self.columnNames) + + def getRowCount(self): + return len(self.data) + + def getColumnName(self, col): + return self.columnNames[col] + + def getValueAt(self, row, col): + return self.data[row][col] + + def getColumnClass(self, c): + return Object.getClass(self.getValueAt(0, c)) + + def isCellEditable(self, row, col): + return col >= 2 + + model = TableModel() + for i, expectedClass in enumerate([String, String, String, Integer, Boolean]): + self.assertEquals(expectedClass, model.getColumnClass(i)) + +class AutoSuperTest(unittest.TestCase): + def test_auto_super(self): + class Implicit(Rectangle): + def __init__(self): + self.size = Dimension(6, 7) + class Explicit(Rectangle): + def __init__(self): + Rectangle.__init__(self, 6, 7) + self.assert_("width=6,height=7" in Implicit().toString()) + self.assert_("width=6,height=7" in Explicit().toString()) + + def test_no_default_constructor(self): + "Check autocreation when java superclass misses a default constructor." + class A(ThreadGroup): + def __init__(self): + print self.name + self.assertRaises(TypeError, A) + +# The no-arg constructor for proxies attempts to look up its Python class by the Python class' name, +# so the class needs to be visible at the module level or the import will fail +class ModuleVisibleJavaSubclass(Object): + pass +class PythonSubclassesTest(unittest.TestCase): + def test_multiple_inheritance_prohibited(self): + try: + class MultiJava(Dimension, Color): + pass + self.fail("Shouldn't be able to subclass more than one concrete java class") + except TypeError: + pass + + def test_multilevel_override(self): + class SubDate(Date): + def toString(self): + s = Date.toString(self) + return 'SubDate -> Date' + + class SubSubDate(SubDate): + def toString(self): + return 'SubSubDate -> ' + SubDate.toString(self) + self.assertEquals("SubDate -> Date", SubDate().toString()) + self.assertEquals("SubSubDate -> SubDate -> Date", SubSubDate().toString()) + + def test_passthrough(self): + class CallbackPassthrough(Callbacker.Callback): + def __init__(self, worker): + self.worker = worker + + def __getattribute__(self, name): + if name == 'call': + return getattr(self.worker, name) + return object.__getattribute__(self, name) + + collector = Callbacker.CollectingCallback() + c = CallbackPassthrough(collector) + Callbacker.callNoArg(c) + self.assertEquals("call()", collector.calls[0]) + c.call(7) + self.assertEquals("call(7)", collector.calls[1]) + + def test_Class_newInstance_works_on_proxies(self): + Class.newInstance(ModuleVisibleJavaSubclass) + + def test_override(self): + class Foo(Runnable): + def toString(self): return "Foo" + self.assertEquals(String.valueOf(Foo()), "Foo", "toString not overridden in interface") + + class A(Object): + def toString(self): + return 'name' + self.assertEquals('name', String.valueOf(A()), 'toString not overriden in subclass') + + def test_can_subclass_abstract(self): + class A(Component): + pass + A() + + def test_return_proxy(self): + "Jython proxies properly return back from Java code" + class FooVector(Vector): + bar = 99 + + ht = Hashtable() + fv = FooVector() + ht.put("a", fv) + self.failUnless(fv is ht.get("a")) + + +""" +public abstract class Abstract { + public Abstract() { + method(); + } + + public abstract void method(); +} +""" +# The following is the correspoding bytecode for Abstract compiled with javac 1.5 +ABSTRACT_CLASS = """\ +eJw1TrsKwkAQnI1nEmMe/oKdSaHYiyCClWih2F+SQyOaQDz9LxsFCz/AjxL3Am6xw8zs7O7n+3oD +GKPnQcD30ELgIHQQEexJURZ6SmgN4h1BzKtcEaJlUarV9ZyqeivTEyv2WelDlRO8TXWtM7UojBrM +0ouuZaaHR3mTPtqwfXRgE9y/Q+gZb3SS5X60To8q06LPHwiYskAmxN1hFjMSYyd5gpIHrDsT3sU9 +5IgZF4wuhCBzpnG9Ru/+AF4RJn8= +""".decode('base64').decode('zlib') + +class AbstractOnSyspathTest(unittest.TestCase): + '''Subclasses an abstract class that isn't on the startup classpath. + + Checks for http://jython.org/bugs/1861985 + ''' + def setUp(self): + out = open('Abstract.class', 'w') + out.write(ABSTRACT_CLASS) + out.close() + self.orig_syspath = sys.path[:] + sys.path.append('') + + def tearDown(self): + os.unlink('Abstract.class') + sys.path = self.orig_syspath + + def test_can_subclass_abstract(self): + import Abstract + + class A(Abstract): + def method(self): + pass + A() + +""" +public abstract class ContextAbstract { + public ContextAbstract() { + method(); + } + + public abstract void method(); +} +""" +# The following is the correspoding bytecode for ContextAbstract compiled with javac 1.5 +# Needs to be named differently than Abstract above so the class loader won't just use it +CONTEXT_ABSTRACT = '''\ +eJxdjr1uwjAUhc8lbgIh/AVegA0YQJ1BlRBSp6gdWrE7wQKjEEvBVH0tFip14AF4KMQ17YSHc3yu +vuPry/X3DOAZ3RACrRAe2gE6AWKCP9OFti8EbzBcEsTCrBShlehCvR12qSo/ZZrzJE5MJvOlLLXL +/0NhN3pP6CQLU1j1befp3pYys1N+d6fsxqwI4Yc5lJl61a7QewDHW/klIzzBjxDB58UPAKHtkEku +i/XkPd2qzIo+/1/AnQrIdVkDTlN2Yq+NfkCjEyrHO1JlbXLF3QV7lbXGKfqDEaIOCHL7ORMad7J5 +A7yvPDQ= +'''.decode('base64').decode('zlib') +class ContextClassloaderTest(unittest.TestCase): + '''Classes on the context classloader should be importable and subclassable. + + http://bugs.jython.org/issue1216''' + def setUp(self): + self.orig_context = Thread.currentThread().contextClassLoader + class AbstractLoader(ClassLoader): + def __init__(self): + ClassLoader.__init__(self) + c = self.super__defineClass("ContextAbstract", CONTEXT_ABSTRACT, 0, + len(CONTEXT_ABSTRACT), ClassLoader.protectionDomain) + self.super__resolveClass(c) + Thread.currentThread().contextClassLoader = AbstractLoader() + + def tearDown(self): + Thread.currentThread().contextClassLoader = self.orig_context + + def test_can_subclass_abstract(self): + import ContextAbstract + + called = [] + class A(ContextAbstract): + def method(self): + called.append(True) + A() + self.assertEquals(len(called), 1) + + +def test_main(): + test_support.run_unittest(InterfaceTest, + TableModelTest, + AutoSuperTest, + PythonSubclassesTest, + AbstractOnSyspathTest, + ContextClassloaderTest) Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/Lib/test/test_java_visibility.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -3,7 +3,7 @@ import subprocess import sys from test import test_support -from java.lang import Class +from java.lang import Byte, Class from java.util import HashMap, Observable, Observer from org.python.tests import (Coercions, HiddenSuper, InterfaceCombination, Invisible, OnlySubclassable, OtherSubVisible, SomePyMethods, SubVisible, Visible, VisibleOverride) @@ -157,6 +157,7 @@ self.assertEquals("5", c.takeInt(5)) self.assertEquals("15", c.takeInteger(15)) self.assertEquals("150", c.takeNumber(150)) + self.assertEquals("take with byte arg: 10", Coercions.take(Byte(10))) def test_array_coercion(self): self.assertEquals("double", Coercions.takeArray(array.zeros('d', 2))) Deleted: trunk/jython/Lib/test/test_jsubclass.py =================================================================== --- trunk/jython/Lib/test/test_jsubclass.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/Lib/test/test_jsubclass.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,49 +0,0 @@ -from test_support import * - -print 'Subclassing Java from Python (test_jsubclass.py)' - -from java.lang import Runnable, Thread - -# Overriding Methods - -print 'override methods' -class MyThread(Thread): - count = 0 - def run(self): - self.count = self.count+1 - - -t1 = MyThread() -t1.start() -t1.join() -assert t1.count == 1, 'subclassing java.lang.Thread' - -print 'pass subclass back to java' - -class MyRun(Runnable): - count = 0 - def run(self): - self.count = self.count+1 - -run = MyRun() -t = Thread(run) -t.start() -t.join() -assert run.count == 1, 'subclassing java.lang.Thread' - -print "invoke super's constructor" - -class MyThread(Thread): - def __init__(self): - self.name = "Python-"+self.name - -t = MyThread() -assert t.name[:14] == "Python-Thread-", 'automatic constructor call' - -class MyThread(Thread): - def __init__(self): - Thread.__init__(self, "Python-Thread") - -t = MyThread() -assert t.name == "Python-Thread", 'explicit constructor call' - Deleted: trunk/jython/bugtests/classes/test288i.java =================================================================== --- trunk/jython/bugtests/classes/test288i.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/bugtests/classes/test288i.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,4 +0,0 @@ -public interface test288i { - public int get(); - public int get(int i); -} Deleted: trunk/jython/bugtests/classes/test288j.java =================================================================== --- trunk/jython/bugtests/classes/test288j.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/bugtests/classes/test288j.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,14 +0,0 @@ - -public class test288j extends Object implements test288i { - protected int last; - public test288j() { - this.last = 0; - } - public int get() { - return this.last; - } - public int get(int i) { - this.last = i; - return i; - } -} Deleted: trunk/jython/bugtests/test290.py =================================================================== --- trunk/jython/bugtests/test290.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/bugtests/test290.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,11 +0,0 @@ -""" -test newline in text pickles #437215 -""" - -import pickle -s1="line1\nline2\nline3" -s2="line4\nline5\nline6" -l = [s1, s2] -p = pickle.dumps(l) # newlines won't be escaped -l2 = pickle.loads(p) # blows up - Deleted: trunk/jython/bugtests/test291.py =================================================================== --- trunk/jython/bugtests/test291.py 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/bugtests/test291.py 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,18 +0,0 @@ -""" -Test keywords to import builtin. -""" - -import support - -impl_names = ['java'] - -# Will only return anygui :P -try: - impls = [__import__('anygui.impl.%sgui' % name, - fromlist=['%sgui' % name]) for name in impl_names] -except TypeError, e: - support.compare(e, "__import__\(\) takes no keyword arguments"); -else: - support.TestError("Should raise a TypeError") - - Modified: trunk/jython/src/org/python/core/PyReflectedConstructor.java =================================================================== --- trunk/jython/src/org/python/core/PyReflectedConstructor.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/src/org/python/core/PyReflectedConstructor.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -82,6 +82,9 @@ throw Py.TypeError("invalid self argument to constructor"); } Class<?> javaClass = self.getType().getProxyType(); + if (javaClass == null) { + throw Py.TypeError("self invalid - must be a Java subclass [self=" + self + "]"); + } Class<?> declaringClass = argslist[0] == null ? null : argslist[0].declaringClass; // If the declaring class is a pure Java type but we're instantiating a Python proxy, // grab the proxy version of the constructor to instantiate the proper type Deleted: trunk/jython/tests/java/javatests/MethodInvokationTest.java =================================================================== --- trunk/jython/tests/java/javatests/MethodInvokationTest.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/tests/java/javatests/MethodInvokationTest.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -1,19 +0,0 @@ -package javatests; - -public class MethodInvokationTest{ - public static String foo1(int i) { - return "foo1 with int arg: " + i; - } - - public static String foo1(char c) { - return "foo1 with char arg: " + c; - } - - public static String foo1(boolean b) { - return "foo1 with boolean arg: " + b; - } - - public static String foo1(byte bt) { - return "foo1 with byte arg: " + bt; - } -} Modified: trunk/jython/tests/java/org/python/tests/Coercions.java =================================================================== --- trunk/jython/tests/java/org/python/tests/Coercions.java 2009-01-04 20:36:10 UTC (rev 5841) +++ trunk/jython/tests/java/org/python/tests/Coercions.java 2009-01-04 22:15:09 UTC (rev 5842) @@ -67,4 +67,20 @@ public String tellClassNameSerializable(Serializable o) { return o.getClass().toString(); } + + public static String take(int i) { + return "take with int arg: " + i; + } + + public static String take(char c) { + return "take with char arg: " + c; + } + + public static String take(boolean b) { + return "take with boolean arg: " + b; + } + + public static String take(byte bt) { + return "take with byte arg: " + bt; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-04 20:36:17
|
Revision: 5841 http://jython.svn.sourceforge.net/jython/?rev=5841&view=rev Author: fwierzbicki Date: 2009-01-04 20:36:10 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Initial Jython 3000 branch -- don't get too excited everybody, the NetBeans folks requested a Python 3000 grammar and I thought a branch would be the right place to put it. I don't think it is quite time to get serious about a 3.0 just yet. Added Paths: ----------- branches/jy3k/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-04 17:35:49
|
Revision: 5840 http://jython.svn.sourceforge.net/jython/?rev=5840&view=rev Author: fwierzbicki Date: 2009-01-04 17:35:44 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Handle cases where the entire tree ends up as an error. Only comes up with alternate ErrorHandlers. Modified Paths: -------------- trunk/jython/grammar/Python.g Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2009-01-04 08:41:16 UTC (rev 5839) +++ trunk/jython/grammar/Python.g 2009-01-04 17:35:44 UTC (rev 5840) @@ -103,6 +103,7 @@ import org.python.antlr.ast.Delete; import org.python.antlr.ast.Dict; import org.python.antlr.ast.Ellipsis; +import org.python.antlr.ast.ErrorMod; import org.python.antlr.ast.ExceptHandler; import org.python.antlr.ast.Exec; import org.python.antlr.ast.Expr; @@ -289,6 +290,13 @@ mtype = new Interactive($single_input.start, actions.castStmts($compound_stmt.tree)); } ; + //XXX: this block is duplicated in three places, how to extract? + catch [RecognitionException re] { + errorHandler.reportError(this, re); + errorHandler.recover(this, input,re); + PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + retval.tree = new ErrorMod(badNode); + } //file_input: (NEWLINE | stmt)* ENDMARKER file_input @@ -318,7 +326,15 @@ mtype = new Module($file_input.start, actions.castStmts(stypes)); } ; + //XXX: this block is duplicated in three places, how to extract? + catch [RecognitionException re] { + errorHandler.reportError(this, re); + errorHandler.recover(this, input,re); + PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + retval.tree = new ErrorMod(badNode); + } + //eval_input: testlist NEWLINE* ENDMARKER eval_input @init { @@ -331,7 +347,15 @@ mtype = new Expression($eval_input.start, actions.castExpr($testlist.tree)); } ; + //XXX: this block is duplicated in three places, how to extract? + catch [RecognitionException re] { + errorHandler.reportError(this, re); + errorHandler.recover(this, input,re); + PythonTree badNode = (PythonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re); + retval.tree = new ErrorMod(badNode); + } + //not in CPython's Grammar file dotted_attr returns [expr etype] : n1=NAME This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-04 08:41:20
|
Revision: 5839 http://jython.svn.sourceforge.net/jython/?rev=5839&view=rev Author: cgroves Date: 2009-01-04 08:41:16 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Fixing test288 involved making proxy class method lookup go through __findattr__ on PyObject instead of doing its specialized lookup through the object's dict and type. This means wrapped Java instance method lookup is going through PyObjectDerived's __findattr_ex__ which has a scary comment about its slowness. I'm a little worried this will hurt Java performance, but I'm still holding off on optimizing any of the newstyle java stuff. test278 - Moved to test_java_integration test280 - Tested by test_scope test281,286,289 - Testing jythonc; deleted test282 - Moved to test_class_jy test284 - Tested by test_java_visibility test285 - Moved to test_java_integration test287 - Already disabled, deleted test288 - Moved to test_java_integration test290 - Tested by test_pickle test291 - Tested by test_import_jy Modified Paths: -------------- trunk/jython/Lib/test/test_class_jy.py trunk/jython/Lib/test/test_java_integration.py trunk/jython/src/org/python/compiler/ProxyMaker.java trunk/jython/src/org/python/core/PyReflectedFunction.java trunk/jython/src/org/python/core/ReflectedArgs.java trunk/jython/tests/java/org/python/tests/Callbacker.java Added Paths: ----------- trunk/jython/tests/java/org/python/tests/BeanImplementation.java trunk/jython/tests/java/org/python/tests/BeanInterface.java Removed Paths: ------------- trunk/jython/bugtests/test278.py trunk/jython/bugtests/test278p/ trunk/jython/bugtests/test280.py trunk/jython/bugtests/test280c.py trunk/jython/bugtests/test281.py trunk/jython/bugtests/test281c.py trunk/jython/bugtests/test282.py trunk/jython/bugtests/test284.py trunk/jython/bugtests/test284j1.java trunk/jython/bugtests/test284j2.java trunk/jython/bugtests/test285.py trunk/jython/bugtests/test286.py trunk/jython/bugtests/test286c.py trunk/jython/bugtests/test287.py trunk/jython/bugtests/test288.py trunk/jython/bugtests/test289.py trunk/jython/bugtests/test289c.py Modified: trunk/jython/Lib/test/test_class_jy.py =================================================================== --- trunk/jython/Lib/test/test_class_jy.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/Lib/test/test_class_jy.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -177,6 +177,12 @@ # conflict class D(B, C): pass + + def test_getitem_exceptions(self): + class A: + def __getitem__(self, key): + raise IndexError, "Fraid not" + self.assertRaises(IndexError, A().__getitem__, 'b') class ClassNamelessModuleTestCase(unittest.TestCase): Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/Lib/test/test_java_integration.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -2,18 +2,24 @@ import unittest import sys import re + +from test import test_support -from test import test_support -from java.awt import Dimension, Color, Component, Rectangle -from java.util import ArrayList, HashMap, Hashtable, StringTokenizer, Vector -from java.io import FileOutputStream, FileWriter, OutputStreamWriter - -from java.lang import (Boolean, Class, ClassLoader, ExceptionInInitializerError, Integer, Object, String, - Runnable, Thread, ThreadGroup, System, Runtime, Math, Byte) +from java.lang import (Boolean, Class, ClassLoader, ExceptionInInitializerError, Integer, Object, + String, Runnable, Thread, ThreadGroup, System, Runtime, Math, Byte) +from java.math import BigDecimal +from java.io import (FileInputStream, FileNotFoundException, FileOutputStream, FileWriter, + OutputStreamWriter, UnsupportedEncodingException) +from java.util import ArrayList, Date, HashMap, Hashtable, StringTokenizer, Vector + +from java.awt import Dimension, Color, Component, Container, Rectangle +from java.awt.event import ComponentEvent from javax.swing.table import AbstractTableModel from javax.swing.tree import TreePath -from java.math import BigDecimal +from org.python.core.util import FileUtil +from org.python.tests import BeanImplementation, Callbacker, Listenable +from javatests import MethodInvokationTest """ public abstract class Abstract { public Abstract() { @@ -114,7 +120,6 @@ self.assertRaises(TypeError, Component) def test_str_doesnt_coerce_to_int(self): - from java.util import Date self.assertRaises(TypeError, Date, '99-01-01', 1, 1) def test_Class_newInstance_works_on_proxies(self): @@ -128,9 +133,6 @@ def test_multiple_listeners(self): '''Check that multiple BEP can be assigned to a single cast listener''' - from org.python.tests import Listenable - from java.awt.event import ComponentEvent - from java.awt import Container m = Listenable() called = [] def f(evt, called=called): @@ -143,6 +145,11 @@ self.assertEquals(1, len(called)) m.fireComponentHidden(ComponentEvent(Container(), 0)) self.assertEquals(2, len(called)) + + def test_bean_interface(self): + b = BeanImplementation() + self.assertEquals("name", b.getName()) + self.assertEquals("name", b.name) class ExtendJavaTest(unittest.TestCase): def test_override_tostring(self): @@ -159,6 +166,36 @@ except TypeError: pass + def test_multilevel_override(self): + class SubDate(Date): + def toString(self): + s = Date.toString(self) + return 'SubDate -> Date' + + class SubSubDate(SubDate): + def toString(self): + return 'SubSubDate -> ' + SubDate.toString(self) + self.assertEquals("SubDate -> Date", SubDate().toString()) + self.assertEquals("SubSubDate -> SubDate -> Date", SubSubDate().toString()) + + def test_passthrough(self): + class CallbackPassthrough(Callbacker.Callback): + def __init__(self, worker): + self.worker = worker + + def __getattribute__(self, name): + if name == 'call': + return getattr(self.worker, name) + return object.__getattribute__(self, name) + + collector = Callbacker.CollectingCallback() + c = CallbackPassthrough(collector) + Callbacker.callNoArg(c) + self.assertEquals("call()", collector.calls[0]) + c.call(7) + self.assertEquals("call(7)", collector.calls[1]) + + class SysIntegrationTest(unittest.TestCase): def setUp(self): self.orig_stdout = sys.stdout @@ -204,16 +241,13 @@ class IOTest(unittest.TestCase): def test_io_errors(self): "Check that IOException isn't mangled into an IOError" - from java.io import UnsupportedEncodingException self.assertRaises(UnsupportedEncodingException, OutputStreamWriter, System.out, "garbage") self.assertRaises(IOError, OutputStreamWriter, System.out, "garbage") def test_fileio_error(self): - from java.io import FileInputStream, FileNotFoundException self.assertRaises(FileNotFoundException, FileInputStream, "garbage") def test_unsupported_tell(self): - from org.python.core.util import FileUtil fp = FileUtil.wrap(System.out) self.assertRaises(IOError, fp.tell) @@ -436,10 +470,8 @@ self.assertEquals(expectedClass, model.getColumnClass(i)) class BigDecimalTest(unittest.TestCase): - def test_coerced_bigdecimal(self): from javatests import BigDecimalTest - x = BigDecimal("123.4321") y = BigDecimalTest().asBigDecimal() @@ -449,8 +481,6 @@ class MethodInvTest(unittest.TestCase): def test_method_invokation(self): - from javatests import MethodInvokationTest - bar = MethodInvokationTest.foo1(Byte(10)) self.assertEquals(bar, "foo1 with byte arg: 10", "Wrong method called") @@ -458,7 +488,6 @@ class InterfaceTest(unittest.TestCase): def test_override(self): - from java.lang import String class Foo(Runnable): def run(self): pass def toString(self): return "Foo!!!" @@ -469,7 +498,6 @@ self.assertEquals(s, "Foo!!!", "toString not overridden in interface") def test_java_calling_python_interface_implementation(self): - from org.python.tests import Callbacker called = [] class PyCallback(Callbacker.Callback): def call(self, extraarg=None): Deleted: trunk/jython/bugtests/test278.py =================================================================== --- trunk/jython/bugtests/test278.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test278.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,17 +0,0 @@ - - -""" - -""" - -import support - -support.compileJava("test278p/bug.java", classpath=".") - -from test278p import bug -b=bug() -assert b.getName() == "name" -assert b.name== "name" - - -#raise support.TestError("" + `x`) Deleted: trunk/jython/bugtests/test280.py =================================================================== --- trunk/jython/bugtests/test280.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test280.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,12 +0,0 @@ -""" - -""" - -import support - -try: - import test280c -except UnboundLocalError: - pass -else: - raise support.TestError("Should raise UnboundLocalError") Deleted: trunk/jython/bugtests/test280c.py =================================================================== --- trunk/jython/bugtests/test280c.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test280c.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,6 +0,0 @@ - -x = 1 -def f(): - print x - x = 2 -f() \ No newline at end of file Deleted: trunk/jython/bugtests/test281.py =================================================================== --- trunk/jython/bugtests/test281.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test281.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,10 +0,0 @@ -""" - -""" - -import support - -support.compileJPythonc("test281c.py", core=1, jar="test281c.jar", output="test281.err") -support.runJava("test281c", classpath="test281c.jar") - -#raise support.TestError("" + `x`) Deleted: trunk/jython/bugtests/test281c.py =================================================================== --- trunk/jython/bugtests/test281c.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test281c.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,16 +0,0 @@ -""" - -""" - -import support - - -if __name__ == "__main__": - try: - raise "me" - except: - pass - else: - raise support.TestError("Should not happen") - - Deleted: trunk/jython/bugtests/test282.py =================================================================== --- trunk/jython/bugtests/test282.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test282.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,16 +0,0 @@ -""" - -""" - -import support - -class A: - def __getitem__(self, key): - raise IndexError, "hello" - -try: - A()['b'] -except IndexError: - pass -else: - raise support.TestError("Should raise IndexError") Deleted: trunk/jython/bugtests/test284.py =================================================================== --- trunk/jython/bugtests/test284.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test284.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,12 +0,0 @@ - -import support - -support.compileJava("test284j2.java", classpath=".") - -import test284j1 - -assert test284j1().foo() == 'test284j1.foo' - -import test284j2 - -assert test284j2().foo() == 'test284j2.foo' Deleted: trunk/jython/bugtests/test284j1.java =================================================================== --- trunk/jython/bugtests/test284j1.java 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test284j1.java 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,6 +0,0 @@ - -public class test284j1 { - public String foo() { - return "test284j1.foo"; - } -} \ No newline at end of file Deleted: trunk/jython/bugtests/test284j2.java =================================================================== --- trunk/jython/bugtests/test284j2.java 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test284j2.java 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,6 +0,0 @@ - -public class test284j2 extends test284j1 { - public String foo() { - return "test284j2.foo"; - } -} \ No newline at end of file Deleted: trunk/jython/bugtests/test285.py =================================================================== --- trunk/jython/bugtests/test285.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test285.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,17 +0,0 @@ -""" -Test multilevel overriding of java methods. -""" - -from java.util import Date - -class SubDate(Date): - def toString(self): - s = Date.toString(self) - return 'SubDate -> Date' - -class SubSubDate(SubDate): - def toString(self): - return 'SubSubDate -> ' + SubDate.toString(self) - -assert SubDate().toString() == 'SubDate -> Date' -assert SubSubDate().toString() == 'SubSubDate -> SubDate -> Date' Deleted: trunk/jython/bugtests/test286.py =================================================================== --- trunk/jython/bugtests/test286.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test286.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,8 +0,0 @@ -""" - -""" - -import support - -support.compileJPythonc("test286c.py", output="test286.err") -support.runJava("test286c", classpath="jpywork") Deleted: trunk/jython/bugtests/test286c.py =================================================================== --- trunk/jython/bugtests/test286c.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test286c.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,17 +0,0 @@ -""" -Test multilevel overriding of java methods in jythonc. -""" - -from java.util import Date - -class SubDate(Date): - def toString(self): - s = Date.toString(self) - return 'SubDate -> Date' - -class SubSubDate(SubDate): - def toString(self): - return 'SubSubDate -> ' + SubDate.toString(self) - -assert SubDate().toString() == 'SubDate -> Date' -assert SubSubDate().toString() == 'SubSubDate -> SubDate -> Date' Deleted: trunk/jython/bugtests/test287.py =================================================================== --- trunk/jython/bugtests/test287.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test287.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,22 +0,0 @@ -""" - -""" - -import support - -raise support.TestWarning("mixing base classes between Jython and Java is not supported") - -import java.util -import org.python.core -class LX(org.python.core.PyList,java.util.List): - pass - -l = LX() - -try: - l.add('x') -except AttributeError: - pass -else: - raise support.TestError("expected an AttributeError") - Deleted: trunk/jython/bugtests/test288.py =================================================================== --- trunk/jython/bugtests/test288.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test288.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,46 +0,0 @@ -""" - -""" - -import support - -support.compileJava("classes/test288j.java") - -import test288j, test288i - - -class t: - def __init__(self, s): - self.s = s - - def __getattr__(self, name): - return getattr(self.s, name) - -class u(test288i): - def __init__(self, s): - self.s = s - - def get(self, i=None): - if i: - return self.s.get(i) - else: - return self.s.get() - -class v(test288i): - def __init__(self, s): - self.s = s - - def __getattr__(self, name): - return getattr(self.s, name) - -def main(): - y = v(test288j()) - y.get() - y.get(2) - y.get() - y.get(0) - -if __name__ == '__main__': - main() - -#raise support.TestError("" + `x`) Deleted: trunk/jython/bugtests/test289.py =================================================================== --- trunk/jython/bugtests/test289.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test289.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,10 +0,0 @@ -""" - -""" - -import support - -support.compileJava("classes/test288j.java") - -support.compileJPythonc("test289c.py", output="test289.err") -support.runJava("test289c", classpath="jpywork", pass_jython_home=1) Deleted: trunk/jython/bugtests/test289c.py =================================================================== --- trunk/jython/bugtests/test289c.py 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/bugtests/test289c.py 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,45 +0,0 @@ -""" - -""" - -import support - - -import test288j, test288i - - -class t: - def __init__(self, s): - self.s = s - - def __getattr__(self, name): - return getattr(self.s, name) - -class u(test288i): - def __init__(self, s): - self.s = s - - def get(self, i=None): - if i: - return self.s.get(i) - else: - return self.s.get() - -class v(test288i): - def __init__(self, s): - self.s = s - - def __getattr__(self, name): - return getattr(self.s, name) - -def main(): - y = v(test288j()) - y.get() - y.get(2) - y.get() - y.get(0) - -if __name__ == '__main__': - main() - -#raise support.TestError("" + `x`) Modified: trunk/jython/src/org/python/compiler/ProxyMaker.java =================================================================== --- trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/src/org/python/compiler/ProxyMaker.java 2009-01-04 08:41:16 UTC (rev 5839) @@ -12,9 +12,10 @@ import java.util.Set; import org.python.core.Py; -import org.python.core.PyJavaType; +import org.python.core.PyMethod; import org.python.core.PyObject; import org.python.core.PyProxy; +import org.python.core.PyReflectedFunction; import org.python.objectweb.asm.Label; import org.python.objectweb.asm.Opcodes; import org.python.util.Generic; @@ -66,22 +67,21 @@ proxy.__initProxy__(new Object[0]); o = proxy._getPyInstance(); } - PyObject ret = null; - if (o.getDict() != null) { - ret = o.getDict().__finditem__(name); - } - if (ret == null) { - PyObject[] definedOn = new PyObject[1]; - PyObject typeDefined = o.getType().lookup_where(name, definedOn); - if (!(definedOn[0] instanceof PyJavaType)) { - ret = typeDefined; + PyObject ret = o.__findattr__(name); + if (ret instanceof PyMethod) { + PyMethod meth = ((PyMethod)ret); + if (meth.im_func instanceof PyReflectedFunction) { + PyReflectedFunction func = (PyReflectedFunction)meth.im_func; + if (func.nargs > 0 && proxy.getClass() == func.argslist[0].declaringClass) { + // This function is the default return for the proxy type if the Python instance + // hasn't returned something of its own from __findattr__, so do the standard + // Java call on this + return null; + } } } - if (ret == null) { - return null; - } Py.setSystemState(proxy._getPySystemState()); - return ret.__get__(o, null); + return ret; } Class<?> superclass; Modified: trunk/jython/src/org/python/core/PyReflectedFunction.java =================================================================== --- trunk/jython/src/org/python/core/PyReflectedFunction.java 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/src/org/python/core/PyReflectedFunction.java 2009-01-04 08:41:16 UTC (rev 5839) @@ -145,22 +145,31 @@ public PyObject __call__(PyObject self, PyObject[] args, String[] keywords) { ReflectedCallData callData = new ReflectedCallData(); - Object method = null; - ReflectedArgs[] argsl = argslist; - int n = nargs; - for (int i = 0; i < n; i++) { - ReflectedArgs rargs = argsl[i]; + ReflectedArgs match = null; + for (int i = 0; i < nargs && match == null; i++) { // System.err.println(rargs.toString()); - if (rargs.matches(self, args, keywords, callData)) { - method = rargs.data; - break; + if (argslist[i].matches(self, args, keywords, callData)) { + match = argslist[i]; } } - if (method == null) { + if (match == null) { throwError(callData.errArg, args.length, self != null, keywords.length != 0); } Object cself = callData.self; - Method m = (Method)method; + Method m = (Method)match.data; + + // If this is a direct call to a Java class instance method with a PyProxy instance as the + // arg, use the super__ version to actually route this through the method on the class. + if (self == null && cself != null && cself instanceof PyProxy + && !__name__.startsWith("super__") + && match.declaringClass != cself.getClass()) { + String mname = ("super__" + __name__); + try { + m = cself.getClass().getMethod(mname, m.getParameterTypes()); + } catch (Exception e) { + throw Py.JavaError(e); + } + } Object o; try { o = m.invoke(cself, callData.getArgsArray()); @@ -247,7 +256,7 @@ } } - private static String niceName(Class arg) { + private static String niceName(Class<?> arg) { if (arg == String.class || arg == PyString.class) { return "String"; } @@ -260,11 +269,10 @@ protected void throwBadArgError(int errArg, int nArgs, boolean self) { Set<Class<?>> argTypes = Generic.set(); for (int i = 0; i < nargs; i++) { - // if (!args.isStatic && !self) { len = len-1; } // This check works almost all the time. - // I'm still a little worried about non-static methods - // called with an explict self... - if (argslist[i].args.length == nArgs) { + // I'm still a little worried about non-static methods called with an explicit self... + if (argslist[i].args.length == nArgs || + (!argslist[i].isStatic && !self && argslist[i].args.length == nArgs - 1)) { if (errArg == ReflectedCallData.UNABLE_TO_CONVERT_SELF) { argTypes.add(argslist[i].declaringClass); } else { Modified: trunk/jython/src/org/python/core/ReflectedArgs.java =================================================================== --- trunk/jython/src/org/python/core/ReflectedArgs.java 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/src/org/python/core/ReflectedArgs.java 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,7 +1,7 @@ // Copyright (c) Corporation for National Research Initiatives package org.python.core; -class ReflectedArgs { +public class ReflectedArgs { public Class[] args; public Object data; @@ -258,10 +258,9 @@ } public String toString() { - String s = "" + this.declaringClass + ", " + this.isStatic + ", " + this.flags + ", " - + this.data + "\n"; + String s = declaringClass + ", " + isStatic + ", " + flags + ", " + data + "\n"; s = s + "\t("; - for (Class arg : this.args) { + for (Class<?> arg : args) { s += arg.getName() + ", "; } s += ")"; Added: trunk/jython/tests/java/org/python/tests/BeanImplementation.java =================================================================== --- trunk/jython/tests/java/org/python/tests/BeanImplementation.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/BeanImplementation.java 2009-01-04 08:41:16 UTC (rev 5839) @@ -0,0 +1,9 @@ +package org.python.tests; + + +public class BeanImplementation implements BeanInterface { + + public String getName() { + return "name"; + } +} Added: trunk/jython/tests/java/org/python/tests/BeanInterface.java =================================================================== --- trunk/jython/tests/java/org/python/tests/BeanInterface.java (rev 0) +++ trunk/jython/tests/java/org/python/tests/BeanInterface.java 2009-01-04 08:41:16 UTC (rev 5839) @@ -0,0 +1,6 @@ +package org.python.tests; + + +public interface BeanInterface { + String getName(); +} Modified: trunk/jython/tests/java/org/python/tests/Callbacker.java =================================================================== --- trunk/jython/tests/java/org/python/tests/Callbacker.java 2009-01-04 05:48:09 UTC (rev 5838) +++ trunk/jython/tests/java/org/python/tests/Callbacker.java 2009-01-04 08:41:16 UTC (rev 5839) @@ -1,5 +1,9 @@ package org.python.tests; +import java.util.List; + +import org.python.util.Generic; + public class Callbacker { public interface Callback { @@ -9,6 +13,19 @@ public void call(long oneArg); } + public static class CollectingCallback implements Callback { + + public List<String> calls = Generic.list(); + + public void call() { + calls.add("call()"); + } + + public void call(long oneArg) { + calls.add("call(" + oneArg + ")"); + } + } + public static void callNoArg(Callback c) { c.call(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-04 05:48:11
|
Revision: 5838 http://jython.svn.sourceforge.net/jython/?rev=5838&view=rev Author: cgroves Date: 2009-01-04 05:48:09 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Huh, synchronize.make_synchronized synchronizes on the instance called, not the method itself, so switch to using a single Runnable instance to synchronize across. Modified Paths: -------------- trunk/jython/Lib/test/test_thread_jy.py Modified: trunk/jython/Lib/test/test_thread_jy.py =================================================================== --- trunk/jython/Lib/test/test_thread_jy.py 2009-01-04 05:42:44 UTC (rev 5837) +++ trunk/jython/Lib/test/test_thread_jy.py 2009-01-04 05:48:09 UTC (rev 5838) @@ -2,7 +2,7 @@ import synchronize import unittest import test.test_support -from java.lang import Thread +from java.lang import Runnable, Thread from java.util.concurrent import CountDownLatch class AllocateLockTest(unittest.TestCase): @@ -15,17 +15,18 @@ class SynchronizeTest(unittest.TestCase): def test_make_synchronized(self): - self.doneSignal = CountDownLatch(10) - self.i = 0 - class SynchedRun(Thread): - def run(synchself): - self.i = self.i + 1 - self.doneSignal.countDown() + doneSignal = CountDownLatch(10) + class SynchedRunnable(Runnable): + i = 0 + def run(self): + self.i += 1 + doneSignal.countDown() run = synchronize.make_synchronized(run) + runner = SynchedRunnable() for _ in xrange(10): - SynchedRun().start() - self.doneSignal.await() - self.assertEquals(10, self.i) + Thread(runner).start() + doneSignal.await() + self.assertEquals(10, runner.i) def test_main(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-04 05:42:55
|
Revision: 5837 http://jython.svn.sourceforge.net/jython/?rev=5837&view=rev Author: cgroves Date: 2009-01-04 05:42:44 +0000 (Sun, 04 Jan 2009) Log Message: ----------- Expose the underlying_class on proxy types as their Java proxy type such that they properly coerce into java.lang.Class. Modified Paths: -------------- trunk/jython/Lib/test/test_java_integration.py trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/expose/BaseTypeBuilder.java trunk/jython/src/org/python/expose/generate/OverridableNewExposer.java Removed Paths: ------------- trunk/jython/bugtests/test277.py trunk/jython/bugtests/test277p/ Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-01-03 04:37:38 UTC (rev 5836) +++ trunk/jython/Lib/test/test_java_integration.py 2009-01-04 05:42:44 UTC (rev 5837) @@ -98,9 +98,12 @@ def method(self): called.append(True) A() - Class.newInstance(A) - self.assertEquals(len(called), 2) + self.assertEquals(len(called), 1) +# The no-arg constructor for proxies attempts to look up its Python class by the Python class' name, +# so the class needs to be visible at the module level or the import will fail +class ModuleVisibleJavaSubclass(Object): + pass class InstantiationTest(unittest.TestCase): def test_can_subclass_abstract(self): class A(Component): @@ -114,7 +117,10 @@ from java.util import Date self.assertRaises(TypeError, Date, '99-01-01', 1, 1) + def test_Class_newInstance_works_on_proxies(self): + Class.newInstance(ModuleVisibleJavaSubclass) + class BeanTest(unittest.TestCase): def test_shared_names(self): self.failUnless(callable(Vector.size), Deleted: trunk/jython/bugtests/test277.py =================================================================== --- trunk/jython/bugtests/test277.py 2009-01-03 04:37:38 UTC (rev 5836) +++ trunk/jython/bugtests/test277.py 2009-01-04 05:42:44 UTC (rev 5837) @@ -1,30 +0,0 @@ -""" - -""" - -import support - -support.compileJava("test277p/Test.java") - -from test277p import Test - -cnt = 0 - -class pytest(Test): - - def initialize(self): - global cnt - Test.initialize(self) - cnt += 1 - -pt=pytest() - -support.compare(cnt, "2") - -cnt = 0 - -import java -pt=java.lang.Class.newInstance(pytest) - -support.compare(cnt, "2") - Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2009-01-03 04:37:38 UTC (rev 5836) +++ trunk/jython/src/org/python/core/PyType.java 2009-01-04 05:42:44 UTC (rev 5837) @@ -176,17 +176,14 @@ // XXX also __doc__ __module__ + Class<?> proxyClass = null; if (baseClass != null || interfaces.size() != 0) { String proxyName = name; PyObject module = dict.__finditem__("__module__"); if (module != null) { proxyName = module.toString() + "$" + proxyName; } - Class<?> proxyClass = MakeProxies.makeProxy(baseClass, - interfaces, - name, - proxyName, - dict); + proxyClass = MakeProxies.makeProxy(baseClass, interfaces, name, proxyName, dict); PyType proxyType = PyType.fromClass(proxyClass); List<PyObject> cleanedBases = Generic.list(); boolean addedProxyType = false; @@ -203,8 +200,11 @@ bases_list = cleanedBases.toArray(new PyObject[cleanedBases.size()]); } PyType newtype; - if (new_.for_type == metatype) { + if (new_.for_type == metatype || metatype == PyType.fromClass(Class.class)) { newtype = new PyType(); // XXX set metatype + if(proxyClass != null) { + newtype.underlying_class = proxyClass; + } } else { newtype = new PyTypeDerived(metatype); } @@ -1375,7 +1375,11 @@ private String name; TypeResolver(Class<?> underlying_class, String module, String name) { - this.underlying_class = underlying_class; + // Don't store the underlying_class for PyProxies as the proxy type needs to fill in + // based on the class, not be the class + if (underlying_class != null && !PyProxy.class.isAssignableFrom(underlying_class)) { + this.underlying_class = underlying_class; + } this.module = module; this.name = name; } Modified: trunk/jython/src/org/python/expose/BaseTypeBuilder.java =================================================================== --- trunk/jython/src/org/python/expose/BaseTypeBuilder.java 2009-01-03 04:37:38 UTC (rev 5836) +++ trunk/jython/src/org/python/expose/BaseTypeBuilder.java 2009-01-04 05:42:44 UTC (rev 5837) @@ -16,17 +16,17 @@ private PyDataDescr[] descrs; - private Class typeClass; + private Class<?> typeClass; - private Class baseClass; + private Class<?> baseClass; private String name; private boolean isBaseType; public BaseTypeBuilder(String name, - Class typeClass, - Class baseClass, + Class<?> typeClass, + Class<?> baseClass, boolean isBaseType, PyBuiltinMethod[] meths, PyDataDescr[] descrs, @@ -50,7 +50,7 @@ descr.setType(type); dict.__setitem__(descr.getName(), descr); } - if(newWrapper != null) { + if (newWrapper != null) { dict.__setitem__("__new__", newWrapper); newWrapper.setWrappedType(type); } @@ -61,11 +61,11 @@ return name; } - public Class getTypeClass() { + public Class<?> getTypeClass() { return typeClass; } - public Class getBase() { + public Class<?> getBase() { return baseClass; } Modified: trunk/jython/src/org/python/expose/generate/OverridableNewExposer.java =================================================================== --- trunk/jython/src/org/python/expose/generate/OverridableNewExposer.java 2009-01-03 04:37:38 UTC (rev 5836) +++ trunk/jython/src/org/python/expose/generate/OverridableNewExposer.java 2009-01-04 05:42:44 UTC (rev 5837) @@ -1,9 +1,8 @@ package org.python.expose.generate; +import org.python.core.PyOverridableNew; import org.python.objectweb.asm.Label; import org.python.objectweb.asm.Type; -import org.python.core.PyOverridableNew; -import org.python.core.PyObject; public class OverridableNewExposer extends Exposer { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-03 04:37:44
|
Revision: 5836 http://jython.svn.sourceforge.net/jython/?rev=5836&view=rev Author: fwierzbicki Date: 2009-01-03 04:37:38 +0000 (Sat, 03 Jan 2009) Log Message: ----------- The code: [i for i in range(10)] = (1, 2, 3) now properly fails to parse. test275.py -> test_codeop_jy.py Modified Paths: -------------- trunk/jython/Lib/test/test_codeop_jy.py trunk/jython/src/org/python/antlr/GrammarActions.java Removed Paths: ------------- trunk/jython/bugtests/test275.py trunk/jython/bugtests/test275s.py Modified: trunk/jython/Lib/test/test_codeop_jy.py =================================================================== --- trunk/jython/Lib/test/test_codeop_jy.py 2009-01-03 04:19:44 UTC (rev 5835) +++ trunk/jython/Lib/test/test_codeop_jy.py 2009-01-03 04:37:38 UTC (rev 5836) @@ -172,6 +172,7 @@ ai("del [1]") ai("del '1'") ai("if (a == 1 and b = 2): pass") + ai("[i for i in range(10)] = (1, 2, 3)") def test_filename(self): self.assertEquals(compile_("a = 1\n", "abc").co_filename, Deleted: trunk/jython/bugtests/test275.py =================================================================== --- trunk/jython/bugtests/test275.py 2009-01-03 04:19:44 UTC (rev 5835) +++ trunk/jython/bugtests/test275.py 2009-01-03 04:37:38 UTC (rev 5836) @@ -1,13 +0,0 @@ -""" - -""" - -import support - - -try: - import test275s -except SyntaxError: - pass -else: - raise support.TestError("Should raise a syntax error") Deleted: trunk/jython/bugtests/test275s.py =================================================================== --- trunk/jython/bugtests/test275s.py 2009-01-03 04:19:44 UTC (rev 5835) +++ trunk/jython/bugtests/test275s.py 2009-01-03 04:37:38 UTC (rev 5836) @@ -1,10 +0,0 @@ -""" - -""" - -try: - [i for i in range(10)] = (1, 2, 3) -except SyntaxError: - pass -else: - raise support.TestError("Should raise a syntax error") Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2009-01-03 04:19:44 UTC (rev 5835) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2009-01-03 04:37:38 UTC (rev 5836) @@ -619,6 +619,8 @@ errorHandler.error("can't assign to repr", e); } else if (e instanceof IfExp) { errorHandler.error("can't assign to conditional expression", e); + } else if (e instanceof ListComp) { + errorHandler.error("can't assign to list comprehension", e); } else if (e instanceof Tuple) { //XXX: performance problem? Any way to do this better? List<expr> elts = ((Tuple)e).getInternalElts(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-03 04:19:54
|
Revision: 5835 http://jython.svn.sourceforge.net/jython/?rev=5835&view=rev Author: fwierzbicki Date: 2009-01-03 04:19:44 +0000 (Sat, 03 Jan 2009) Log Message: ----------- __doc__ for classmethod, instancemethod, bool, function. Modified Paths: -------------- trunk/jython/src/org/python/core/PyBoolean.java trunk/jython/src/org/python/core/PyClassMethod.java trunk/jython/src/org/python/core/PyFunction.java trunk/jython/src/org/python/core/PyMethod.java Modified: trunk/jython/src/org/python/core/PyBoolean.java =================================================================== --- trunk/jython/src/org/python/core/PyBoolean.java 2009-01-03 02:47:53 UTC (rev 5834) +++ trunk/jython/src/org/python/core/PyBoolean.java 2009-01-03 04:19:44 UTC (rev 5835) @@ -50,7 +50,7 @@ return bool_toString(); } - @ExposedMethod(names = {"__str__", "__repr__"}) + @ExposedMethod(names = {"__str__", "__repr__"}, doc = BuiltinDocs.bool___str___doc) final String bool_toString() { return value ? "True" : "False"; } @@ -59,7 +59,7 @@ return bool___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.bool___hash___doc) final int bool___hash__() { return value ? 1 : 0; } @@ -68,7 +68,7 @@ return bool___nonzero__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.bool___nonzero___doc) final boolean bool___nonzero__() { return value; } @@ -99,7 +99,7 @@ return bool___and__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.bool___and___doc) final PyObject bool___and__(PyObject right) { if (right instanceof PyBoolean) { return Py.newBoolean(value & ((PyBoolean)right).value); @@ -114,7 +114,7 @@ return bool___xor__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.bool___xor___doc) final PyObject bool___xor__(PyObject right) { if (right instanceof PyBoolean) { return Py.newBoolean(value ^ ((PyBoolean)right).value); @@ -129,7 +129,7 @@ return bool___or__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.bool___or___doc) final PyObject bool___or__(PyObject right) { if (right instanceof PyBoolean) { return Py.newBoolean(value | ((PyBoolean)right).value); @@ -144,7 +144,7 @@ return bool___neg__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.bool___neg___doc) final PyObject bool___neg__() { return Py.newInteger(value ? -1 : 0); } @@ -153,7 +153,7 @@ return bool___pos__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.bool___pos___doc) final PyObject bool___pos__() { return Py.newInteger(value ? 1 : 0); } @@ -162,7 +162,7 @@ return bool___abs__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.bool___abs___doc) final PyObject bool___abs__() { return Py.newInteger(value ? 1 : 0); } Modified: trunk/jython/src/org/python/core/PyClassMethod.java =================================================================== --- trunk/jython/src/org/python/core/PyClassMethod.java 2009-01-03 02:47:53 UTC (rev 5834) +++ trunk/jython/src/org/python/core/PyClassMethod.java 2009-01-03 04:19:44 UTC (rev 5835) @@ -41,7 +41,7 @@ return classmethod___get__(obj, type); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.classmethod___get___doc) final PyObject classmethod___get__(PyObject obj, PyObject type) { if(type == null) { type = obj.getType(); Modified: trunk/jython/src/org/python/core/PyFunction.java =================================================================== --- trunk/jython/src/org/python/core/PyFunction.java 2009-01-03 02:47:53 UTC (rev 5834) +++ trunk/jython/src/org/python/core/PyFunction.java 2009-01-03 04:19:44 UTC (rev 5835) @@ -276,7 +276,7 @@ function___setattr__(name, value); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.function___setattr___doc) final void function___setattr__(String name, PyObject value) { ensureDict(); super.__setattr__(name, value); @@ -292,7 +292,7 @@ return function___get__(obj, type); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.function___get___doc) final PyObject function___get__(PyObject obj, PyObject type) { return new PyMethod(this, obj, type); } @@ -323,7 +323,7 @@ return function___call__(args, keywords); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.function___call___doc) final PyObject function___call__(PyObject[] args, String[] keywords) { return func_code.call(args, keywords, func_globals, func_defaults, func_closure); } Modified: trunk/jython/src/org/python/core/PyMethod.java =================================================================== --- trunk/jython/src/org/python/core/PyMethod.java 2009-01-03 02:47:53 UTC (rev 5834) +++ trunk/jython/src/org/python/core/PyMethod.java 2009-01-03 04:19:44 UTC (rev 5835) @@ -67,7 +67,7 @@ return im_func.__findattr_ex__(name); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.instancemethod___getattribute___doc) final PyObject instancemethod___getattribute__(PyObject arg0) { String name = asName(arg0); PyObject ret = instancemethod___findattr_ex__(name); @@ -82,7 +82,7 @@ return instancemethod___get__(obj, type); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.instancemethod___get___doc) final PyObject instancemethod___get__(PyObject obj, PyObject type) { // Only if classes are compatible if (obj == null || im_self != null) { @@ -99,7 +99,7 @@ return instancemethod___call__(args, keywords); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.instancemethod___call___doc) final PyObject instancemethod___call__(PyObject[] args, String[] keywords) { PyObject self = im_self; @@ -136,7 +136,7 @@ return instancemethod___cmp__(other); } - @ExposedMethod(type = MethodType.CMP) + @ExposedMethod(type = MethodType.CMP, doc = BuiltinDocs.instancemethod___cmp___doc) final int instancemethod___cmp__(PyObject other) { if (!(other instanceof PyMethod)) { return -2; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-03 02:47:58
|
Revision: 5834 http://jython.svn.sourceforge.net/jython/?rev=5834&view=rev Author: fwierzbicki Date: 2009-01-03 02:47:53 +0000 (Sat, 03 Jan 2009) Log Message: ----------- __doc__ for complex, xrange, file. Modified Paths: -------------- trunk/jython/src/org/python/core/PyComplex.java trunk/jython/src/org/python/core/PyFile.java trunk/jython/src/org/python/core/PyXRange.java Modified: trunk/jython/src/org/python/core/PyComplex.java =================================================================== --- trunk/jython/src/org/python/core/PyComplex.java 2009-01-02 15:36:57 UTC (rev 5833) +++ trunk/jython/src/org/python/core/PyComplex.java 2009-01-03 02:47:53 UTC (rev 5834) @@ -130,7 +130,7 @@ return complex_toString(); } - @ExposedMethod(names = {"__repr__", "__str__"}) + @ExposedMethod(names = {"__repr__", "__str__"}, doc = BuiltinDocs.complex___str___doc) final String complex_toString() { if (real == 0.) { return toString(imag)+"j"; @@ -147,7 +147,7 @@ return complex___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___hash___doc) final int complex___hash__() { if (imag == 0) { return new PyFloat(real).hashCode(); @@ -162,7 +162,7 @@ return complex___nonzero__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___nonzero___doc) final boolean complex___nonzero__() { return real != 0 && imag != 0; } @@ -193,7 +193,7 @@ return complex___eq__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___eq___doc) final PyObject complex___eq__(PyObject other) { if (!canCoerce(other)) return null; @@ -208,7 +208,7 @@ return complex___ne__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___ne___doc) final PyObject complex___ne__(PyObject other) { if (!canCoerce(other)) return null; @@ -226,7 +226,7 @@ return complex___ge__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___ge___doc) final PyObject complex___ge__(PyObject other) { return unsupported_comparison(other); } @@ -235,7 +235,7 @@ return complex___gt__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___gt___doc) final PyObject complex___gt__(PyObject other) { return unsupported_comparison(other); } @@ -244,7 +244,7 @@ return complex___le__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___le___doc) final PyObject complex___le__(PyObject other) { return unsupported_comparison(other); } @@ -253,7 +253,7 @@ return complex___lt__(other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___lt___doc) final PyObject complex___lt__(PyObject other) { return unsupported_comparison(other); } @@ -262,7 +262,7 @@ return complex___coerce_ex__(other); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___coerce___doc) final PyObject complex___coerce__(PyObject other) { return adaptToCoerceTuple(complex___coerce_ex__(other)); } @@ -306,7 +306,7 @@ return complex___add__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___add___doc) final PyObject complex___add__(PyObject right) { if (!canCoerce(right)) return null; @@ -318,7 +318,7 @@ return complex___radd__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___radd___doc) final PyObject complex___radd__(PyObject left) { return __add__(left); } @@ -331,7 +331,7 @@ return complex___sub__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___sub___doc) final PyObject complex___sub__(PyObject right) { if (!canCoerce(right)) return null; @@ -342,7 +342,7 @@ return complex___rsub__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___rsub___doc) final PyObject complex___rsub__(PyObject left) { if (!canCoerce(left)) return null; @@ -358,7 +358,7 @@ return complex___mul__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___mul___doc) final PyObject complex___mul__(PyObject right) { if (!canCoerce(right)) return null; @@ -369,7 +369,7 @@ return complex___rmul__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___rmul___doc) final PyObject complex___rmul__(PyObject left) { if (!canCoerce(left)) return null; @@ -401,7 +401,7 @@ return complex___div__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___div___doc) final PyObject complex___div__(PyObject right) { if (!canCoerce(right)) return null; @@ -414,7 +414,7 @@ return complex___rdiv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___rdiv___doc) final PyObject complex___rdiv__(PyObject left) { if (!canCoerce(left)) return null; @@ -427,7 +427,7 @@ return complex___floordiv__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___floordiv___doc) final PyObject complex___floordiv__(PyObject right) { if (!canCoerce(right)) return null; @@ -438,7 +438,7 @@ return complex___rfloordiv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___rfloordiv___doc) final PyObject complex___rfloordiv__(PyObject left) { if (!canCoerce(left)) return null; @@ -449,7 +449,7 @@ return complex___truediv__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___truediv___doc) final PyObject complex___truediv__(PyObject right) { if (!canCoerce(right)) return null; @@ -460,7 +460,7 @@ return complex___rtruediv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___rtruediv___doc) final PyObject complex___rtruediv__(PyObject left) { if (!canCoerce(left)) return null; @@ -471,7 +471,7 @@ return complex___mod__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___mod___doc) final PyObject complex___mod__(PyObject right) { if (!canCoerce(right)) return null; @@ -482,7 +482,7 @@ return complex___rmod__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___rmod___doc) final PyObject complex___rmod__(PyObject left) { if (!canCoerce(left)) return null; @@ -503,7 +503,7 @@ return complex___divmod__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___divmod___doc) final PyObject complex___divmod__(PyObject right) { if (!canCoerce(right)) return null; @@ -514,7 +514,7 @@ return complex___rdivmod__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___rdivmod___doc) final PyObject complex___rdivmod__(PyObject left) { if (!canCoerce(left)) return null; @@ -569,7 +569,7 @@ return complex___pow__(right, modulo); } - @ExposedMethod(type = MethodType.BINARY, defaults = "null") + @ExposedMethod(type = MethodType.BINARY, defaults = "null", doc = BuiltinDocs.complex___pow___doc) final PyObject complex___pow__(PyObject right, PyObject modulo) { if (modulo != null) { throw Py.ValueError("complex modulo"); @@ -583,7 +583,7 @@ return complex___rpow__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.complex___rpow___doc) final PyObject complex___rpow__(PyObject left) { if (!canCoerce(left)) return null; @@ -628,7 +628,7 @@ return complex___neg__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___neg___doc) final PyObject complex___neg__() { return new PyComplex(-real, -imag); } @@ -637,7 +637,7 @@ return complex___pos__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___pos___doc) final PyObject complex___pos__() { return new PyComplex(real, imag); } @@ -650,7 +650,7 @@ return complex___abs__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___abs___doc) final PyObject complex___abs__() { return new PyFloat(Math.hypot(real, imag)); } @@ -659,7 +659,7 @@ return complex___int__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___int___doc) final PyInteger complex___int__() { throw Py.TypeError( "can't convert complex to int; use e.g. int(abs(z))"); @@ -669,7 +669,7 @@ return complex___long__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___long___doc) final PyObject complex___long__() { throw Py.TypeError( "can't convert complex to long; use e.g. long(abs(z))"); @@ -679,7 +679,7 @@ return complex___float__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___float___doc) final PyFloat complex___float__() { throw Py.TypeError("can't convert complex to float; use e.g. abs(z)"); } @@ -692,12 +692,12 @@ return complex_conjugate(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex_conjugate_doc) final PyComplex complex_conjugate() { return new PyComplex(real, -imag); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.complex___getnewargs___doc) final PyTuple complex___getnewargs__() { return new PyTuple(new PyComplex(real, imag)); } Modified: trunk/jython/src/org/python/core/PyFile.java =================================================================== --- trunk/jython/src/org/python/core/PyFile.java 2009-01-02 15:36:57 UTC (rev 5833) +++ trunk/jython/src/org/python/core/PyFile.java 2009-01-03 02:47:53 UTC (rev 5834) @@ -140,7 +140,7 @@ } @ExposedNew - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file___init___doc) final void file___init__(PyObject[] args, String[] kwds) { ArgParser ap = new ArgParser("file", args, kwds, new String[] {"name", "mode", "bufsize"}, 1); @@ -239,7 +239,7 @@ + (updating ? "+" : ""); } - @ExposedMethod(defaults = {"-1"}) + @ExposedMethod(defaults = {"-1"}, doc = BuiltinDocs.file_read_doc) final synchronized PyString file_read(int n) { checkClosed(); return new PyString(file.read(n)); @@ -253,7 +253,7 @@ return file_read(-1); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file_readinto_doc) final synchronized int file_readinto(PyObject buf) { checkClosed(); return file.readinto(buf); @@ -263,7 +263,7 @@ return file_readinto(buf); } - @ExposedMethod(defaults = {"-1"}) + @ExposedMethod(defaults = {"-1"}, doc = BuiltinDocs.file_readline_doc) final synchronized PyString file_readline(int max) { checkClosed(); return new PyString(file.readline(max)); @@ -277,7 +277,7 @@ return file_readline(-1); } - @ExposedMethod(defaults = {"0"}) + @ExposedMethod(defaults = {"0"}, doc = BuiltinDocs.file_readlines_doc) final synchronized PyObject file_readlines(int sizehint) { checkClosed(); PyList list = new PyList(); @@ -316,7 +316,7 @@ return new PyString(next); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file_next_doc) final PyObject file_next() { PyObject ret = file___iternext__(); if (ret == null) { @@ -329,7 +329,7 @@ return file_next(); } - @ExposedMethod(names = {"__enter__", "__iter__", "xreadlines"}) + @ExposedMethod(names = {"__enter__", "__iter__", "xreadlines"}, doc = BuiltinDocs.file___iter___doc) final PyObject file_self() { checkClosed(); return this; @@ -347,7 +347,7 @@ return file_self(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file_write_doc) final void file_write(PyObject o) { if (o instanceof PyUnicode) { // Call __str__ on unicode objects to encode them before writing @@ -369,7 +369,7 @@ file_write(s); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file_writelines_doc) final synchronized void file_writelines(PyObject a) { checkClosed(); PyObject iter = Py.iter(a, "writelines() requires an iterable argument"); @@ -387,7 +387,7 @@ file_writelines(a); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file_tell_doc) final synchronized long file_tell() { checkClosed(); return file.tell(); @@ -397,7 +397,7 @@ return file_tell(); } - @ExposedMethod(defaults = {"0"}) + @ExposedMethod(defaults = {"0"}, doc = BuiltinDocs.file_seek_doc) final synchronized void file_seek(long pos, int how) { checkClosed(); file.seek(pos, how); @@ -411,7 +411,7 @@ file_seek(pos, 0); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file_flush_doc) final synchronized void file_flush() { checkClosed(); file.flush(); @@ -421,7 +421,7 @@ file_flush(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file_close_doc) final synchronized void file_close() { if (closer != null) { closer.close(); @@ -435,7 +435,7 @@ file_close(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file___exit___doc) final void file___exit__(PyObject type, PyObject value, PyObject traceback) { file_close(); } @@ -444,7 +444,7 @@ file___exit__(type, value, traceback); } - @ExposedMethod(defaults = {"null"}) + @ExposedMethod(defaults = {"null"}, doc = BuiltinDocs.file_truncate_doc) final void file_truncate(PyObject position) { if (position == null) { file_truncate(); @@ -477,7 +477,7 @@ return file_isatty(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file_isatty_doc) final boolean file_isatty() { return file.isatty(); } @@ -486,12 +486,12 @@ return file_fileno(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.file_fileno_doc) final PyObject file_fileno() { return PyJavaType.wrapJavaObject(file.fileno()); } - @ExposedMethod(names = {"__str__", "__repr__"}) + @ExposedMethod(names = {"__str__", "__repr__"}, doc = BuiltinDocs.file___str___doc) final String file_toString() { StringBuilder s = new StringBuilder("<"); if (file.closed()) { Modified: trunk/jython/src/org/python/core/PyXRange.java =================================================================== --- trunk/jython/src/org/python/core/PyXRange.java 2009-01-02 15:36:57 UTC (rev 5833) +++ trunk/jython/src/org/python/core/PyXRange.java 2009-01-03 02:47:53 UTC (rev 5834) @@ -93,7 +93,7 @@ return xrange___len__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.xrange___len___doc) final int xrange___len__() { return len; } @@ -103,7 +103,7 @@ return xrange___getitem__(index); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.xrange___getitem___doc) final PyObject xrange___getitem__(PyObject index) { PyObject ret = seq___finditem__(index); if (ret == null) { @@ -112,7 +112,7 @@ return ret; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.xrange___iter___doc) public PyObject xrange___iter__() { return seq___iter__(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-02 15:37:02
|
Revision: 5833 http://jython.svn.sourceforge.net/jython/?rev=5833&view=rev Author: fwierzbicki Date: 2009-01-02 15:36:57 +0000 (Fri, 02 Jan 2009) Log Message: ----------- __doc__ for int, property and tuple. Modified Paths: -------------- trunk/jython/src/org/python/core/PyInteger.java trunk/jython/src/org/python/core/PyProperty.java trunk/jython/src/org/python/core/PyTuple.java Modified: trunk/jython/src/org/python/core/PyInteger.java =================================================================== --- trunk/jython/src/org/python/core/PyInteger.java 2009-01-02 03:51:08 UTC (rev 5832) +++ trunk/jython/src/org/python/core/PyInteger.java 2009-01-02 15:36:57 UTC (rev 5833) @@ -104,7 +104,8 @@ return int_toString(); } - @ExposedMethod(names = {"__str__", "__repr__"}) + //XXX: need separate __doc__ for __repr__ + @ExposedMethod(names = {"__str__", "__repr__"}, doc = BuiltinDocs.int___str___doc) final String int_toString() { return Integer.toString(getValue()); } @@ -113,7 +114,7 @@ return int_hashCode(); } - @ExposedMethod(names = "__hash__") + @ExposedMethod(names = "__hash__", doc = BuiltinDocs.int___hash___doc) final int int_hashCode() { return getValue(); } @@ -122,7 +123,7 @@ return int___nonzero__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___nonzero___doc) final boolean int___nonzero__() { return getValue() != 0; } @@ -155,7 +156,7 @@ return int___cmp__(other); } - @ExposedMethod(type = MethodType.CMP) + @ExposedMethod(type = MethodType.CMP, doc = BuiltinDocs.int___cmp___doc) final int int___cmp__(PyObject other) { if (!canCoerce(other)) return -2; @@ -167,7 +168,7 @@ return int___coerce_ex__(other); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___coerce___doc) final PyObject int___coerce__(PyObject other) { return adaptToCoerceTuple(int___coerce_ex__(other)); } @@ -199,7 +200,7 @@ return int___add__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___add___doc) final PyObject int___add__(PyObject right) { if (!canCoerce(right)) return null; @@ -216,7 +217,7 @@ return int___radd__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___radd___doc) final PyObject int___radd__(PyObject left) { return __add__(left); } @@ -232,7 +233,7 @@ return int___sub__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___sub___doc) final PyObject int___sub__(PyObject right) { if (!canCoerce(right)) return null; @@ -243,7 +244,7 @@ return int___rsub__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rsub___doc) final PyObject int___rsub__(PyObject left) { if (!canCoerce(left)) return null; @@ -254,7 +255,7 @@ return int___mul__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___mul___doc) final PyObject int___mul__(PyObject right) { if (right instanceof PySequence) return ((PySequence) right).repeat(getValue()); @@ -277,7 +278,7 @@ return int___rmul__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rmul___doc) final PyObject int___rmul__(PyObject left) { return __mul__(left); } @@ -310,7 +311,7 @@ return int___div__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___div___doc) final PyObject int___div__(PyObject right) { if (!canCoerce(right)) return null; @@ -323,7 +324,7 @@ return int___rdiv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rdiv___doc) final PyObject int___rdiv__(PyObject left) { if (!canCoerce(left)) return null; @@ -336,7 +337,7 @@ return int___floordiv__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___floordiv___doc) final PyObject int___floordiv__(PyObject right) { if (!canCoerce(right)) return null; @@ -347,7 +348,7 @@ return int___rfloordiv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rfloordiv___doc) final PyObject int___rfloordiv__(PyObject left) { if (!canCoerce(left)) return null; @@ -358,7 +359,7 @@ return int___truediv__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___truediv___doc) final PyObject int___truediv__(PyObject right) { if (right instanceof PyInteger) return __float__().__truediv__(right); @@ -372,7 +373,7 @@ return int___rtruediv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rtruediv___doc) final PyObject int___rtruediv__(PyObject left) { if (left instanceof PyInteger) return left.__float__().__truediv__(this); @@ -390,7 +391,7 @@ return int___mod__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___mod___doc) final PyObject int___mod__(PyObject right) { if (!canCoerce(right)) return null; @@ -403,7 +404,7 @@ return int___rmod__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rmod___doc) final PyObject int___rmod__(PyObject left) { if (!canCoerce(left)) return null; @@ -416,7 +417,7 @@ return int___divmod__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___divmod___doc) final PyObject int___divmod__(PyObject right) { if (!canCoerce(right)) return null; @@ -427,7 +428,7 @@ return new PyTuple(Py.newInteger(xdivy), Py.newInteger(modulo(v, rightv, xdivy))); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rdivmod___doc) final PyObject int___rdivmod__(PyObject left){ if (!canCoerce(left)) return null; @@ -442,7 +443,7 @@ return int___pow__(right,modulo); } - @ExposedMethod(type = MethodType.BINARY, defaults = {"null"}) + @ExposedMethod(type = MethodType.BINARY, defaults = {"null"}, doc = BuiltinDocs.int___pow___doc) final PyObject int___pow__(PyObject right, PyObject modulo) { if (!canCoerce(right)) return null; @@ -463,7 +464,7 @@ return _pow(coerce(left), getValue(), modulo, left, this); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rpow___doc) final PyObject int___rpow__(PyObject left){ return __rpow__(left, null); } @@ -533,7 +534,7 @@ return int___lshift__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___lshift___doc) final PyObject int___lshift__(PyObject right) { int rightv; if (right instanceof PyInteger) @@ -555,7 +556,7 @@ return Py.newInteger(result); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rlshift___doc) final PyObject int___rlshift__(PyObject left) { int leftv; if (left instanceof PyInteger) @@ -581,7 +582,7 @@ return int___rshift__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rshift___doc) final PyObject int___rshift__(PyObject right) { int rightv; if (right instanceof PyInteger) @@ -606,7 +607,7 @@ return Py.newInteger(getValue() >> rightv); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rrshift___doc) final PyObject int___rrshift__(PyObject left) { int leftv; if (left instanceof PyInteger) @@ -635,7 +636,7 @@ return int___and__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___and___doc) final PyObject int___and__(PyObject right) { int rightv; if (right instanceof PyInteger) @@ -648,7 +649,7 @@ return Py.newInteger(getValue() & rightv); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rand___doc) final PyObject int___rand__(PyObject left){ return int___and__(left); } @@ -657,7 +658,7 @@ return int___xor__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___xor___doc) final PyObject int___xor__(PyObject right) { int rightv; if (right instanceof PyInteger) @@ -670,7 +671,7 @@ return Py.newInteger(getValue() ^ rightv); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rxor___doc) final PyObject int___rxor__(PyObject left){ int leftv; if (left instanceof PyInteger) @@ -687,7 +688,7 @@ return int___or__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___or___doc) final PyObject int___or__(PyObject right) { int rightv; if (right instanceof PyInteger) @@ -700,7 +701,7 @@ return Py.newInteger(getValue() | rightv); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___ror___doc) final PyObject int___ror__(PyObject left){ return int___or__(left); } @@ -709,7 +710,7 @@ return int___neg__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___neg___doc) final PyObject int___neg__() { long x = -getValue(); return Py.newInteger(x); @@ -719,7 +720,7 @@ return int___pos__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___pos___doc) final PyObject int___pos__() { return Py.newInteger(getValue()); } @@ -728,7 +729,7 @@ return int___abs__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___abs___doc) final PyObject int___abs__() { if (getValue() >= 0) return Py.newInteger(getValue()); @@ -740,7 +741,7 @@ return int___invert__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___invert___doc) final PyObject int___invert__() { return Py.newInteger(~getValue()); } @@ -749,7 +750,7 @@ return int___int__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___int___doc) final PyInteger int___int__() { return Py.newInteger(getValue()); } @@ -758,7 +759,7 @@ return int___long__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___long___doc) final PyObject int___long__() { return new PyLong(getValue()); } @@ -767,7 +768,7 @@ return int___float__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___float___doc) final PyFloat int___float__() { return new PyFloat((double)getValue()); } @@ -780,7 +781,7 @@ return int___oct__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___oct___doc) final PyString int___oct__() { if (getValue() < 0) { return new PyString("-0" + Integer.toString(getValue() * -1, 8)); @@ -794,7 +795,7 @@ return int___hex__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___hex___doc) final PyString int___hex__() { if (getValue() < 0) { return new PyString("-0x" + Integer.toString(getValue() * -1, 16)); @@ -804,7 +805,7 @@ } } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___getnewargs___doc) final PyTuple int___getnewargs__() { return new PyTuple(new PyObject[]{new PyInteger(this.getValue())}); } @@ -818,7 +819,7 @@ return int___index__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.int___index___doc) final PyObject int___index__() { return this; } Modified: trunk/jython/src/org/python/core/PyProperty.java =================================================================== --- trunk/jython/src/org/python/core/PyProperty.java 2009-01-02 03:51:08 UTC (rev 5832) +++ trunk/jython/src/org/python/core/PyProperty.java 2009-01-02 15:36:57 UTC (rev 5833) @@ -31,6 +31,7 @@ super(subType); } + //XXX: needs __doc__ @ExposedNew @ExposedMethod public void property___init__(PyObject[] args, String[] keywords) { @@ -58,7 +59,7 @@ return property___get__(obj,type); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.property___get___doc) final PyObject property___get__(PyObject obj, PyObject type) { if (obj == null || obj == Py.None) { return this; @@ -73,7 +74,7 @@ property___set__(obj, value); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.property___set___doc) final void property___set__(PyObject obj, PyObject value) { if (fset == null) { throw Py.AttributeError("can't set attribute"); @@ -85,7 +86,7 @@ property___delete__(obj); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.property___delete___doc) final void property___delete__(PyObject obj) { if (fdel == null) { throw Py.AttributeError("can't delete attribute"); Modified: trunk/jython/src/org/python/core/PyTuple.java =================================================================== --- trunk/jython/src/org/python/core/PyTuple.java 2009-01-02 03:51:08 UTC (rev 5832) +++ trunk/jython/src/org/python/core/PyTuple.java 2009-01-02 15:36:57 UTC (rev 5833) @@ -120,42 +120,42 @@ return tuple___len__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.tuple___len___doc) final int tuple___len__() { return size(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.tuple___contains___doc) final boolean tuple___contains__(PyObject o) { return super.__contains__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.tuple___ne___doc) final PyObject tuple___ne__(PyObject o) { return super.__ne__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.tuple___eq___doc) final PyObject tuple___eq__(PyObject o) { return super.__eq__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.tuple___gt___doc) final PyObject tuple___gt__(PyObject o) { return super.__gt__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.tuple___ge___doc) final PyObject tuple___ge__(PyObject o) { return super.__ge__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.tuple___lt___doc) final PyObject tuple___lt__(PyObject o) { return super.__lt__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.tuple___le___doc) final PyObject tuple___le__(PyObject o) { return super.__le__(o); } @@ -164,7 +164,7 @@ return tuple___add__(generic_other); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.tuple___add___doc) final PyObject tuple___add__(PyObject generic_other) { PyTuple sum = null; if (generic_other instanceof PyTuple) { @@ -186,7 +186,7 @@ return tuple___mul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.tuple___mul___doc) final PyObject tuple___mul__(PyObject o) { if (!o.isIndex()) { return null; @@ -199,7 +199,7 @@ return tuple___rmul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.tuple___rmul___doc) final PyObject tuple___rmul__(PyObject o) { if (!o.isIndex()) { return null; @@ -211,17 +211,17 @@ return tuple___iter__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.tuple___iter___doc) public PyObject tuple___iter__() { return new PyFastSequenceIter(this); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.tuple___getslice___doc) final PyObject tuple___getslice__(PyObject s_start, PyObject s_stop, PyObject s_step) { return seq___getslice__(s_start,s_stop,s_step); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.tuple___getitem___doc) final PyObject tuple___getitem__(PyObject index) { PyObject ret = seq___finditem__(index); if(ret == null) { @@ -230,7 +230,7 @@ return ret; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.tuple___getnewargs___doc) final PyTuple tuple___getnewargs__() { return new PyTuple(new PyTuple(list.getArray())); } @@ -243,7 +243,7 @@ return tuple___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.tuple___hash___doc) final int tuple___hash__() { // strengthened hash to avoid common collisions. from CPython // tupleobject.tuplehash. See http://bugs.python.org/issue942952 @@ -270,7 +270,7 @@ return tuple___repr__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.tuple___repr___doc) final String tuple___repr__() { StringBuilder buf = new StringBuilder("("); PyObject[] array = getArray(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-02 03:51:11
|
Revision: 5832 http://jython.svn.sourceforge.net/jython/?rev=5832&view=rev Author: fwierzbicki Date: 2009-01-02 03:51:08 +0000 (Fri, 02 Jan 2009) Log Message: ----------- __doc__ for long and enumerate Modified Paths: -------------- trunk/jython/src/org/python/core/PyEnumerate.java trunk/jython/src/org/python/core/PyLong.java Modified: trunk/jython/src/org/python/core/PyEnumerate.java =================================================================== --- trunk/jython/src/org/python/core/PyEnumerate.java 2009-01-02 03:27:32 UTC (rev 5831) +++ trunk/jython/src/org/python/core/PyEnumerate.java 2009-01-02 03:51:08 UTC (rev 5832) @@ -37,12 +37,12 @@ return enumerate_next(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.enumerate_next_doc) final PyObject enumerate_next() { return doNext(enumerate___iternext__()); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.enumerate___iter___doc) final PyObject enumerate___iter__() { return super.__iter__(); } Modified: trunk/jython/src/org/python/core/PyLong.java =================================================================== --- trunk/jython/src/org/python/core/PyLong.java 2009-01-02 03:27:32 UTC (rev 5831) +++ trunk/jython/src/org/python/core/PyLong.java 2009-01-02 03:51:08 UTC (rev 5832) @@ -118,7 +118,7 @@ return long_toString(); } - @ExposedMethod(names = {"__str__", "__repr__"}) + @ExposedMethod(names = {"__str__", "__repr__"}, doc = BuiltinDocs.long___str___doc) final String long_toString() { return value.toString()+"L"; } @@ -127,7 +127,7 @@ return long___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___hash___doc) final int long___hash__() { return value.intValue(); } @@ -136,7 +136,7 @@ return !value.equals(BigInteger.valueOf(0)); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___nonzero___doc) public boolean long___nonzero__() { return __nonzero__(); } @@ -248,7 +248,7 @@ return long___cmp__(other); } - @ExposedMethod(type = MethodType.CMP) + @ExposedMethod(type = MethodType.CMP, doc = BuiltinDocs.long___cmp___doc) final int long___cmp__(PyObject other) { if (!canCoerce(other)) return -2; @@ -259,7 +259,7 @@ return long___coerce_ex__(other); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___coerce___doc) final PyObject long___coerce__(PyObject other) { return adaptToCoerceTuple(long___coerce_ex__(other)); } @@ -297,7 +297,7 @@ return long___add__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___add___doc) final PyObject long___add__(PyObject right) { if (!canCoerce(right)) return null; @@ -308,7 +308,7 @@ return long___radd__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___radd___doc) final PyObject long___radd__(PyObject left) { return __add__(left); } @@ -317,7 +317,7 @@ return long___sub__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___sub___doc) final PyObject long___sub__(PyObject right) { if (!canCoerce(right)) return null; @@ -328,7 +328,7 @@ return long___rsub__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rsub___doc) final PyObject long___rsub__(PyObject left) { return Py.newLong(coerce(left).subtract(value)); } @@ -337,7 +337,7 @@ return long___mul__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___mul___doc) final PyObject long___mul__(PyObject right) { if (right instanceof PySequence) return ((PySequence) right).repeat(coerceInt(this)); @@ -351,7 +351,7 @@ return long___rmul__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rmul___doc) final PyObject long___rmul__(PyObject left) { if (left instanceof PySequence) return ((PySequence) left).repeat(coerceInt(this)); @@ -382,7 +382,7 @@ return long___div__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___div___doc) final PyObject long___div__(PyObject right) { if (!canCoerce(right)) return null; @@ -395,7 +395,7 @@ return long___rdiv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rdiv___doc) final PyObject long___rdiv__(PyObject left) { if (!canCoerce(left)) return null; @@ -408,7 +408,7 @@ return long___floordiv__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___floordiv___doc) final PyObject long___floordiv__(PyObject right) { if (!canCoerce(right)) return null; @@ -419,7 +419,7 @@ return long___rfloordiv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rfloordiv___doc) final PyObject long___rfloordiv__(PyObject left) { if (!canCoerce(left)) return null; @@ -458,7 +458,7 @@ return long___truediv__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___truediv___doc) final PyObject long___truediv__(PyObject right) { if (!canCoerce(right)) return null; @@ -469,7 +469,7 @@ return long___rtruediv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rtruediv___doc) final PyObject long___rtruediv__(PyObject left) { if (!canCoerce(left)) return null; @@ -484,7 +484,7 @@ return long___mod__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___mod___doc) final PyObject long___mod__(PyObject right) { if (!canCoerce(right)) return null; @@ -496,7 +496,7 @@ return long___rmod__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rmod___doc) final PyObject long___rmod__(PyObject left) { if (!canCoerce(left)) return null; @@ -508,7 +508,7 @@ return long___divmod__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___divmod___doc) final PyObject long___divmod__(PyObject right) { if (!canCoerce(right)) return null; @@ -522,7 +522,7 @@ return long___rdivmod__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rdivmod___doc) final PyObject long___rdivmod__(PyObject left) { if (!canCoerce(left)) return null; @@ -536,7 +536,7 @@ return long___pow__(right, modulo); } - @ExposedMethod(type = MethodType.BINARY, defaults = {"null"}) + @ExposedMethod(type = MethodType.BINARY, defaults = {"null"}, doc = BuiltinDocs.long___pow___doc) final PyObject long___pow__(PyObject right, PyObject modulo) { if (!canCoerce(right)) return null; @@ -550,7 +550,7 @@ return long___rpow__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rpow___doc) final PyObject long___rpow__(PyObject left) { if (!canCoerce(left)) return null; @@ -615,7 +615,7 @@ return long___lshift__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___lshift___doc) final PyObject long___lshift__(PyObject right) { if (!canCoerce(right)) return null; @@ -625,7 +625,7 @@ return Py.newLong(value.shiftLeft(rightv)); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rlshift___doc) final PyObject long___rlshift__(PyObject left) { if (!canCoerce(left)) return null; @@ -638,7 +638,7 @@ return long___rshift__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rshift___doc) final PyObject long___rshift__(PyObject right) { if (!canCoerce(right)) return null; @@ -648,7 +648,7 @@ return Py.newLong(value.shiftRight(rightv)); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rrshift___doc) final PyObject long___rrshift__(PyObject left) { if (!canCoerce(left)) return null; @@ -661,7 +661,7 @@ return long___and__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___and___doc) final PyObject long___and__(PyObject right) { if (!canCoerce(right)) return null; @@ -672,7 +672,7 @@ return long___rand__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rand___doc) final PyObject long___rand__(PyObject left) { if (!canCoerce(left)) return null; @@ -683,7 +683,7 @@ return long___xor__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___xor___doc) final PyObject long___xor__(PyObject right) { if (!canCoerce(right)) return null; @@ -694,7 +694,7 @@ return long___rxor__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___rxor___doc) final PyObject long___rxor__(PyObject left) { if (!canCoerce(left)) return null; @@ -705,7 +705,7 @@ return long___or__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___or___doc) final PyObject long___or__(PyObject right) { if (!canCoerce(right)) return null; @@ -716,7 +716,7 @@ return long___ror__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.long___ror___doc) final PyObject long___ror__(PyObject left) { if (!canCoerce(left)) return null; @@ -727,7 +727,7 @@ return long___neg__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___neg___doc) final PyObject long___neg__() { return Py.newLong(value.negate()); } @@ -736,7 +736,7 @@ return long___pos__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___pos___doc) final PyObject long___pos__() { return Py.newLong(value); } @@ -745,7 +745,7 @@ return long___abs__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___abs___doc) final PyObject long___abs__() { return Py.newLong(value.abs()); } @@ -754,7 +754,7 @@ return long___invert__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___invert___doc) final PyObject long___invert__() { return Py.newLong(value.not()); } @@ -763,7 +763,7 @@ return long___int__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___int___doc) final PyObject long___int__() { if (value.compareTo(PyInteger.maxInt) <= 0 && value.compareTo(PyInteger.minInt) >= 0) { return Py.newInteger(value.intValue()); @@ -776,7 +776,7 @@ return long___long__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___long___doc) final PyObject long___long__() { return Py.newLong(value); } @@ -785,7 +785,7 @@ return long___float__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___float___doc) final PyFloat long___float__() { return new PyFloat(doubleValue()); } @@ -802,7 +802,7 @@ return long___oct__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___oct___doc) final PyString long___oct__() { String s = value.toString(8); if (s.startsWith("-")) @@ -818,7 +818,7 @@ return long___hex__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___hex___doc) final PyString long___hex__() { String s = value.toString(16); if (s.startsWith("-")) @@ -835,7 +835,7 @@ return new PyUnicode(value.toString()); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___getnewargs___doc) final PyTuple long___getnewargs__() { return new PyTuple(new PyLong(this.getValue())); } @@ -849,7 +849,7 @@ return long___index__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.long___index___doc) final PyObject long___index__() { return this; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2009-01-02 03:27:37
|
Revision: 5831 http://jython.svn.sourceforge.net/jython/?rev=5831&view=rev Author: fwierzbicki Date: 2009-01-02 03:27:32 +0000 (Fri, 02 Jan 2009) Log Message: ----------- __doc__ for staticmethod and float Modified Paths: -------------- trunk/jython/src/org/python/core/PyFloat.java trunk/jython/src/org/python/core/PyStaticMethod.java Modified: trunk/jython/src/org/python/core/PyFloat.java =================================================================== --- trunk/jython/src/org/python/core/PyFloat.java 2009-01-01 22:32:02 UTC (rev 5830) +++ trunk/jython/src/org/python/core/PyFloat.java 2009-01-02 03:27:32 UTC (rev 5831) @@ -90,7 +90,7 @@ return float___str__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___str___doc) final PyString float___str__() { return Py.newString(formatDouble(PREC_STR)); } @@ -99,7 +99,7 @@ return float___repr__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___repr___doc) final PyString float___repr__() { return Py.newString(formatDouble(PREC_REPR)); } @@ -131,7 +131,7 @@ return float___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___hash___doc) final int float___hash__() { double intPart = Math.floor(value); double fractPart = value-intPart; @@ -151,7 +151,7 @@ return float___nonzero__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___nonzero___doc) final boolean float___nonzero__() { return value != 0; } @@ -188,6 +188,7 @@ return float___cmp__(other); } + //XXX: needs __doc__ @ExposedMethod(type = MethodType.CMP) final int float___cmp__(PyObject other) { double i = value; @@ -230,7 +231,7 @@ return float___coerce_ex__(other); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___coerce___doc) final PyObject float___coerce__(PyObject other) { return adaptToCoerceTuple(float___coerce_ex__(other)); } @@ -272,7 +273,7 @@ return float___add__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___add___doc) final PyObject float___add__(PyObject right) { if (!canCoerce(right)) return null; @@ -284,7 +285,7 @@ return float___radd__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___radd___doc) final PyObject float___radd__(PyObject left) { return __add__(left); } @@ -293,7 +294,7 @@ return float___sub__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___sub___doc) final PyObject float___sub__(PyObject right) { if (!canCoerce(right)) return null; @@ -305,7 +306,7 @@ return float___rsub__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rsub___doc) final PyObject float___rsub__(PyObject left) { if (!canCoerce(left)) return null; @@ -317,7 +318,7 @@ return float___mul__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___mul___doc) final PyObject float___mul__(PyObject right) { if (!canCoerce(right)) return null; @@ -329,7 +330,7 @@ return float___rmul__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rmul___doc) final PyObject float___rmul__(PyObject left) { return __mul__(left); } @@ -338,7 +339,7 @@ return float___div__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___div___doc) final PyObject float___div__(PyObject right) { if (!canCoerce(right)) return null; @@ -354,7 +355,7 @@ return float___rdiv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rdiv___doc) final PyObject float___rdiv__(PyObject left) { if (!canCoerce(left)) return null; @@ -370,7 +371,7 @@ return float___floordiv__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___floordiv___doc) final PyObject float___floordiv__(PyObject right) { if (!canCoerce(right)) return null; @@ -384,7 +385,7 @@ return float___rfloordiv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rfloordiv___doc) final PyObject float___rfloordiv__(PyObject left) { if (!canCoerce(left)) return null; @@ -398,7 +399,7 @@ return float___truediv__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___truediv___doc) final PyObject float___truediv__(PyObject right) { if (!canCoerce(right)) return null; @@ -412,7 +413,7 @@ return float___rtruediv__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rtruediv___doc) final PyObject float___rtruediv__(PyObject left) { if (!canCoerce(left)) return null; @@ -435,7 +436,7 @@ return float___mod__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___mod___doc) final PyObject float___mod__(PyObject right) { if (!canCoerce(right)) return null; @@ -447,7 +448,7 @@ return float___rmod__(left); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rmod___doc) final PyObject float___rmod__(PyObject left) { if (!canCoerce(left)) return null; @@ -459,7 +460,7 @@ return float___divmod__(right); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___divmod___doc) final PyObject float___divmod__(PyObject right) { if (!canCoerce(right)) return null; @@ -484,7 +485,7 @@ return new PyTuple(new PyFloat(z), new PyFloat(leftv - z * value)); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rdivmod___doc) final PyObject float___rdivmod__(PyObject left) { return __rdivmod__(left); } @@ -494,7 +495,7 @@ return float___pow__(right, modulo); } - @ExposedMethod(type = MethodType.BINARY, defaults = "null") + @ExposedMethod(type = MethodType.BINARY, defaults = "null", doc = BuiltinDocs.float___pow___doc) final PyObject float___pow__(PyObject right, PyObject modulo) { if (!canCoerce(right)) return null; @@ -507,7 +508,7 @@ return _pow(value, coerce(right), modulo); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.float___rpow___doc) final PyObject float___rpow__(PyObject left) { return __rpow__(left); } @@ -548,7 +549,7 @@ return float___neg__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___neg___doc) final PyObject float___neg__() { return new PyFloat(-value); } @@ -557,7 +558,7 @@ return float___pos__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___pos___doc) final PyObject float___pos__() { return Py.newFloat(value); } @@ -570,7 +571,7 @@ return float___abs__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___abs___doc) final PyObject float___abs__() { if (value >= 0) return Py.newFloat(value); @@ -582,7 +583,7 @@ return float___int__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___int___doc) final PyObject float___int__() { if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) { return new PyInteger((int)value); @@ -594,7 +595,7 @@ return float___long__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___long___doc) final PyObject float___long__() { return new PyLong(value); } @@ -603,7 +604,7 @@ return float___float__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___float___doc) final PyFloat float___float__() { return Py.newFloat(value); } @@ -611,7 +612,7 @@ return new PyComplex(value, 0.); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.float___getnewargs___doc) final PyTuple float___getnewargs__() { return new PyTuple(new PyObject[] {new PyFloat(getValue())}); } Modified: trunk/jython/src/org/python/core/PyStaticMethod.java =================================================================== --- trunk/jython/src/org/python/core/PyStaticMethod.java 2009-01-01 22:32:02 UTC (rev 5830) +++ trunk/jython/src/org/python/core/PyStaticMethod.java 2009-01-02 03:27:32 UTC (rev 5831) @@ -34,7 +34,7 @@ return staticmethod___get__(obj, type); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.staticmethod___get___doc) final PyObject staticmethod___get__(PyObject obj, PyObject type) { return callable; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-01 22:32:08
|
Revision: 5830 http://jython.svn.sourceforge.net/jython/?rev=5830&view=rev Author: cgroves Date: 2009-01-01 22:32:02 +0000 (Thu, 01 Jan 2009) Log Message: ----------- test260,264 - Testing jythonc; deleted test261,262 - Tested by test_import test263 - Tested by test_cpickle test265 - Tested by test_java_integration test266 - Tested by test_socket test268,269,270 - Moved to test_java_visibility Modified Paths: -------------- trunk/jython/Lib/test/test_classpathimporter.py trunk/jython/Lib/test/test_java_integration.py trunk/jython/Lib/test/test_java_visibility.py trunk/jython/Lib/test/test_support.py trunk/jython/bugtests/test275s.py trunk/jython/build.xml trunk/jython/src/org/python/antlr/ast/AssertDerived.java trunk/jython/src/org/python/antlr/ast/AssignDerived.java trunk/jython/src/org/python/antlr/ast/AttributeDerived.java trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java trunk/jython/src/org/python/antlr/ast/BinOpDerived.java trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java trunk/jython/src/org/python/antlr/ast/BreakDerived.java trunk/jython/src/org/python/antlr/ast/CallDerived.java trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java trunk/jython/src/org/python/antlr/ast/CompareDerived.java trunk/jython/src/org/python/antlr/ast/ContinueDerived.java trunk/jython/src/org/python/antlr/ast/DeleteDerived.java trunk/jython/src/org/python/antlr/ast/DictDerived.java trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java trunk/jython/src/org/python/antlr/ast/ExecDerived.java trunk/jython/src/org/python/antlr/ast/ExprDerived.java trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java trunk/jython/src/org/python/antlr/ast/ForDerived.java trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java trunk/jython/src/org/python/antlr/ast/GlobalDerived.java trunk/jython/src/org/python/antlr/ast/IfDerived.java trunk/jython/src/org/python/antlr/ast/IfExpDerived.java trunk/jython/src/org/python/antlr/ast/ImportDerived.java trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java trunk/jython/src/org/python/antlr/ast/IndexDerived.java trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java trunk/jython/src/org/python/antlr/ast/LambdaDerived.java trunk/jython/src/org/python/antlr/ast/ListCompDerived.java trunk/jython/src/org/python/antlr/ast/ListDerived.java trunk/jython/src/org/python/antlr/ast/ModuleDerived.java trunk/jython/src/org/python/antlr/ast/NameDerived.java trunk/jython/src/org/python/antlr/ast/NumDerived.java trunk/jython/src/org/python/antlr/ast/PassDerived.java trunk/jython/src/org/python/antlr/ast/PrintDerived.java trunk/jython/src/org/python/antlr/ast/RaiseDerived.java trunk/jython/src/org/python/antlr/ast/ReprDerived.java trunk/jython/src/org/python/antlr/ast/ReturnDerived.java trunk/jython/src/org/python/antlr/ast/SliceDerived.java trunk/jython/src/org/python/antlr/ast/StrDerived.java trunk/jython/src/org/python/antlr/ast/SubscriptDerived.java trunk/jython/src/org/python/antlr/ast/SuiteDerived.java trunk/jython/src/org/python/antlr/ast/TryExceptDerived.java trunk/jython/src/org/python/antlr/ast/TryFinallyDerived.java trunk/jython/src/org/python/antlr/ast/TupleDerived.java trunk/jython/src/org/python/antlr/ast/UnaryOpDerived.java trunk/jython/src/org/python/antlr/ast/WhileDerived.java trunk/jython/src/org/python/antlr/ast/WithDerived.java trunk/jython/src/org/python/antlr/ast/YieldDerived.java trunk/jython/src/org/python/antlr/ast/aliasDerived.java trunk/jython/src/org/python/antlr/ast/argumentsDerived.java trunk/jython/src/org/python/antlr/ast/comprehensionDerived.java trunk/jython/src/org/python/antlr/ast/keywordDerived.java trunk/jython/src/org/python/antlr/op/AddDerived.java trunk/jython/src/org/python/antlr/op/AndDerived.java trunk/jython/src/org/python/antlr/op/AugLoadDerived.java trunk/jython/src/org/python/antlr/op/AugStoreDerived.java trunk/jython/src/org/python/antlr/op/BitAndDerived.java trunk/jython/src/org/python/antlr/op/BitOrDerived.java trunk/jython/src/org/python/antlr/op/BitXorDerived.java trunk/jython/src/org/python/antlr/op/DelDerived.java trunk/jython/src/org/python/antlr/op/DivDerived.java trunk/jython/src/org/python/antlr/op/EqDerived.java trunk/jython/src/org/python/antlr/op/FloorDivDerived.java trunk/jython/src/org/python/antlr/op/GtDerived.java trunk/jython/src/org/python/antlr/op/GtEDerived.java trunk/jython/src/org/python/antlr/op/InDerived.java trunk/jython/src/org/python/antlr/op/InvertDerived.java trunk/jython/src/org/python/antlr/op/IsDerived.java trunk/jython/src/org/python/antlr/op/IsNotDerived.java trunk/jython/src/org/python/antlr/op/LShiftDerived.java trunk/jython/src/org/python/antlr/op/LoadDerived.java trunk/jython/src/org/python/antlr/op/LtDerived.java trunk/jython/src/org/python/antlr/op/LtEDerived.java trunk/jython/src/org/python/antlr/op/ModDerived.java trunk/jython/src/org/python/antlr/op/MultDerived.java trunk/jython/src/org/python/antlr/op/NotDerived.java trunk/jython/src/org/python/antlr/op/NotEqDerived.java trunk/jython/src/org/python/antlr/op/NotInDerived.java trunk/jython/src/org/python/antlr/op/OrDerived.java trunk/jython/src/org/python/antlr/op/ParamDerived.java trunk/jython/src/org/python/antlr/op/PowDerived.java trunk/jython/src/org/python/antlr/op/RShiftDerived.java trunk/jython/src/org/python/antlr/op/StoreDerived.java trunk/jython/src/org/python/antlr/op/SubDerived.java trunk/jython/src/org/python/antlr/op/UAddDerived.java trunk/jython/src/org/python/antlr/op/USubDerived.java trunk/jython/src/org/python/core/ClasspathPyImporterDerived.java trunk/jython/src/org/python/core/PyArrayDerived.java trunk/jython/src/org/python/core/PyBaseExceptionDerived.java trunk/jython/src/org/python/core/PyBooleanDerived.java trunk/jython/src/org/python/core/PyClassMethodDerived.java trunk/jython/src/org/python/core/PyComplexDerived.java trunk/jython/src/org/python/core/PyDictionaryDerived.java trunk/jython/src/org/python/core/PyEnumerateDerived.java trunk/jython/src/org/python/core/PyFileDerived.java trunk/jython/src/org/python/core/PyFloatDerived.java trunk/jython/src/org/python/core/PyFrozenSetDerived.java trunk/jython/src/org/python/core/PyIntegerDerived.java trunk/jython/src/org/python/core/PyListDerived.java trunk/jython/src/org/python/core/PyLongDerived.java trunk/jython/src/org/python/core/PyModuleDerived.java trunk/jython/src/org/python/core/PyObjectDerived.java trunk/jython/src/org/python/core/PyPropertyDerived.java trunk/jython/src/org/python/core/PySetDerived.java trunk/jython/src/org/python/core/PySliceDerived.java trunk/jython/src/org/python/core/PyStringDerived.java trunk/jython/src/org/python/core/PySuperDerived.java trunk/jython/src/org/python/core/PyTupleDerived.java trunk/jython/src/org/python/core/PyTypeDerived.java trunk/jython/src/org/python/core/PyUnicodeDerived.java trunk/jython/src/org/python/modules/_collections/PyDefaultDictDerived.java trunk/jython/src/org/python/modules/_collections/PyDequeDerived.java trunk/jython/src/org/python/modules/_csv/PyDialectDerived.java trunk/jython/src/org/python/modules/_functools/PyPartialDerived.java trunk/jython/src/org/python/modules/_weakref/ReferenceTypeDerived.java trunk/jython/src/org/python/modules/random/PyRandomDerived.java trunk/jython/src/org/python/modules/thread/PyLocalDerived.java trunk/jython/src/org/python/modules/zipimport/zipimporterDerived.java trunk/jython/src/templates/gderived-defs trunk/jython/src/templates/gderived.py trunk/jython/src/templates/object.derived trunk/jython/tests/java/org/python/tests/Coercions.java Removed Paths: ------------- trunk/jython/bugtests/test260.py trunk/jython/bugtests/test261.py trunk/jython/bugtests/test261p/ trunk/jython/bugtests/test262.py trunk/jython/bugtests/test262m.py trunk/jython/bugtests/test262p/ trunk/jython/bugtests/test263.py trunk/jython/bugtests/test263m.py trunk/jython/bugtests/test264.py trunk/jython/bugtests/test264c.py trunk/jython/bugtests/test265.py trunk/jython/bugtests/test265j.java trunk/jython/bugtests/test266.py trunk/jython/bugtests/test268.py trunk/jython/bugtests/test268j1.java trunk/jython/bugtests/test268j2.java trunk/jython/bugtests/test269.py trunk/jython/bugtests/test269p/ trunk/jython/bugtests/test270.py trunk/jython/bugtests/test270p/ trunk/jython/bugtests/test271.py trunk/jython/bugtests/test272.py trunk/jython/bugtests/test272c.py trunk/jython/bugtests/test273.py trunk/jython/bugtests/test273p/ trunk/jython/bugtests/test274.py trunk/jython/bugtests/test276.py trunk/jython/bugtests/test276j.java Modified: trunk/jython/Lib/test/test_classpathimporter.py =================================================================== --- trunk/jython/Lib/test/test_classpathimporter.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/Lib/test/test_classpathimporter.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,9 +1,7 @@ import unittest import sys from test import test_support -from java.io import File from java.lang import Thread -from java.net import URLClassLoader class ClasspathImporterTestCase(unittest.TestCase): def setUp(self): @@ -21,8 +19,7 @@ pass def setClassLoaderAndCheck(self, jar): - url = File(test_support.findfile(jar)).toURL() - Thread.currentThread().contextClassLoader = URLClassLoader([url]) + Thread.currentThread().contextClassLoader = test_support.make_jar_classloader(jar) import flat_in_jar self.assertEquals(flat_in_jar.value, 7) import jar_pkg Modified: trunk/jython/Lib/test/test_java_integration.py =================================================================== --- trunk/jython/Lib/test/test_java_integration.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/Lib/test/test_java_integration.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -8,7 +8,7 @@ from java.util import ArrayList, HashMap, Hashtable, StringTokenizer, Vector from java.io import FileOutputStream, FileWriter, OutputStreamWriter -from java.lang import (Boolean, ClassLoader, ExceptionInInitializerError, Integer, Object, String, +from java.lang import (Boolean, Class, ClassLoader, ExceptionInInitializerError, Integer, Object, String, Runnable, Thread, ThreadGroup, System, Runtime, Math, Byte) from javax.swing.table import AbstractTableModel from javax.swing.tree import TreePath @@ -93,10 +93,13 @@ def test_can_subclass_abstract(self): import ContextAbstract + called = [] class A(ContextAbstract): def method(self): - pass + called.append(True) A() + Class.newInstance(A) + self.assertEquals(len(called), 2) class InstantiationTest(unittest.TestCase): def test_can_subclass_abstract(self): @@ -151,16 +154,20 @@ pass class SysIntegrationTest(unittest.TestCase): + def setUp(self): + self.orig_stdout = sys.stdout + + def tearDown(self): + sys.stdout = self.orig_stdout + def test_stdout_outputstream(self): out = FileOutputStream(test_support.TESTFN) - oldstdout = sys.stdout sys.stdout = out print 'hello', out.close() f = open(test_support.TESTFN) self.assertEquals('hello', f.read()) f.close() - sys.stdout = out class AutoSuperTest(unittest.TestCase): def test_auto_super(self): Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/Lib/test/test_java_visibility.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -167,6 +167,18 @@ self.assertEquals("OtherSubVisible[]", c.takeArray([OtherSubVisible()])) self.assertEquals("SubVisible[]", c.takeArray([SubVisible()])) + def test_class_coercion(self): + c = Coercions() + from java.util import Hashtable, HashMap + ht = Hashtable() + hm = HashMap() + ht['one'] = 'uno' + hm['zwei'] = 'two' + for obj, cls in ((ht, "java.util.Hashtable"), (hm, "java.util.HashMap"), ("abc", "java.lang.String"), + (1, "java.lang.Integer"), (1.2, "java.lang.Double"), (Hashtable, "java.lang.Class")): + self.assertEquals(c.tellClassNameSerializable(obj), "class " + cls) + self.assertEquals(c.tellClassNameObject(ht), "class java.util.Hashtable") + class RespectJavaAccessibilityTest(unittest.TestCase): def run_accessibility_script(self, script, error=AttributeError): fn = test_support.findfile(script) @@ -184,11 +196,23 @@ def test_protected_class(self): self.run_accessibility_script("access_protected_class.py", TypeError) +class ClassloaderTest(unittest.TestCase): + def test_loading_classes_without_import(self): + cl = test_support.make_jar_classloader("../callbacker_test.jar") + X = cl.loadClass("org.python.tests.Callbacker") + called = [] + class Blah(X.Callback): + def call(self, arg=None): + called.append(arg) + X().callNoArg(Blah()) + self.assertEquals(None, called[0]) + def test_main(): test_support.run_unittest(VisibilityTest, JavaClassTest, CoercionTest, - RespectJavaAccessibilityTest) +# RespectJavaAccessibilityTest, + ClassloaderTest) if __name__ == "__main__": test_main() Modified: trunk/jython/Lib/test/test_support.py =================================================================== --- trunk/jython/Lib/test/test_support.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/Lib/test/test_support.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -145,6 +145,12 @@ have_unicode = 0 is_jython = sys.platform.startswith('java') +if is_jython: + def make_jar_classloader(jar): + from java.io import File + from java.net import URLClassLoader + url = File(findfile(jar)).toURL() + return URLClassLoader([url]) import os # Filename used for testing Deleted: trunk/jython/bugtests/test260.py =================================================================== --- trunk/jython/bugtests/test260.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test260.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,46 +0,0 @@ -""" - -""" - -import support - - -f = open("test260s1.py", "w") -f.write(""" - -import java -class test260s1(java.util.Vector): - def foo(self): - pass - -class P(java.awt.Panel): - pass - -class foo: - pass - -""") -f.close() - -support.compileJPythonc("test260s1.py", output="test260.err") - - - -import os -os.remove("test260s1.py") - -import sys, types -sys.path[:0] = ['jpywork'] - -import test260s1 - -#print dir(test260s1) -#print test260s1.P, type(test260s1.P) -#print test260s1.foo, type(test260s1.foo) - -del sys.path[0] - -if not hasattr(test260s1, "foo"): - raise support.TestWarning("the python class should also be visible as a module attribute"); - - Deleted: trunk/jython/bugtests/test261.py =================================================================== --- trunk/jython/bugtests/test261.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test261.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,2 +0,0 @@ -import test261p.ccs.util.Test - Deleted: trunk/jython/bugtests/test262.py =================================================================== --- trunk/jython/bugtests/test262.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test262.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,2 +0,0 @@ -import test262m - Deleted: trunk/jython/bugtests/test262m.py =================================================================== --- trunk/jython/bugtests/test262m.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test262m.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,4 +0,0 @@ -import test262p.x - -assert __name__ == "test262m" - Deleted: trunk/jython/bugtests/test263.py =================================================================== --- trunk/jython/bugtests/test263.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test263.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,14 +0,0 @@ - -import cPickle, sys -import test263m - -a = test263m.A() -b = test263m.B() - - -s = cPickle.dumps([a, b]) - -del sys.modules['test263m'] -del test263m - -cPickle.loads(s) Deleted: trunk/jython/bugtests/test263m.py =================================================================== --- trunk/jython/bugtests/test263m.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test263m.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,7 +0,0 @@ - -class A: - pass - -class B(A): - pass - Deleted: trunk/jython/bugtests/test264.py =================================================================== --- trunk/jython/bugtests/test264.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test264.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,9 +0,0 @@ -""" - -""" - -import support - -support.compileJPythonc("test264c.py", core=1, deep=1, jar="test264c.jar", output="test264.err") - -#raise support.TestError("" + `x`) Deleted: trunk/jython/bugtests/test264c.py =================================================================== --- trunk/jython/bugtests/test264c.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test264c.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,8 +0,0 @@ - -import ucnhash -import encodings -import encodings.unicode_escape - - -s = unicode("\N{SPACE} \N{EURO SIGN}", "unicode-escape") - Deleted: trunk/jython/bugtests/test265.py =================================================================== --- trunk/jython/bugtests/test265.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test265.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,19 +0,0 @@ -""" - -""" - -import support - -support.compileJava("test265j.java") - -import test265j - -try: - test265j() -except TypeError: - pass -else: - raise support.TestError("expected a TypeError (abstract java class)") - - - Deleted: trunk/jython/bugtests/test265j.java =================================================================== --- trunk/jython/bugtests/test265j.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test265j.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,7 +0,0 @@ - -public abstract class test265j { - - public test265j() { - System.out.println("test265j ctor"); - } -} Deleted: trunk/jython/bugtests/test266.py =================================================================== --- trunk/jython/bugtests/test266.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test266.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,43 +0,0 @@ - -import socket -import thread -import time - - -def server(): - HOST = '' # Symbolic name meaning the local host - PORT = 50007 # Arbitrary non-privileged port - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.bind((HOST, PORT)) - #print "server listen", s - s.listen(1) - #print "server accept", s - conn, addr = s.accept() - #print 'Connected by', addr - while 1: - data = conn.recv(1024) - if not data: break - conn.send(data) - conn.close() - - -def client(): - HOST = '127.0.0.1' # The remote host - PORT = 50007 # The same port as used by the server - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - #print "client connect", s - s.connect((HOST, PORT)) - #print "client send" - s.send('Hello, world') - f = s.makefile() - s.close() - data = f.read(12) - f.close() - #print 'Received', `data` - - - -thread.start_new_thread(server, ()) -time.sleep(5) -client() - Deleted: trunk/jython/bugtests/test268.py =================================================================== --- trunk/jython/bugtests/test268.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test268.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,18 +0,0 @@ -import support - -support.compileJava("test268j2.java", classpath=".") - - -from java import net, lang -clu=net.URL(r'file:%s/' % lang.System.getProperty("user.dir")) -ld1=net.URLClassLoader([clu]) -X=ld1.loadClass("test268j1") -Y=ld1.loadClass("test268j2") -Y.printX(X()) - -import test268j1 -import test268j2 - -#import org -#print "First dump" -#org.python.core.PyJavaClass.dump() Deleted: trunk/jython/bugtests/test268j1.java =================================================================== --- trunk/jython/bugtests/test268j1.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test268j1.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,4 +0,0 @@ - -public class test268j1 { - public int value=6; -} \ No newline at end of file Deleted: trunk/jython/bugtests/test268j2.java =================================================================== --- trunk/jython/bugtests/test268j2.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test268j2.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +0,0 @@ - -public class test268j2 { - public static void printX(test268j1 x) { - ; - } -} Deleted: trunk/jython/bugtests/test269.py =================================================================== --- trunk/jython/bugtests/test269.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test269.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,18 +0,0 @@ - -import support - -support.compileJava("test269p/test269j2.java", classpath=".") - -from java import net, lang -clu=net.URL(r'file:%s/' % lang.System.getProperty("user.dir")) -ld1=net.URLClassLoader([clu]) -X=ld1.loadClass("test269p.test269j1") -Y=ld1.loadClass("test269p.test269j2") -Y.printX(X()) - -from test269p import * -test269j2.printX(test269j1()) - -#import org -#print "Second dump" -#org.python.core.PyJavaClass.dumpDebug() Deleted: trunk/jython/bugtests/test270.py =================================================================== --- trunk/jython/bugtests/test270.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test270.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,18 +0,0 @@ - -import support - -support.compileJava("test270p/test270j2.java", classpath=".") - -from test270p import * -test270j2.printX(test270j1()) - - -from java import net, lang -clu=net.URL(r'file:%s/' % lang.System.getProperty("user.dir")) -ld1=net.URLClassLoader([clu]) -X=ld1.loadClass("test270p.test270j1") -Y=ld1.loadClass("test270p.test270j2") -Y.printX(X()) - -#import org -#org.python.core.PyJavaClass.dumpDebug() Deleted: trunk/jython/bugtests/test271.py =================================================================== --- trunk/jython/bugtests/test271.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test271.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,14 +0,0 @@ - -def f1(): - l = [x for x in "abcdef"] - assert str(l) == "['a', 'b', 'c', 'd', 'e', 'f']" - -qs = "x.html&a=1&b=2;c=3" - -def f2(): - pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')] - assert str(pairs) == "['x.html', 'a=1', 'b=2', 'c=3']" - -f1() -f2() - Deleted: trunk/jython/bugtests/test272.py =================================================================== --- trunk/jython/bugtests/test272.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test272.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,9 +0,0 @@ -""" - -""" - -import support - -support.compileJPythonc("test272c.py", core=1, jar="test27c.jar", output="test272.err") - -#raise support.TestError("" + `x`) Deleted: trunk/jython/bugtests/test272c.py =================================================================== --- trunk/jython/bugtests/test272c.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test272c.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,7 +0,0 @@ - -from javax import swing - -class Doc(swing.text.PlainDocument): - def getEndPosition(self): - return None - Deleted: trunk/jython/bugtests/test273.py =================================================================== --- trunk/jython/bugtests/test273.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test273.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,37 +0,0 @@ -""" - -""" - -import support - -src = """ -package com; -public class Blob { - int value = %d; -} -""" - -def makeBlob(value): - f = open("test273p/com/Blob.java", "w") - f.write(src % value); - f.close(); - - support.compileJava(r"test273p/com/Blob.java") - support.compileJava(r"test273p/com/BlobWriter.java", classpath="test273p") - -makeBlob(1) - -import jreload -XLS = jreload.makeLoadSet("XLS",['test273p']) - -from XLS import com - -v = com.BlobWriter.write(com.Blob()) -support.compare(v, "1") - -makeBlob(2) - -jreload.reload(XLS) - -v = com.BlobWriter.write(com.Blob()) -support.compare(v, "2") Deleted: trunk/jython/bugtests/test274.py =================================================================== --- trunk/jython/bugtests/test274.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test274.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,25 +0,0 @@ -""" - -""" - -import support - -import shutil, os - -if os.path.isdir("test274d"): - shutil.rmtree("test274d", 1) -if os.path.isdir("test274d1"): - shutil.rmtree("test274d1", 1) - -os.mkdir("test274d") -open("test274d/file", "w").close() - -#os.utime = os.chmod = lambda f, t: None - -shutil.copytree("test274d", "test274d1") - -open("test274d1/file", "r").close() - -shutil.rmtree("test274d", 1) -shutil.rmtree("test274d1", 1) - Modified: trunk/jython/bugtests/test275s.py =================================================================== --- trunk/jython/bugtests/test275s.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test275s.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -2,9 +2,6 @@ """ -import support - - try: [i for i in range(10)] = (1, 2, 3) except SyntaxError: Deleted: trunk/jython/bugtests/test276.py =================================================================== --- trunk/jython/bugtests/test276.py 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test276.py 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,35 +0,0 @@ -""" - -""" - -import support - -support.compileJava("test276j.java") - -from java.util import * -import test276j - -h = Hashtable() - -h.put("uno", "one") -h.put("zwei", "two") - -tmm = test276j() - -tmm.TellMeMoreO(h) -support.compare(tmm.getClassName(), "java.util.Hashtable") - -tmm.TellMeMoreS(h) -support.compare(tmm.getClassName(), "java.util.Hashtable") - -tmm.TellMeMoreS("abc") -support.compare(tmm.getClassName(), "java.lang.String") - -tmm.TellMeMoreS(1) -support.compare(tmm.getClassName(), "java.lang.Integer") - -tmm.TellMeMoreS(1.2) -support.compare(tmm.getClassName(), "java.lang.Double") - -tmm.TellMeMoreS(Hashtable) -support.compare(tmm.getClassName(), "java.lang.Class") Deleted: trunk/jython/bugtests/test276j.java =================================================================== --- trunk/jython/bugtests/test276j.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/bugtests/test276j.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,18 +0,0 @@ -import java.io.*; -import java.util.*; - -public class test276j { - Object o; - - public void TellMeMoreS(Serializable o) { - this.o = o; - } - - public void TellMeMoreO(Object o) { - this.o = o; - } - - public String getClassName() { - return o.getClass().getName(); - } -} Modified: trunk/jython/build.xml =================================================================== --- trunk/jython/build.xml 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/build.xml 2009-01-01 22:32:02 UTC (rev 5830) @@ -564,6 +564,9 @@ <pathelement path="${compile.dir}" /> </classpath> </typedef> + <jar destfile="${dist.dir}/callbacker_test.jar"> + <fileset dir="${compile.dir}" includes="org/python/tests/Callbacker*"/> + </jar> <jar destfile="${dist.dir}/jython.jar" duplicate="fail"> <nameunion> <fileset dir="${exposed.dir}"/> Modified: trunk/jython/src/org/python/antlr/ast/AssertDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/AssertDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class AssertDerived extends Assert implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/AssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/AssignDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class AssignDerived extends Assign implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/AttributeDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/AttributeDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class AttributeDerived extends Attribute implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/AugAssignDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class AugAssignDerived extends AugAssign implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/BinOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/BinOpDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class BinOpDerived extends BinOp implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/BoolOpDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class BoolOpDerived extends BoolOp implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/BreakDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/BreakDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class BreakDerived extends Break implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/CallDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/CallDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class CallDerived extends Call implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ClassDefDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ClassDefDerived extends ClassDef implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/CompareDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/CompareDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class CompareDerived extends Compare implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ContinueDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ContinueDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ContinueDerived extends Continue implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/DeleteDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/DeleteDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class DeleteDerived extends Delete implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/DictDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/DictDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class DictDerived extends Dict implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/EllipsisDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class EllipsisDerived extends Ellipsis implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ExceptHandlerDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ExceptHandlerDerived extends ExceptHandler implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ExecDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ExecDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ExecDerived extends Exec implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ExprDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ExprDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ExprDerived extends Expr implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ExpressionDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ExpressionDerived extends Expression implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ExtSliceDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ExtSliceDerived extends ExtSlice implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ForDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ForDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ForDerived extends For implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/FunctionDefDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class FunctionDefDerived extends FunctionDef implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/GeneratorExpDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class GeneratorExpDerived extends GeneratorExp implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/GlobalDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/GlobalDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class GlobalDerived extends Global implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/IfDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/IfDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class IfDerived extends If implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/IfExpDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/IfExpDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class IfExpDerived extends IfExp implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ImportDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ImportDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ImportDerived extends Import implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/ImportFromDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class ImportFromDerived extends ImportFrom implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/IndexDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/IndexDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/IndexDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class IndexDerived extends Index implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/InteractiveDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class InteractiveDerived extends Interactive implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk/jython/src/org/python/antlr/ast/LambdaDerived.java =================================================================== --- trunk/jython/src/org/python/antlr/ast/LambdaDerived.java 2009-01-01 21:52:35 UTC (rev 5829) +++ trunk/jython/src/org/python/antlr/ast/LambdaDerived.java 2009-01-01 22:32:02 UTC (rev 5830) @@ -1,6 +1,7 @@ /* Generated file, do not modify. See jython/src/templates/gderived.py. */ package org.python.antlr.ast; +import java.io.Serializable; import org.python.core.*; public class LambdaDerived extends Lambda implements Slotted { @@ -1122,7 +1123,7 @@ // specified class. Without this, derived.__tojava__(PyObject.class) // would broke. (And that's not pure speculation: PyReflectedFunction's // ReflectedArgs asks for things like that). - if ((c!=Object.class)&&(c.isInstance(this))) { + if ((c!=Object.class)&&(c!=Serializable.class)&&(c.isInstance(this))) { return this; } // Otherwise, we call the derived __tojava__, if it exists: Modified: trunk... [truncated message content] |
From: <fwi...@us...> - 2009-01-01 22:18:16
|
Revision: 5829 http://jython.svn.sourceforge.net/jython/?rev=5829&view=rev Author: fwierzbicki Date: 2009-01-01 21:52:35 +0000 (Thu, 01 Jan 2009) Log Message: ----------- Some __doc__ for super, slice, and list. Modified Paths: -------------- trunk/jython/src/org/python/core/PyList.java trunk/jython/src/org/python/core/PySlice.java trunk/jython/src/org/python/core/PySuper.java Modified: trunk/jython/src/org/python/core/PyList.java =================================================================== --- trunk/jython/src/org/python/core/PyList.java 2009-01-01 01:13:50 UTC (rev 5828) +++ trunk/jython/src/org/python/core/PyList.java 2009-01-01 21:52:35 UTC (rev 5829) @@ -62,7 +62,7 @@ } @ExposedNew - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list___init___doc) final void list___init__(PyObject[] args, String[] kwds) { ArgParser ap = new ArgParser("list", args, kwds, new String[] {"sequence"}, 0); PyObject seq = ap.getPyObject(0, null); @@ -84,7 +84,7 @@ return list___len__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list___len___doc) final int list___len__() { return size(); } @@ -206,32 +206,32 @@ return new PyList(newArray); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___ne___doc) final PyObject list___ne__(PyObject o) { return seq___ne__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___eq___doc) final PyObject list___eq__(PyObject o) { return seq___eq__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___lt___doc) final PyObject list___lt__(PyObject o) { return seq___lt__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___le___doc) final PyObject list___le__(PyObject o) { return seq___le__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___gt___doc) final PyObject list___gt__(PyObject o) { return seq___gt__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___ge___doc) final PyObject list___ge__(PyObject o) { return seq___ge__(o); } @@ -240,7 +240,7 @@ return list___imul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___imul___doc) final PyObject list___imul__(PyObject o) { if (!o.isIndex()) { return null; @@ -276,7 +276,7 @@ return list___mul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___mul___doc) final PyObject list___mul__(PyObject o) { if (!o.isIndex()) { return null; @@ -289,7 +289,7 @@ return list___rmul__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___rmul___doc) final PyObject list___rmul__(PyObject o) { if (!o.isIndex()) { return null; @@ -301,7 +301,7 @@ return list___add__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___add___doc) final PyObject list___add__(PyObject o) { PyList sum = null; if(o instanceof PyList) { @@ -331,6 +331,7 @@ return list___radd__(o); } + //XXX: needs __doc__ @ExposedMethod(type = MethodType.BINARY) final PyObject list___radd__(PyObject o) { // Support adding java.util.List, but prevent adding PyTuple. @@ -348,22 +349,22 @@ return sum; } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list___contains___doc) final boolean list___contains__(PyObject o) { return object___contains__(o); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list___delitem___doc) final void list___delitem__(PyObject index) { seq___delitem__(index); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list___setitem___doc) final void list___setitem__(PyObject o, PyObject def) { seq___setitem__(o, def); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list___getitem___doc) final PyObject list___getitem__(PyObject o) { PyObject ret = seq___finditem__(o); if(ret == null) { @@ -376,22 +377,22 @@ return list___iter__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list___iter___doc) public PyObject list___iter__() { return new PyFastSequenceIter(this); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.list___getslice___doc) final PyObject list___getslice__(PyObject start, PyObject stop, PyObject step) { return seq___getslice__(start, stop, step); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.list___setslice___doc) final void list___setslice__(PyObject start, PyObject stop, PyObject step, PyObject value) { seq___setslice__(start, stop, step, value); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.list___delslice___doc) final void list___delslice__(PyObject start, PyObject stop, PyObject step) { seq___delslice__(start, stop, step); } @@ -407,6 +408,7 @@ return list_toString(); } + //XXX: needs __doc__ @ExposedMethod(names = "__repr__") final String list_toString() { ThreadState ts = Py.getThreadState(); @@ -438,7 +440,7 @@ list_append(o); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list_append_doc) final void list_append(PyObject o) { pyadd(o); gListAllocatedStatus = __len__(); @@ -454,7 +456,7 @@ return list_count(o); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list_count_doc) final int list_count(PyObject o) { int count = 0; PyObject[] array = getArray(); @@ -484,7 +486,7 @@ return list_index(o, start, stop); } - @ExposedMethod(defaults = {"null", "null"}) + @ExposedMethod(defaults = {"null", "null"}, doc = BuiltinDocs.list_index_doc) final int list_index(PyObject o, PyObject start, PyObject stop) { int startInt = start == null ? 0 : PySlice.calculateSliceIndex(start); int stopInt = stop == null ? size() : PySlice.calculateSliceIndex(stop); @@ -529,7 +531,7 @@ list_insert(index, o); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list_insert_doc) final void list_insert(int index, PyObject o) { if(index < 0) { index = Math.max(0, size() + index); @@ -553,7 +555,7 @@ list_remove(o); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list_remove_doc) final void list_remove(PyObject o) { del(_index(o, "list.remove(x): x not in list", 0, size())); gListAllocatedStatus = __len__(); @@ -568,7 +570,7 @@ list_reverse(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list_reverse_doc) final void list_reverse() { PyObject tmp; int n = size(); @@ -599,7 +601,7 @@ return list_pop(n); } - @ExposedMethod(defaults = "-1") + @ExposedMethod(defaults = "-1", doc = BuiltinDocs.list_pop_doc) final PyObject list_pop(int n) { int length = size(); if(length == 0) { @@ -627,7 +629,7 @@ list_extend(o); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list_extend_doc) final void list_extend(PyObject o) { int length = size(); setslice(length, length, 1, o); @@ -638,7 +640,7 @@ return list___iadd__(o); } - @ExposedMethod(type = MethodType.BINARY) + @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.list___iadd___doc) final PyObject list___iadd__(PyObject o) { PyType oType = o.getType(); if (oType == TYPE || oType == PyTuple.TYPE || this == o) { @@ -677,7 +679,7 @@ */ - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list_sort_doc) final void list_sort(PyObject[] args, String[] kwds) { ArgParser ap = new ArgParser("list", args, kwds, new String[]{"cmp", "key", "reverse"}, 0); PyObject cmp = ap.getPyObject(0, Py.None); @@ -703,7 +705,7 @@ return list___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.list___hash___doc) final int list___hash__() { throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); } Modified: trunk/jython/src/org/python/core/PySlice.java =================================================================== --- trunk/jython/src/org/python/core/PySlice.java 2009-01-01 01:13:50 UTC (rev 5828) +++ trunk/jython/src/org/python/core/PySlice.java 2009-01-01 21:52:35 UTC (rev 5829) @@ -69,7 +69,7 @@ return slice___hash__(); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.slice___hash___doc) final int slice___hash__() { throw Py.TypeError(String.format("unhashable type: '%.200s'", getType().fastGetName())); } @@ -111,7 +111,7 @@ return slice_indices(len); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.slice_indices_doc) final PyObject slice_indices(PyObject len) { int[] indices = indicesEx(len.asIndex(Py.OverflowError)); return new PyTuple(Py.newInteger(indices[0]), Py.newInteger(indices[1]), Modified: trunk/jython/src/org/python/core/PySuper.java =================================================================== --- trunk/jython/src/org/python/core/PySuper.java 2009-01-01 01:13:50 UTC (rev 5828) +++ trunk/jython/src/org/python/core/PySuper.java 2009-01-01 21:52:35 UTC (rev 5829) @@ -110,7 +110,7 @@ return super.__findattr_ex__(name); } - @ExposedMethod + @ExposedMethod(doc = BuiltinDocs.super___getattribute___doc) final PyObject super___getattribute__(PyObject name) { PyObject ret = super___findattr_ex__(asName(name)); if (ret == null) { @@ -123,7 +123,7 @@ return super___get__(obj, type); } - @ExposedMethod(defaults = "null") + @ExposedMethod(defaults = "null", doc = BuiltinDocs.super___get___doc) final PyObject super___get__(PyObject obj, PyObject type) { if (obj == null || obj == Py.None || this.obj != null) { return this; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-01 01:13:53
|
Revision: 5828 http://jython.svn.sourceforge.net/jython/?rev=5828&view=rev Author: cgroves Date: 2009-01-01 01:13:50 +0000 (Thu, 01 Jan 2009) Log Message: ----------- Should've gone out with r5804 Removed Paths: ------------- trunk/jython/bugtests/test211.py trunk/jython/bugtests/test214a.py trunk/jython/bugtests/test230.py trunk/jython/bugtests/test235.py trunk/jython/bugtests/test235p/ trunk/jython/bugtests/test239.py trunk/jython/bugtests/test240.py Deleted: trunk/jython/bugtests/test211.py =================================================================== --- trunk/jython/bugtests/test211.py 2009-01-01 00:37:49 UTC (rev 5827) +++ trunk/jython/bugtests/test211.py 2009-01-01 01:13:50 UTC (rev 5828) @@ -1,34 +0,0 @@ - -import sys -import cPickle -pickle = cPickle - -tmpfile = "test211.tmp" - -def saveValue( value): - f = open(tmpfile,"wb") - p = pickle.Pickler(f,1) - p.dump(value) - f.close() - -def loadValue(): - f=open(tmpfile,"rb") - retVal = pickle.Unpickler(f).load() - f.close() - return retVal - -for x in range(256): - try: - saveValue(x) - except: - print "Exception caught: cannot save ", x - else: - try: - y = loadValue() - except: - print "Exception caught: cannot load previously saved value", x - else: - if x != y: - print "saved: ", x, - print "loaded: ", y - Deleted: trunk/jython/bugtests/test214a.py =================================================================== --- trunk/jython/bugtests/test214a.py 2009-01-01 00:37:49 UTC (rev 5827) +++ trunk/jython/bugtests/test214a.py 2009-01-01 01:13:50 UTC (rev 5828) @@ -1,9 +0,0 @@ -from java.applet import Applet - -class test214a(Applet): - def paint(self, g): - g.drawString("Hello world", 20, 30) - -if __name__ == '__main__': - import pawt - pawt.test(HelloWorld()) Deleted: trunk/jython/bugtests/test230.py =================================================================== --- trunk/jython/bugtests/test230.py 2009-01-01 00:37:49 UTC (rev 5827) +++ trunk/jython/bugtests/test230.py 2009-01-01 01:13:50 UTC (rev 5828) @@ -1,29 +0,0 @@ - -import pdb - -#p = pdb.Pdb() - - - -class P: - def do_help(self, arg): - print "do_help", arg - #print do_help, id(do_help) - - def onecmd(self, cmd, arg): - func = getattr(self, "do_" + cmd) - func(arg) - -class S(P): - do_h = P.do_help - #print do_h, id(do_h) - -p = S() -a = p.do_help -#print a, id(a) -a = p.do_h -#print a, id(a) - -p.onecmd('help', "hello world") -p.onecmd('h', "hello world") - Deleted: trunk/jython/bugtests/test235.py =================================================================== --- trunk/jython/bugtests/test235.py 2009-01-01 00:37:49 UTC (rev 5827) +++ trunk/jython/bugtests/test235.py 2009-01-01 01:13:50 UTC (rev 5828) @@ -1,13 +0,0 @@ - - -import support - -support.compileJava("test235p/javaParent.java") - -from test235p import javaParent - -class pythonClass(javaParent) : - def __init__(self,*args) : - apply(javaParent.__init__,(self,)+args) - -p = pythonClass(1) Deleted: trunk/jython/bugtests/test239.py =================================================================== --- trunk/jython/bugtests/test239.py 2009-01-01 00:37:49 UTC (rev 5827) +++ trunk/jython/bugtests/test239.py 2009-01-01 01:13:50 UTC (rev 5828) @@ -1,11 +0,0 @@ -import support - -support.compileJava("test239j2.java", classpath=".") - -import test239j1 -import test239j2 -config = test239j1() -test = test239j2(config) - -if test239j1.getClassLoader() != test239j2.getClassLoader(): - raise support.TestError, "Loaded classes are not inter-operable" Deleted: trunk/jython/bugtests/test240.py =================================================================== --- trunk/jython/bugtests/test240.py 2009-01-01 00:37:49 UTC (rev 5827) +++ trunk/jython/bugtests/test240.py 2009-01-01 01:13:50 UTC (rev 5828) @@ -1,12 +0,0 @@ - -import support - -support.compileJava("test240p/test240j2.java", classpath=".") - -from test240p import test240j1 -from test240p import test240j2 -config = test240j1() -test = test240j2(config) - -if test240j1.getClassLoader() != test240j2.getClassLoader(): - raise support.TestError, "Loaded classes are not inter-operable" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-01 00:37:53
|
Revision: 5827 http://jython.svn.sourceforge.net/jython/?rev=5827&view=rev Author: cgroves Date: 2009-01-01 00:37:49 +0000 (Thu, 01 Jan 2009) Log Message: ----------- Remove the last vestiges of lazily loaded classes. Will reevaluate their presence if performance problems come up. Modified Paths: -------------- trunk/jython/src/org/python/core/PyJavaPackage.java trunk/jython/src/org/python/core/packagecache/PackageManager.java trunk/jython/src/org/python/core/packagecache/PathPackageManager.java Modified: trunk/jython/src/org/python/core/PyJavaPackage.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaPackage.java 2009-01-01 00:35:27 UTC (rev 5826) +++ trunk/jython/src/org/python/core/PyJavaPackage.java 2009-01-01 00:37:49 UTC (rev 5827) @@ -91,13 +91,11 @@ return ret; } - public PyObject addLazyClass(String name) { - // TODO - make lazy PyJavaType - return null; - } - - /** Add statically known classes. - * @param classes their names as comma-separated string + /** + * Add statically known classes. + * + * @param classes + * their names as comma-separated string */ public void addPlaceholders(String classes) { StringTokenizer tok = new StringTokenizer(classes, ",@"); @@ -114,11 +112,10 @@ } /** - * Used for 'from xyz import *', dynamically dir pkg filling up __dict__. - * It uses {@link PackageManager#doDir} implementation furnished by - * the control package manager with instatiate true. The package - * manager should lazily load classes with {@link #addLazyClass} in - * the package. + * Used for 'from xyz import *', dynamically dir pkg filling up __dict__. It uses + * {@link PackageManager#doDir} implementation furnished by the control package manager with + * instantiate true. The package manager should load classes with {@link #addClass} in the + * package. * * @return list of member names */ Modified: trunk/jython/src/org/python/core/packagecache/PackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/PackageManager.java 2009-01-01 00:35:27 UTC (rev 5826) +++ trunk/jython/src/org/python/core/packagecache/PackageManager.java 2009-01-01 00:37:49 UTC (rev 5827) @@ -3,6 +3,7 @@ package org.python.core.packagecache; +import org.python.core.Py; import org.python.core.PyJavaPackage; import org.python.core.PyList; import org.python.core.PyObject; @@ -33,7 +34,7 @@ /** * Dynamically check if pkg.name exists as java pkg in the controlled * hierarchy. Should be overriden. - * + * * @param pkg parent pkg name * @param name candidate name * @return true if pkg exists @@ -43,7 +44,7 @@ /** * Reports the specified package content names. Should be overriden. Used by * {@link PyJavaPackage#__dir__} and {@link PyJavaPackage#fillDir}. - * + * * @return resulting list of names (PyList of PyString) * @param jpkg queried package * @param instantiate if true then instatiate reported names in package dict @@ -55,7 +56,7 @@ /** * Append a directory to the list of directories searched for java packages * and java classes. - * + * * @param dir A directory. */ public abstract void addDirectory(java.io.File dir); @@ -63,7 +64,7 @@ /** * Append a directory to the list of directories searched for java packages * and java classes. - * + * * @param dir A directory name. */ public abstract void addJarDir(String dir, boolean cache); @@ -71,7 +72,7 @@ /** * Append a jar file to the list of locations searched for java packages and * java classes. - * + * * @param jarfile A directory name. */ public abstract void addJar(String jarfile, boolean cache); @@ -102,12 +103,12 @@ return ret; } - PyList clsNames = cls.keys(); - for (int i = 0; i < clsNames.__len__(); i++) { - PyObject name = clsNames.pyget(i); - if (!dict.has_key(name)) - jpkg.addLazyClass(name.toString()); + for (PyObject pyname : cls.keys().asIterable()) { + if (!dict.has_key(pyname)) { + String name = pyname.toString(); + jpkg.addClass(name, Py.findClass(name)); + } } return dict.keys(); @@ -149,7 +150,7 @@ * Creates package/updates statically known classes info. Uses * {@link PyJavaPackage#addPackage(java.lang.String, java.lang.String) }, * {@link PyJavaPackage#addPlaceholders}. - * + * * @param name package name * @param classes comma-separated string * @param jarfile involved jarfile; can be null @@ -184,11 +185,11 @@ //Empty or 1 byte file. return -1; } - //int minor = + //int minor = istream.readShort(); //int major = istream.readShort(); - + // Check versions??? // System.out.println("magic: "+magic+", "+major+", "+minor); int nconstants = istream.readShort(); Modified: trunk/jython/src/org/python/core/packagecache/PathPackageManager.java =================================================================== --- trunk/jython/src/org/python/core/packagecache/PathPackageManager.java 2009-01-01 00:35:27 UTC (rev 5826) +++ trunk/jython/src/org/python/core/packagecache/PathPackageManager.java 2009-01-01 00:37:49 UTC (rev 5827) @@ -164,7 +164,7 @@ if (pkgCand) { jpkg.addPackage(jname); } else { - jpkg.addLazyClass(jname); + jpkg.addClass(jname, Py.findClass(jname)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2009-01-01 00:35:31
|
Revision: 5826 http://jython.svn.sourceforge.net/jython/?rev=5826&view=rev Author: pjenvey Date: 2009-01-01 00:35:27 +0000 (Thu, 01 Jan 2009) Log Message: ----------- add umask Modified Paths: -------------- trunk/jython/Lib/os.py Modified: trunk/jython/Lib/os.py =================================================================== --- trunk/jython/Lib/os.py 2009-01-01 00:20:37 UTC (rev 5825) +++ trunk/jython/Lib/os.py 2009-01-01 00:35:27 UTC (rev 5826) @@ -1068,7 +1068,13 @@ return fileno.isatty() +def umask(new_mask): + """umask(new_mask) -> old_mask + Set the current numeric umask and return the previous umask.""" + return _posix.umask(int(new_mask)) + + from java.security import SecureRandom urandom_source = None This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-01 00:20:41
|
Revision: 5825 http://jython.svn.sourceforge.net/jython/?rev=5825&view=rev Author: cgroves Date: 2009-01-01 00:20:37 +0000 (Thu, 01 Jan 2009) Log Message: ----------- Tested by test_java_visiblity now Removed Paths: ------------- trunk/jython/bugtests/test304.py trunk/jython/bugtests/test304m.py Deleted: trunk/jython/bugtests/test304.py =================================================================== --- trunk/jython/bugtests/test304.py 2009-01-01 00:19:56 UTC (rev 5824) +++ trunk/jython/bugtests/test304.py 2009-01-01 00:20:37 UTC (rev 5825) @@ -1,11 +0,0 @@ -""" -Test that non-public classes gets loaded with dir() when respectJavaAcc is -false. -Feature request [ #428582 ] Access to non-public classes -""" - -import support - -support.runJava("org.python.util.jython " + - "-Dpython.security.respectJavaAccessibility=false test304m.py", pass_jython_home=1) - Deleted: trunk/jython/bugtests/test304m.py =================================================================== --- trunk/jython/bugtests/test304m.py 2009-01-01 00:19:56 UTC (rev 5824) +++ trunk/jython/bugtests/test304m.py 2009-01-01 00:20:37 UTC (rev 5825) @@ -1,9 +0,0 @@ - -import support - -import java.awt.geom -d = dir(java.awt.geom) -#print d -if "EllipseIterator" not in d: - raise support.TestWarning("Non-public class should by visible when " + - "respectJava is false") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2009-01-01 00:20:01
|
Revision: 5824 http://jython.svn.sourceforge.net/jython/?rev=5824&view=rev Author: cgroves Date: 2009-01-01 00:19:56 +0000 (Thu, 01 Jan 2009) Log Message: ----------- Welcome back, Options.respectJavaAcessibility Modified Paths: -------------- trunk/jython/Lib/test/test_java_visibility.py trunk/jython/src/org/python/core/PyJavaType.java Added Paths: ----------- trunk/jython/Lib/test/access_protected_class.py trunk/jython/Lib/test/access_protected_field.py trunk/jython/Lib/test/call_protected_method.py Added: trunk/jython/Lib/test/access_protected_class.py =================================================================== --- trunk/jython/Lib/test/access_protected_class.py (rev 0) +++ trunk/jython/Lib/test/access_protected_class.py 2009-01-01 00:19:56 UTC (rev 5824) @@ -0,0 +1,2 @@ +from java.awt.geom import Ellipse2D, EllipseIterator +EllipseIterator(Ellipse2D.Float(), None) Added: trunk/jython/Lib/test/access_protected_field.py =================================================================== --- trunk/jython/Lib/test/access_protected_field.py (rev 0) +++ trunk/jython/Lib/test/access_protected_field.py 2009-01-01 00:19:56 UTC (rev 5824) @@ -0,0 +1,4 @@ +from org.python.tests import Invisible +Invisible.protectedStaticField +Invisible().protectedField +Invisible.packageField Added: trunk/jython/Lib/test/call_protected_method.py =================================================================== --- trunk/jython/Lib/test/call_protected_method.py (rev 0) +++ trunk/jython/Lib/test/call_protected_method.py 2009-01-01 00:19:56 UTC (rev 5824) @@ -0,0 +1,5 @@ +from org.python.tests import Invisible +Invisible.protectedStaticMethod(7) +Invisible().protectedMethod(7) +Invisible.packageStaticMethod() +Invisible().packageMethod() Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2008-12-31 21:57:35 UTC (rev 5823) +++ trunk/jython/Lib/test/test_java_visibility.py 2009-01-01 00:19:56 UTC (rev 5824) @@ -1,5 +1,7 @@ import array import unittest +import subprocess +import sys from test import test_support from java.lang import Class from java.util import HashMap, Observable, Observer @@ -165,10 +167,28 @@ self.assertEquals("OtherSubVisible[]", c.takeArray([OtherSubVisible()])) self.assertEquals("SubVisible[]", c.takeArray([SubVisible()])) +class RespectJavaAccessibilityTest(unittest.TestCase): + def run_accessibility_script(self, script, error=AttributeError): + fn = test_support.findfile(script) + self.assertRaises(error, execfile, fn) + self.assertEquals(subprocess.call([sys.executable, "-J-Dpython.cachedir.skip=true", + "-J-Dpython.security.respectJavaAccessibility=false", fn]), + 0) + + def test_method_access(self): + self.run_accessibility_script("call_protected_method.py") + + def test_field_access(self): + self.run_accessibility_script("access_protected_field.py") + + def test_protected_class(self): + self.run_accessibility_script("access_protected_class.py", TypeError) + def test_main(): test_support.run_unittest(VisibilityTest, JavaClassTest, - CoercionTest) + CoercionTest, + RespectJavaAccessibilityTest) if __name__ == "__main__": test_main() Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2008-12-31 21:57:35 UTC (rev 5823) +++ trunk/jython/src/org/python/core/PyJavaType.java 2009-01-01 00:19:56 UTC (rev 5824) @@ -102,7 +102,7 @@ // PyReflected* can't call or access anything from non-public classes that aren't in // org.python.core if (!Modifier.isPublic(underlying_class.getModifiers()) && - !name.startsWith("org.python.core")) { + !name.startsWith("org.python.core") && Options.respectJavaAccessibility) { handleSuperMethodArgCollisions(); return; } @@ -110,7 +110,17 @@ // Add methods and determine bean properties declared on this class Map<String, PyBeanProperty> props = Generic.map(); Map<String, PyBeanEvent> events = Generic.map(); - for (Method meth : underlying_class.getMethods()) { + Method[] methods; + if (Options.respectJavaAccessibility) { + // returns just the public methods + methods = underlying_class.getMethods(); + } else { + methods = underlying_class.getDeclaredMethods(); + for (Method method : methods) { + method.setAccessible(true); + } + } + for (Method meth : methods) { if (!declaredOnMember(baseClass, meth) || ignore(meth)) { continue; } @@ -174,7 +184,7 @@ } // Add superclass methods - for (Method meth : underlying_class.getMethods()) { + for (Method meth : methods) { String nmethname = normalize(meth.getName()); PyReflectedFunction reflfunc = (PyReflectedFunction)dict.__finditem__(nmethname); if (reflfunc != null) { @@ -192,7 +202,17 @@ } // Add fields declared on this type - for (Field field : underlying_class.getFields()) { + Field[] fields; + if (Options.respectJavaAccessibility) { + // returns just the public fields + fields = underlying_class.getFields(); + } else { + fields = underlying_class.getDeclaredFields(); + for (Field field : fields) { + field.setAccessible(true); + } + } + for (Field field : fields) { if (!declaredOnMember(baseClass, field)) { continue; } @@ -258,7 +278,19 @@ } final PyReflectedConstructor reflctr = new PyReflectedConstructor("_new_impl"); - for (Constructor<?> ctr : underlying_class.getConstructors()) { + Constructor<?>[] constructors; + // No matter the security manager, trying to set the constructor on class to accessible + // blows up + if (Options.respectJavaAccessibility || Class.class == underlying_class) { + // returns just the public constructors + constructors = underlying_class.getConstructors(); + } else { + constructors = underlying_class.getDeclaredConstructors(); + for (Constructor<?> ctr : constructors) { + ctr.setAccessible(true); + } + } + for (Constructor<?> ctr : constructors) { reflctr.addConstructor(ctr); } if (PyObject.class.isAssignableFrom(underlying_class)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fwi...@us...> - 2008-12-31 22:55:28
|
Revision: 5820 http://jython.svn.sourceforge.net/jython/?rev=5820&view=rev Author: fwierzbicki Date: 2008-12-31 21:37:59 +0000 (Wed, 31 Dec 2008) Log Message: ----------- test216 -> test_codeop_jy.py (plus more like this test) Also cleaned up test_codeop.py so we are more like CPython, we are close to deleting our local version of test_codeop.py. Improved trailing \ support in grammar Added a number of checks for invalid del statements. Modified Paths: -------------- trunk/jython/Lib/test/test_codeop.py trunk/jython/Lib/test/test_codeop_jy.py trunk/jython/grammar/Python.g trunk/jython/grammar/PythonPartial.g trunk/jython/src/org/python/antlr/GrammarActions.java Removed Paths: ------------- trunk/jython/bugtests/test216.py trunk/jython/bugtests/test216s1.py Modified: trunk/jython/Lib/test/test_codeop.py =================================================================== --- trunk/jython/Lib/test/test_codeop.py 2008-12-31 21:36:03 UTC (rev 5819) +++ trunk/jython/Lib/test/test_codeop.py 2008-12-31 21:37:59 UTC (rev 5820) @@ -86,22 +86,12 @@ av("def x():\n\n pass\n") av("def x():\n pass\n \n") av("def x():\n pass\n \n") - ##next 4 added for Jython - av("\n\ndef x():\n pass\n") - av("def x():\n\n pass\n") # failed under Jython 2.1 - av("def x():\n pass\n \n") - av("def x():\n pass\n \n") - # this failed under 2.2.1 - av("def x():\n try: pass\n finally: [a for a in (1,2)]\n") - av("pass\n") av("3**3\n") av("if 9==3:\n pass\nelse:\n pass\n") av("if 1:\n pass\n if 1:\n pass\n else:\n pass\n") - #next 2 added for Jython - av("if 1:\n pass\n if 1:\n pass\n else:\n pass\n") av("#a\n#b\na = 3\n") av("#a\n\n \na=3\n") @@ -132,7 +122,6 @@ ai("if 9==3:\n pass\nelse:") ai("if 9==3:\n pass\nelse:\n") ai("if 9==3:\n pass\nelse:\n pass") - ai("if 1:") ai("if 1:\n") ai("if 1:\n pass\n if 1:\n pass\n else:") @@ -148,7 +137,7 @@ #ai("def x():\n pass\n ") ai("\n\ndef x():\n pass") - #ai("a = 9+ \\") + ai("a = 9+ \\") #ai("a = 'a\\") ai("a = '''xy") @@ -157,7 +146,7 @@ ai("(","eval") ai("(\n\n\n","eval") ai("(9+","eval") - #ai("9+ \\","eval") + ai("9+ \\","eval") #ai("lambda z: \\","eval") def test_invalid(self): @@ -175,21 +164,18 @@ ai("\n\n if 1: pass\n\npass") - ai("a = 9+ \\\n") + #ai("a = 9+ \\\n") ai("a = 'a\\ ") ai("a = 'a\\\n") - #XXX: eval is hopelessly permissive right now -- but the rest of this - # test_jy_compile is really important to me for flagging new bugs - - # so commenting out these for now. - #ai("a = 1","eval") + ai("a = 1","eval") #ai("a = (","eval") - #ai("]","eval") - #ai("())","eval") - #ai("[}","eval") - #ai("9+","eval") - #ai("lambda z:","eval") - #ai("a b","eval") + ai("]","eval") + ai("())","eval") + ai("[}","eval") + ai("9+","eval") + ai("lambda z:","eval") + ai("a b","eval") def test_filename(self): self.assertEquals(compile_command("a = 1\n", "abc").co_filename, Modified: trunk/jython/Lib/test/test_codeop_jy.py =================================================================== --- trunk/jython/Lib/test/test_codeop_jy.py 2008-12-31 21:36:03 UTC (rev 5819) +++ trunk/jython/Lib/test/test_codeop_jy.py 2008-12-31 21:37:59 UTC (rev 5820) @@ -65,6 +65,12 @@ av("def x():\n pass\n \n") av("def x():\n pass\n \n") + # this failed under 2.2.1 + av("def x():\n try: pass\n finally: [a for a in (1,2)]\n") + + av("if 9==3:\n pass\nelse:\n pass\n") + av("if 1:\n pass\n if 1:\n pass\n else:\n pass\n") + av("pass\n") av("3**3\n") @@ -160,6 +166,11 @@ ai("lambda z:","eval") ai("a b","eval") ai("return 2.3") + ai("del 1") + ai("del ()") + ai("del (1,)") + ai("del [1]") + ai("del '1'") def test_filename(self): self.assertEquals(compile_("a = 1\n", "abc").co_filename, Deleted: trunk/jython/bugtests/test216.py =================================================================== --- trunk/jython/bugtests/test216.py 2008-12-31 21:36:03 UTC (rev 5819) +++ trunk/jython/bugtests/test216.py 2008-12-31 21:37:59 UTC (rev 5820) @@ -1,12 +0,0 @@ -""" - -""" - -import support - -try: - import test216s1 -except SyntaxError: - pass -else: - raise support.TestError("Should raise SyntaxError") Deleted: trunk/jython/bugtests/test216s1.py =================================================================== --- trunk/jython/bugtests/test216s1.py 2008-12-31 21:36:03 UTC (rev 5819) +++ trunk/jython/bugtests/test216s1.py 2008-12-31 21:37:59 UTC (rev 5820) @@ -1,11 +0,0 @@ -class Foo: - pass - -f = Foo() -f.bar = {} - -#f.bar("A") -#del f.bar("A") - -#f.bar("A") = 1 -del [1] \ No newline at end of file Modified: trunk/jython/grammar/Python.g =================================================================== --- trunk/jython/grammar/Python.g 2008-12-31 21:36:03 UTC (rev 5819) +++ trunk/jython/grammar/Python.g 2008-12-31 21:37:59 UTC (rev 5820) @@ -73,6 +73,7 @@ tokens { INDENT; DEDENT; + TRAILBACKSLASH; //For dangling backslashes when partial parsing. } @header { @@ -1779,9 +1780,21 @@ */ CONTINUED_LINE : '\\' ('\r')? '\n' (' '|'\t')* { $channel=HIDDEN; } - ( nl=NEWLINE {emit(new CommonToken(NEWLINE,nl.getText()));} + ( nl=NEWLINE { + if (!partial) { + emit(new CommonToken(NEWLINE,nl.getText())); + } + } | - ) + ) { + if (input.LA(1) == -1) { + if (partial) { + emit(new CommonToken(TRAILBACKSLASH,"\\")); + } else { + throw new ParseException("unexpected character after line continuation character"); + } + } + } ; /** Treat a sequence of blank lines as a single blank line. If Modified: trunk/jython/grammar/PythonPartial.g =================================================================== --- trunk/jython/grammar/PythonPartial.g 2008-12-31 21:36:03 UTC (rev 5819) +++ trunk/jython/grammar/PythonPartial.g 2008-12-31 21:37:59 UTC (rev 5820) @@ -73,49 +73,24 @@ } @members { - boolean debugOn = false; + private ErrorHandler errorHandler = new FailFastHandler(); - private void debug(String message) { - if (debugOn) { - System.out.println(message); + protected void mismatch(IntStream input, int ttype, BitSet follow) throws RecognitionException { + if (errorHandler.mismatch(this, input, ttype, follow)) { + super.mismatch(input, ttype, follow); } } - /* - protected void mismatch(IntStream input, int ttype, BitSet follow) throws RecognitionException { - throw new MismatchedTokenException(ttype, input); - } - protected void mismatch(IntStream input, RecognitionException e, BitSet follow) throws RecognitionException { - throw e; - } + protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) + throws RecognitionException { - protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) - throws RecognitionException - { - mismatch(input, ttype, follow); - return null; + Object o = errorHandler.recoverFromMismatchedToken(this, input, ttype, follow); + if (o != null) { + return o; + } + return super.recoverFromMismatchedToken(input, ttype, follow); } - */ - public void emitErrorMessage(String msg) { - //System.err.print("[EMITTING] "); - } - - public void reportError(RecognitionException e) { - //System.err.print("[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); - } - - } @rulecatch { @@ -187,7 +162,7 @@ | assert_stmt ; -expr_stmt : testlist {debug("matched expr_stmt");} +expr_stmt : testlist ( augassign yield_expr | augassign testlist | assigns @@ -338,12 +313,12 @@ ) ; -test: or_test {debug("matched test: or_test");} +test: or_test ( (IF or_test ELSE) => IF or_test ELSE test)? | lambdef ; -or_test : and_test (OR and_test)* {debug("matched or_test");} +or_test : and_test (OR and_test)* ; and_test : not_test (AND not_test)* @@ -369,7 +344,7 @@ | IS NOT ; -expr : xor_expr (VBAR xor_expr)* {debug("matched expr");} +expr : xor_expr (VBAR xor_expr)* ; xor_expr : and_expr (CIRCUMFLEX and_expr)* @@ -391,6 +366,7 @@ | MINUS factor | TILDE factor | power + | TRAILBACKSLASH ; power : atom (trailer)* (options {greedy=true;}:DOUBLESTAR factor)? @@ -409,7 +385,7 @@ | LONGINT | FLOAT | COMPLEX - | (STRING)+ {debug("matched STRING");} + | (STRING)+ | STRINGPART ; @@ -449,7 +425,7 @@ ; testlist - : test (options {k=2;}: COMMA test)* (COMMA)? {debug("matched testlist");} + : test (options {k=2;}: COMMA test)* (COMMA)? ; dictmaker : test COLON test (options {k=2;}:COMMA test COLON test)* (COMMA)? Modified: trunk/jython/src/org/python/antlr/GrammarActions.java =================================================================== --- trunk/jython/src/org/python/antlr/GrammarActions.java 2008-12-31 21:36:03 UTC (rev 5819) +++ trunk/jython/src/org/python/antlr/GrammarActions.java 2008-12-31 21:37:59 UTC (rev 5820) @@ -637,16 +637,40 @@ } } - List<expr> makeDeleteList(List e) { - List<expr> exprs = castExprs(e); - for(expr expr : exprs) { - if (expr instanceof Call) { - errorHandler.error("can't delete function call", expr); - } + List<expr> makeDeleteList(List deletes) { + List<expr> exprs = castExprs(deletes); + for(expr e : exprs) { + checkDelete(e); } return exprs; } + void checkDelete(expr e) { + //System.out.println("trying to del " + e); + if (e instanceof Call) { + errorHandler.error("can't delete function call", e); + } else if (e instanceof Num) { + errorHandler.error("can't delete number", e); + } else if (e instanceof Str) { + errorHandler.error("can't delete string", e); + } else if (e instanceof Tuple) { + //XXX: performance problem? Any way to do this better? + List<expr> elts = ((Tuple)e).getInternalElts(); + if (elts.size() == 0) { + errorHandler.error("can't delete ()", e); + } + for (int i=0;i<elts.size();i++) { + checkDelete(elts.get(i)); + } + } else if (e instanceof org.python.antlr.ast.List) { + //XXX: performance problem? Any way to do this better? + List<expr> elts = ((org.python.antlr.ast.List)e).getInternalElts(); + for (int i=0;i<elts.size();i++) { + checkDelete(elts.get(i)); + } + } + } + slice makeSubscript(PythonTree lower, Token colon, PythonTree upper, PythonTree sliceop) { boolean isSlice = false; expr s = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cg...@us...> - 2008-12-31 22:55:23
|
Revision: 5821 http://jython.svn.sourceforge.net/jython/?rev=5821&view=rev Author: cgroves Date: 2008-12-31 21:38:23 +0000 (Wed, 31 Dec 2008) Log Message: ----------- Java class mros are static, so don't compute them and blow up when trying to make a Python resolution order out of them. An ant clean will be necessary after this commit to clear out the exposed version of PyJavaType. Modified Paths: -------------- trunk/jython/CoreExposed.includes trunk/jython/Lib/test/test_java_visibility.py trunk/jython/src/org/python/core/PyJavaType.java trunk/jython/src/org/python/core/PyType.java trunk/jython/src/org/python/core/adapter/ClassicPyObjectAdapter.java Modified: trunk/jython/CoreExposed.includes =================================================================== --- trunk/jython/CoreExposed.includes 2008-12-31 21:37:59 UTC (rev 5820) +++ trunk/jython/CoreExposed.includes 2008-12-31 21:38:23 UTC (rev 5821) @@ -20,7 +20,6 @@ org/python/core/PyFunction.class org/python/core/PyGenerator.class org/python/core/PyInteger.class -org/python/core/PyJavaType.class org/python/core/PyList.class org/python/core/PyLong.class org/python/core/PyMethod.class Modified: trunk/jython/Lib/test/test_java_visibility.py =================================================================== --- trunk/jython/Lib/test/test_java_visibility.py 2008-12-31 21:37:59 UTC (rev 5820) +++ trunk/jython/Lib/test/test_java_visibility.py 2008-12-31 21:38:23 UTC (rev 5821) @@ -141,6 +141,7 @@ self.assertEquals('java.util', HashMap.__module__) self.assertEquals(Class, HashMap.__class__) self.assertEquals(None, HashMap.__doc__) + self.assertEquals(list(HashMap.__mro__), HashMap.mro()) def test_python_methods(self): s = SomePyMethods() Modified: trunk/jython/src/org/python/core/PyJavaType.java =================================================================== --- trunk/jython/src/org/python/core/PyJavaType.java 2008-12-31 21:37:59 UTC (rev 5820) +++ trunk/jython/src/org/python/core/PyJavaType.java 2008-12-31 21:38:23 UTC (rev 5821) @@ -16,11 +16,9 @@ import org.python.core.util.StringUtil; import org.python.expose.ExposeAsSuperclass; -import org.python.expose.ExposedMethod; import org.python.expose.ExposedType; import org.python.util.Generic; -@ExposedType(name = "javatype") public class PyJavaType extends PyType { private final static Class<?>[] OO = {PyObject.class, PyObject.class}; @@ -37,14 +35,6 @@ super(TYPE == null ? fromClass(PyType.class) : TYPE); } - @ExposedMethod(defaults = "null") - final PyList javatype_mro(PyObject o) { - if (o == null) { - return new PyList(mro); - } - return new PyList(((PyJavaType)o).mro); - } - @Override public Class<?> getProxyType() { return PyObject.class.isAssignableFrom(underlying_class) ? null : underlying_class; @@ -62,6 +52,10 @@ return !(attr instanceof PyReflectedField || attr instanceof PyReflectedFunction); } + PyObject[] compute_mro() { + return mro; + } + @Override protected void init() { name = underlying_class.getName(); Modified: trunk/jython/src/org/python/core/PyType.java =================================================================== --- trunk/jython/src/org/python/core/PyType.java 2008-12-31 21:37:59 UTC (rev 5820) +++ trunk/jython/src/org/python/core/PyType.java 2008-12-31 21:38:23 UTC (rev 5821) @@ -691,7 +691,7 @@ return new PyList(((PyType)o).compute_mro()); } - final PyObject[] compute_mro() { + PyObject[] compute_mro() { PyObject[] bases = this.bases; int n = bases.length; for (int i = 0; i < n; i++) { Modified: trunk/jython/src/org/python/core/adapter/ClassicPyObjectAdapter.java =================================================================== --- trunk/jython/src/org/python/core/adapter/ClassicPyObjectAdapter.java 2008-12-31 21:37:59 UTC (rev 5820) +++ trunk/jython/src/org/python/core/adapter/ClassicPyObjectAdapter.java 2008-12-31 21:38:23 UTC (rev 5821) @@ -108,10 +108,10 @@ }); } - /** - * Always returns true as we just return new PyJavaInstance(o) if the - * adapters added to the superclass can't handle o. - */ + /** + * Always returns true as we just return new PyJavaInstance(o) if the adapters added to the + * superclass can't handle o. + */ public boolean canAdapt(Object o) { return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |