From jython-checkins at python.org Thu Jan 2 20:28:30 2014 From: jython-checkins at python.org (frank.wierzbicki) Date: Thu, 2 Jan 2014 20:28:30 +0100 (CET) Subject: [Jython-checkins] =?utf-8?q?jython=3A_Fix_string_substition_error?= =?utf-8?q?=2E?= Message-ID: <3dwK6Q437sz7Lk5@mail.python.org> http://hg.python.org/jython/rev/5ae3611df6c6 changeset: 7173:5ae3611df6c6 user: Frank Wierzbicki date: Thu Jan 02 11:15:18 2014 -0800 summary: Fix string substition error. files: ast/asdl_antlr.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ast/asdl_antlr.py b/ast/asdl_antlr.py --- a/ast/asdl_antlr.py +++ b/ast/asdl_antlr.py @@ -433,8 +433,8 @@ # The accept() method self.emit("public R accept(VisitorIF visitor) throws Exception {", depth) if is_product: - self.emit('traverse(visitor);' % clsname, depth+1) - self.emit('return null;' % clsname, depth+1) + self.emit('traverse(visitor);', depth+1) + self.emit('return null;', depth+1) else: self.emit('return visitor.visit%s(this);' % clsname, depth+1) self.emit("}", depth) @@ -564,7 +564,7 @@ self.emit("return (PyObject)%s;" % field.name, depth+1) elif str(field.type) == 'bool': self.emit("if (%s) return Py.True;" % field.name, depth+1) - self.emit("return Py.False;" % field.name, depth+1) + self.emit("return Py.False;", depth+1) elif str(field.type) == 'int': self.emit("return Py.newInteger(%s);" % field.name, depth+1) elif field.typedef.simple: -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Fri Jan 3 01:25:45 2014 From: jython-checkins at python.org (frank.wierzbicki) Date: Fri, 3 Jan 2014 01:25:45 +0100 (CET) Subject: [Jython-checkins] =?utf-8?q?jython=3A_Move_indexer_support_into_c?= =?utf-8?q?ode_generation=2E?= Message-ID: <3dwRjP1rB5z7LkC@mail.python.org> http://hg.python.org/jython/rev/b2890af7a5e8 changeset: 7174:b2890af7a5e8 user: Frank Wierzbicki date: Thu Jan 02 16:25:39 2014 -0800 summary: Move indexer support into code generation. files: ast/asdl_antlr.py | 199 ++++++++++++++++++++++++++++++++++ 1 files changed, 199 insertions(+), 0 deletions(-) diff --git a/ast/asdl_antlr.py b/ast/asdl_antlr.py --- a/ast/asdl_antlr.py +++ b/ast/asdl_antlr.py @@ -311,6 +311,9 @@ self.javaMethods(product, name, name, True, product.fields, depth+1) + if str(name) in indexer_support: + self.indexerSupport(str(name), depth) + self.emit("}", depth) self.close() @@ -375,6 +378,8 @@ self.emit("}", depth + 1) self.emit("", 0) + if str(cons.name) in indexer_support: + self.indexerSupport(str(cons.name), depth) self.emit("}", depth) self.close() @@ -609,6 +614,11 @@ if check_seq and field.seq: return "java.util.List<%s>" % jtype return jtype + + def indexerSupport(self, name, depth): + print "emitting indexer support for", name + self.emit("// Support for indexer below", depth + 1) + self.file.write(indexer_support[name]) class VisitorVisitor(EmitVisitor): def __init__(self, dir): @@ -673,6 +683,195 @@ VisitorVisitor(outdir)) c.visit(mod) +indexer_support = {"Attribute": """ + private Name attrName; + public Name getInternalAttrName() { + return attrName; + } + public Attribute(Token token, expr value, Name attr, expr_contextType ctx) { + super(token); + this.value = value; + addChild(value); + this.attr = attr.getText(); + this.attrName = attr; + this.ctx = ctx; + } + + public Attribute(Integer ttype, Token token, expr value, Name attr, expr_contextType ctx) { + super(ttype, token); + this.value = value; + addChild(value); + this.attr = attr.getText(); + this.attrName = attr; + this.ctx = ctx; + } +""", + +"ClassDef": """ + private Name nameNode; + public Name getInternalNameNode() { + return nameNode; + } + public ClassDef(Token token, Name name, java.util.List bases, java.util.List + body, java.util.List decorator_list) { + super(token); + this.name = name.getText(); + this.nameNode = name; + this.bases = bases; + if (bases == null) { + this.bases = new ArrayList(); + } + for(PythonTree t : this.bases) { + addChild(t); + } + this.body = body; + if (body == null) { + this.body = new ArrayList(); + } + for(PythonTree t : this.body) { + addChild(t); + } + this.decorator_list = decorator_list; + if (decorator_list == null) { + this.decorator_list = new ArrayList(); + } + for(PythonTree t : this.decorator_list) { + addChild(t); + } + } +""", + +"FunctionDef": """ + private Name nameNode; + public Name getInternalNameNode() { + return nameNode; + } + public FunctionDef(Token token, Name name, arguments args, java.util.List body, + java.util.List decorator_list) { + super(token); + this.name = name.getText(); + this.nameNode = name; + this.args = args; + this.body = body; + if (body == null) { + this.body = new ArrayList(); + } + for(PythonTree t : this.body) { + addChild(t); + } + this.decorator_list = decorator_list; + if (decorator_list == null) { + this.decorator_list = new ArrayList(); + } + for(PythonTree t : this.decorator_list) { + addChild(t); + } + } +""", + +"Global": """ + private java.util.List nameNodes; + public java.util.List getInternalNameNodes() { + return nameNodes; + } + public Global(Token token, java.util.List names, java.util.List nameNodes) { + super(token); + this.names = names; + this.nameNodes = nameNodes; + } +""", + +"ImportFrom": """ + private java.util.List moduleNames; + public java.util.List getInternalModuleNames() { + return moduleNames; + } + public ImportFrom(Token token, + String module, java.util.List moduleNames, + java.util.List names, Integer level) { + super(token); + this.module = module; + this.names = names; + if (names == null) { + this.names = new ArrayList(); + } + for(PythonTree t : this.names) { + addChild(t); + } + this.moduleNames = moduleNames; + if (moduleNames == null) { + this.moduleNames = new ArrayList(); + } + for(PythonTree t : this.moduleNames) { + addChild(t); + } + this.level = level; + } +""", + +"alias": """ + private java.util.List nameNodes; + public java.util.List getInternalNameNodes() { + return nameNodes; + } + private Name asnameNode; + public Name getInternalAsnameNode() { + return asnameNode; + } + // [import] name [as asname] + public alias(Name name, Name asname) { + this(java.util.Arrays.asList(new Name[]{name}), asname); + } + + // [import] ...foo.bar.baz [as asname] + public alias(java.util.List nameNodes, Name asname) { + this.nameNodes = nameNodes; + this.name = dottedNameListToString(nameNodes); + if (asname != null) { + this.asnameNode = asname; + this.asname = asname.getInternalId(); + } + } +""", + +"arguments": """ + private Name varargName; + public Name getInternalVarargName() { + return varargName; + } + private Name kwargName; + public Name getInternalKwargName() { + return kwargName; + } + // XXX: vararg and kwarg are deliberately moved to the end of the + // method signature to avoid clashes with the (Token, List, + // String, String, List) version of the constructor. + public arguments(Token token, java.util.List args, + java.util.List defaults, Name vararg, Name kwarg) { + super(token); + this.args = args; + if (args == null) { + this.args = new ArrayList(); + } + for(PythonTree t : this.args) { + addChild(t); + } + this.vararg = vararg == null ? null : vararg.getText(); + this.varargName = vararg; + this.kwarg = kwarg == null ? null : kwarg.getText(); + this.kwargName = kwarg; + this.defaults = defaults; + if (defaults == null) { + this.defaults = new ArrayList(); + } + for(PythonTree t : this.defaults) { + addChild(t); + } + } +""", + +} + if __name__ == "__main__": import sys import getopt -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Fri Jan 10 05:08:23 2014 From: jython-checkins at python.org (jim.baker) Date: Fri, 10 Jan 2014 05:08:23 +0100 (CET) Subject: [Jython-checkins] =?utf-8?q?jython=3A_Enable_mixing_Python_and_Ja?= =?utf-8?q?va_types_in_the_bases_of_a_class_when?= Message-ID: <3f0rK32tt2z7LjT@mail.python.org> http://hg.python.org/jython/rev/b4ae9e2893c8 changeset: 7175:b4ae9e2893c8 user: Jim Baker date: Thu Jan 09 21:08:56 2014 -0700 summary: Enable mixing Python and Java types in the bases of a class when using a metaclass. files: Lib/test/test_java_subclasses.py | 46 +++++++++++++++++++- src/org/python/core/PyType.java | 12 +++++ 2 files changed, 57 insertions(+), 1 deletions(-) diff --git a/Lib/test/test_java_subclasses.py b/Lib/test/test_java_subclasses.py --- a/Lib/test/test_java_subclasses.py +++ b/Lib/test/test_java_subclasses.py @@ -8,6 +8,7 @@ from java.lang import (Boolean, Class, ClassLoader, Comparable,Integer, Object, Runnable, String, Thread, ThreadGroup) from java.util import Date, Hashtable, Vector +from java.util.concurrent import Callable, Executors from java.awt import Color, Component, Dimension, Rectangle from javax.swing import ComboBoxModel, ListModel @@ -331,13 +332,56 @@ self.assertEquals(len(called), 1) +class MetaClass(type): + def __new__(meta, name, bases, d): + + # Insert the method to be called from Java + def call(self): + return self.x + + d["call"] = call + d["foo"] = 99 + return super(MetaClass, meta).__new__(meta, name, bases, d) + + +class MetaBase(object): + __metaclass__ = MetaClass + + +class MetaClassTest(unittest.TestCase): + + def test_java_with_metaclass_base(self): + """Java classes can be mixed with Python bases using metaclasses""" + + # Permute mixin order + class Bar(MetaBase, Callable): + def __init__(self, x): + self.x = x + + class Baz(Callable, MetaBase): + def __init__(self, x): + self.x = x + + # Go through {bar|baz}.call indirectly through a Java path, + # just to ensure this mixin provided by the metaclass is available + pool = Executors.newSingleThreadExecutor() + bar = Bar(42) + self.assertEqual(bar.foo, 99) + self.assertEqual(42, pool.submit(bar).get()) + baz = Baz(47) + self.assertEqual(baz.foo, 99) + self.assertEqual(47, pool.submit(baz).get()) + pool.shutdown() + + def test_main(): test_support.run_unittest(InterfaceTest, TableModelTest, AutoSuperTest, PythonSubclassesTest, AbstractOnSyspathTest, - ContextClassloaderTest) + ContextClassloaderTest, + MetaClassTest) if __name__ == '__main__': diff --git a/src/org/python/core/PyType.java b/src/org/python/core/PyType.java --- a/src/org/python/core/PyType.java +++ b/src/org/python/core/PyType.java @@ -1119,6 +1119,10 @@ return best; } + private static boolean isJavaRootClass(PyType type) { + return type instanceof PyJavaType && type.fastGetName().equals("java.lang.Class"); + } + /** * Finds the most derived subtype of initialMetatype in the types * of bases, or initialMetatype if it is already the most derived. @@ -1130,11 +1134,19 @@ */ private static PyType findMostDerivedMetatype(PyObject[] bases_list, PyType initialMetatype) { PyType winner = initialMetatype; + if (isJavaRootClass(winner)) { // consider this root class to be equivalent to type + winner = PyType.TYPE; + } + for (PyObject base : bases_list) { if (base instanceof PyClass) { continue; } PyType curtype = base.getType(); + if (isJavaRootClass(curtype)) { + curtype = PyType.TYPE; + } + if (winner.isSubType(curtype)) { continue; } -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sat Jan 25 23:56:20 2014 From: jython-checkins at python.org (jeff.allen) Date: Sat, 25 Jan 2014 23:56:20 +0100 (CET) Subject: [Jython-checkins] =?utf-8?q?jython=3A_Correct_issue_=232109_test_?= =?utf-8?q?failures_in_test=5Fhttpservers_on_Windows=2E?= Message-ID: <3fBXdc5y2Jz7LjS@mail.python.org> http://hg.python.org/jython/rev/6441fcfd940b changeset: 7176:6441fcfd940b parent: 7171:05192fad65cb user: Jeff Allen date: Wed Jan 15 08:16:12 2014 +0000 summary: Correct issue #2109 test failures in test_httpservers on Windows. In the affected tests, use method names that do not have a special meaning to packet filtering software (on Windows, the Base Filtering Engine). In clause test_version_none, use a method that would be valid if HTTP/0.9 were not correctly detected. Also Python issue 20155. files: Lib/test/test_httpservers.py | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py --- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -189,7 +189,7 @@ def test_request_line_trimming(self): self.con._http_vsn_str = 'HTTP/1.1\n' - self.con.putrequest('GET', '/') + self.con.putrequest('XYZBOGUS', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) @@ -216,8 +216,9 @@ self.assertEqual(res.status, 501) def test_version_none(self): + # Test that a valid method is rejected when not HTTP/1.x self.con._http_vsn_str = '' - self.con.putrequest('PUT', '/') + self.con.putrequest('CUSTOM', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sat Jan 25 23:56:22 2014 From: jython-checkins at python.org (jeff.allen) Date: Sat, 25 Jan 2014 23:56:22 +0100 (CET) Subject: [Jython-checkins] =?utf-8?q?jython=3A_=5BTrivial=5D_Correct_typo_?= =?utf-8?q?FIME_-=3E_FIXME?= Message-ID: <3fBXdf0Srsz7LjS@mail.python.org> http://hg.python.org/jython/rev/a394359c0582 changeset: 7177:a394359c0582 user: Jeff Allen date: Wed Jan 15 08:42:37 2014 +0000 summary: [Trivial] Correct typo FIME -> FIXME files: Lib/test/test_httplib.py | 2 +- Lib/test/test_httpservers.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -201,7 +201,7 @@ if resp.read() != "": self.fail("Did not expect response from HEAD request") - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_send_file(self): expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ 'Accept-Encoding: identity\r\nContent-Length:' diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py --- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -461,13 +461,13 @@ msg='path = %r\nGot: %r\nWanted: %r' % (path, actual, expected)) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_headers_and_content(self): res = self.request('/cgi-bin/file1.py') self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_post(self): params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456}) headers = {'Content-type' : 'application/x-www-form-urlencoded'} @@ -480,7 +480,7 @@ res.read() self.assertEqual(res.status, 404) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_authorization(self): headers = {'Authorization' : 'Basic %s' % base64.b64encode('username:pass')} @@ -488,14 +488,14 @@ self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_no_leading_slash(self): # http://bugs.python.org/issue2254 res = self.request('cgi-bin/file1.py') self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_os_environ_is_not_altered(self): signature = "Test CGI Server" os.environ['SERVER_SOFTWARE'] = signature -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sat Jan 25 23:56:23 2014 From: jython-checkins at python.org (jeff.allen) Date: Sat, 25 Jan 2014 23:56:23 +0100 (CET) Subject: [Jython-checkins] =?utf-8?q?jython=3A_Update_test=5Fbz2_to_CPytho?= =?utf-8?q?n_2=2E7=2E6_version_to_avoid_CPython_issue_17843=2E?= Message-ID: <3fBXdg3JqVz7LlS@mail.python.org> http://hg.python.org/jython/rev/8fac773f868d changeset: 7178:8fac773f868d user: Jeff Allen date: Fri Jan 17 23:46:16 2014 +0000 summary: Update test_bz2 to CPython 2.7.6 version to avoid CPython issue 17843. testbz2_bigmem.bz2 used before this patch is detected by certain anti-virus software as Trojan-ArcBomb.BZip.Agent: see CPython issue 17843. files: lib-python/2.7/test/test_bz2.py | 44 +++++------- lib-python/2.7/test/testbz2_bigmem.bz2 | Bin 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/lib-python/2.7/test/test_bz2.py b/lib-python/2.7/test/test_bz2.py --- a/lib-python/2.7/test/test_bz2.py +++ b/lib-python/2.7/test/test_bz2.py @@ -25,9 +25,6 @@ DATA_CRLF = 'BZh91AY&SY\xaez\xbbN\x00\x01H\xdf\x80\x00\x12@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe0@\x01\xbc\xc6`\x86*\x8d=M\xa9\x9a\x86\xd0L@\x0fI\xa6!\xa1\x13\xc8\x88jdi\x8d@\x03@\x1a\x1a\x0c\x0c\x83 \x00\xc4h2\x19\x01\x82D\x84e\t\xe8\x99\x89\x19\x1ah\x00\r\x1a\x11\xaf\x9b\x0fG\xf5(\x1b\x1f?\t\x12\xcf\xb5\xfc\x95E\x00ps\x89\x12^\xa4\xdd\xa2&\x05(\x87\x04\x98\x89u\xe40%\xb6\x19\'\x8c\xc4\x89\xca\x07\x0e\x1b!\x91UIFU%C\x994!DI\xd2\xfa\xf0\xf1N8W\xde\x13A\xf5\x9cr%?\x9f3;I45A\xd1\x8bT\xb1\xa4\xc7\x8d\x1a\\"\xad\xa1\xabyBg\x15\xb9l\x88\x88\x91k"\x94\xa4\xd4\x89\xae*\xa6\x0b\x10\x0c\xd6\xd4m\xe86\xec\xb5j\x8a\x86j\';\xca.\x01I\xf2\xaaJ\xe8\x88\x8cU+t3\xfb\x0c\n\xa33\x13r2\r\x16\xe0\xb3(\xbf\x1d\x83r\xe7M\xf0D\x1365\xd8\x88\xd3\xa4\x92\xcb2\x06\x04\\\xc1\xb0\xea//\xbek&\xd8\xe6+t\xe5\xa1\x13\xada\x16\xder5"w]\xa2i\xb7[\x97R \xe2IT\xcd;Z\x04dk4\xad\x8a\t\xd3\x81z\x10\xf1:^`\xab\x1f\xc5\xdc\x91N\x14$+\x9e\xae\xd3\x80' EMPTY_DATA = 'BZh9\x17rE8P\x90\x00\x00\x00\x00' - with open(findfile("testbz2_bigmem.bz2"), "rb") as f: - DATA_BIGMEM = f.read() - if has_cmdline_bunzip2: def decompress(self, data): pop = subprocess.Popen("bunzip2", shell=True, @@ -328,23 +325,20 @@ self.assertRaises(ValueError, f.readline) self.assertRaises(ValueError, f.readlines) - def test_read_truncated(self): - # Drop the eos_magic field (6 bytes) and CRC (4 bytes). - truncated = self.DATA[:-10] - with open(self.filename, 'wb') as f: - f.write(truncated) - with BZ2File(self.filename) as f: - self.assertRaises(EOFError, f.read) - with BZ2File(self.filename) as f: - self.assertEqual(f.read(len(self.TEXT)), self.TEXT) - self.assertRaises(EOFError, f.read, 1) - # Incomplete 4-byte file header, and block header of at least 146 bits. - for i in range(22): - with open(self.filename, 'wb') as f: - f.write(truncated[:i]) - with BZ2File(self.filename) as f: - self.assertRaises(EOFError, f.read, 1) - + @unittest.skipIf(sys.platform == 'win32', + 'test depends on being able to delete a still-open file,' + ' which is not possible on Windows') + def testInitNonExistentFile(self): + # Issue #19878: Should not segfault when __init__ with non-existent + # file for the second time. + self.createTempFile() + # Test close(): + with BZ2File(self.filename, "wb") as f: + self.assertRaises(IOError, f.__init__, "non-existent-file") + # Test object deallocation without call to close(): + f = bz2.BZ2File(self.filename) + self.assertRaises(IOError, f.__init__, "non-existent-file") + del f class BZ2CompressorTest(BaseTest): def testCompress(self): @@ -431,9 +425,10 @@ # Issue #14398: decompression fails when output data is >=2GB. if size < _4G: self.skipTest("Test needs 5GB of memory to run.") - text = bz2.BZ2Decompressor().decompress(self.DATA_BIGMEM) + compressed = bz2.compress("a" * _4G) + text = bz2.BZ2Decompressor().decompress(compressed) self.assertEqual(len(text), _4G) - self.assertEqual(text.strip("\0"), "") + self.assertEqual(text.strip("a"), "") class FuncTest(BaseTest): @@ -482,9 +477,10 @@ # Issue #14398: decompression fails when output data is >=2GB. if size < _4G: self.skipTest("Test needs 5GB of memory to run.") - text = bz2.decompress(self.DATA_BIGMEM) + compressed = bz2.compress("a" * _4G) + text = bz2.decompress(compressed) self.assertEqual(len(text), _4G) - self.assertEqual(text.strip("\0"), "") + self.assertEqual(text.strip("a"), "") def test_main(): test_support.run_unittest( diff --git a/lib-python/2.7/test/testbz2_bigmem.bz2 b/lib-python/2.7/test/testbz2_bigmem.bz2 deleted file mode 100644 index c9a4616c8053b1c92a45023635c8610c26299fc2..0000000000000000000000000000000000000000 GIT binary patch [stripped] -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sat Jan 25 23:56:24 2014 From: jython-checkins at python.org (jeff.allen) Date: Sat, 25 Jan 2014 23:56:24 +0100 (CET) Subject: [Jython-checkins] =?utf-8?q?jython=3A_Fixes_type_of_time=2Estrpti?= =?utf-8?q?me_as_per_issue_=231964_part_2=2E?= Message-ID: <3fBXdh4hs0z7LlM@mail.python.org> http://hg.python.org/jython/rev/57232db660c9 changeset: 7179:57232db660c9 user: Santoso Wijaya date: Sat Jan 25 20:05:48 2014 +0000 summary: Fixes type of time.strptime as per issue #1964 part 2. Fallback to python from native code used the wrong function, revealed by original %f fix. files: Lib/test/test_strptime_jy.py | 2 +- src/org/python/modules/time/Time.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_strptime_jy.py b/Lib/test/test_strptime_jy.py --- a/Lib/test/test_strptime_jy.py +++ b/Lib/test/test_strptime_jy.py @@ -20,7 +20,7 @@ def test_issue1964(self): d = strptime('0', '%f') - self.assertEqual(0, d[1]) + self.assertEqual(1900, d.tm_year) def test_main(): test_support.run_unittest( diff --git a/src/org/python/modules/time/Time.java b/src/org/python/modules/time/Time.java --- a/src/org/python/modules/time/Time.java +++ b/src/org/python/modules/time/Time.java @@ -688,7 +688,7 @@ */ private static PyTuple pystrptime(String data_string, String format) { return (PyTuple) __builtin__.__import__("_strptime") - .invoke("_strptime", + .invoke("_strptime_time", Py.newUnicode(data_string), Py.newUnicode(format)); } -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sat Jan 25 23:56:26 2014 From: jython-checkins at python.org (jeff.allen) Date: Sat, 25 Jan 2014 23:56:26 +0100 (CET) Subject: [Jython-checkins] =?utf-8?q?jython_=28merge_default_-=3E_default?= =?utf-8?q?=29=3A_Merge_to_trunk?= Message-ID: <3fBXdk0dWsz7Lm5@mail.python.org> http://hg.python.org/jython/rev/709791a0cea2 changeset: 7180:709791a0cea2 parent: 7175:b4ae9e2893c8 parent: 7179:57232db660c9 user: Jeff Allen date: Sat Jan 25 20:31:35 2014 +0000 summary: Merge to trunk files: Lib/test/test_httplib.py | 2 +- Lib/test/test_httpservers.py | 15 ++-- Lib/test/test_strptime_jy.py | 2 +- lib-python/2.7/test/test_bz2.py | 44 +++++------- lib-python/2.7/test/testbz2_bigmem.bz2 | Bin src/org/python/modules/time/Time.java | 2 +- 6 files changed, 31 insertions(+), 34 deletions(-) diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -201,7 +201,7 @@ if resp.read() != "": self.fail("Did not expect response from HEAD request") - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_send_file(self): expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ 'Accept-Encoding: identity\r\nContent-Length:' diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py --- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -189,7 +189,7 @@ def test_request_line_trimming(self): self.con._http_vsn_str = 'HTTP/1.1\n' - self.con.putrequest('GET', '/') + self.con.putrequest('XYZBOGUS', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 501) @@ -216,8 +216,9 @@ self.assertEqual(res.status, 501) def test_version_none(self): + # Test that a valid method is rejected when not HTTP/1.x self.con._http_vsn_str = '' - self.con.putrequest('PUT', '/') + self.con.putrequest('CUSTOM', '/') self.con.endheaders() res = self.con.getresponse() self.assertEqual(res.status, 400) @@ -460,13 +461,13 @@ msg='path = %r\nGot: %r\nWanted: %r' % (path, actual, expected)) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_headers_and_content(self): res = self.request('/cgi-bin/file1.py') self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_post(self): params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456}) headers = {'Content-type' : 'application/x-www-form-urlencoded'} @@ -479,7 +480,7 @@ res.read() self.assertEqual(res.status, 404) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_authorization(self): headers = {'Authorization' : 'Basic %s' % base64.b64encode('username:pass')} @@ -487,14 +488,14 @@ self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_no_leading_slash(self): # http://bugs.python.org/issue2254 res = self.request('cgi-bin/file1.py') self.assertEqual(('Hello World\n', 'text/html', 200), (res.read(), res.getheader('Content-type'), res.status)) - @unittest.skipIf(test_support.is_jython, "FIME: not working on Jython") + @unittest.skipIf(test_support.is_jython, "FIXME: not working on Jython") def test_os_environ_is_not_altered(self): signature = "Test CGI Server" os.environ['SERVER_SOFTWARE'] = signature diff --git a/Lib/test/test_strptime_jy.py b/Lib/test/test_strptime_jy.py --- a/Lib/test/test_strptime_jy.py +++ b/Lib/test/test_strptime_jy.py @@ -20,7 +20,7 @@ def test_issue1964(self): d = strptime('0', '%f') - self.assertEqual(0, d[1]) + self.assertEqual(1900, d.tm_year) def test_main(): test_support.run_unittest( diff --git a/lib-python/2.7/test/test_bz2.py b/lib-python/2.7/test/test_bz2.py --- a/lib-python/2.7/test/test_bz2.py +++ b/lib-python/2.7/test/test_bz2.py @@ -25,9 +25,6 @@ DATA_CRLF = 'BZh91AY&SY\xaez\xbbN\x00\x01H\xdf\x80\x00\x12@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe0@\x01\xbc\xc6`\x86*\x8d=M\xa9\x9a\x86\xd0L@\x0fI\xa6!\xa1\x13\xc8\x88jdi\x8d@\x03@\x1a\x1a\x0c\x0c\x83 \x00\xc4h2\x19\x01\x82D\x84e\t\xe8\x99\x89\x19\x1ah\x00\r\x1a\x11\xaf\x9b\x0fG\xf5(\x1b\x1f?\t\x12\xcf\xb5\xfc\x95E\x00ps\x89\x12^\xa4\xdd\xa2&\x05(\x87\x04\x98\x89u\xe40%\xb6\x19\'\x8c\xc4\x89\xca\x07\x0e\x1b!\x91UIFU%C\x994!DI\xd2\xfa\xf0\xf1N8W\xde\x13A\xf5\x9cr%?\x9f3;I45A\xd1\x8bT\xb1\xa4\xc7\x8d\x1a\\"\xad\xa1\xabyBg\x15\xb9l\x88\x88\x91k"\x94\xa4\xd4\x89\xae*\xa6\x0b\x10\x0c\xd6\xd4m\xe86\xec\xb5j\x8a\x86j\';\xca.\x01I\xf2\xaaJ\xe8\x88\x8cU+t3\xfb\x0c\n\xa33\x13r2\r\x16\xe0\xb3(\xbf\x1d\x83r\xe7M\xf0D\x1365\xd8\x88\xd3\xa4\x92\xcb2\x06\x04\\\xc1\xb0\xea//\xbek&\xd8\xe6+t\xe5\xa1\x13\xada\x16\xder5"w]\xa2i\xb7[\x97R \xe2IT\xcd;Z\x04dk4\xad\x8a\t\xd3\x81z\x10\xf1:^`\xab\x1f\xc5\xdc\x91N\x14$+\x9e\xae\xd3\x80' EMPTY_DATA = 'BZh9\x17rE8P\x90\x00\x00\x00\x00' - with open(findfile("testbz2_bigmem.bz2"), "rb") as f: - DATA_BIGMEM = f.read() - if has_cmdline_bunzip2: def decompress(self, data): pop = subprocess.Popen("bunzip2", shell=True, @@ -328,23 +325,20 @@ self.assertRaises(ValueError, f.readline) self.assertRaises(ValueError, f.readlines) - def test_read_truncated(self): - # Drop the eos_magic field (6 bytes) and CRC (4 bytes). - truncated = self.DATA[:-10] - with open(self.filename, 'wb') as f: - f.write(truncated) - with BZ2File(self.filename) as f: - self.assertRaises(EOFError, f.read) - with BZ2File(self.filename) as f: - self.assertEqual(f.read(len(self.TEXT)), self.TEXT) - self.assertRaises(EOFError, f.read, 1) - # Incomplete 4-byte file header, and block header of at least 146 bits. - for i in range(22): - with open(self.filename, 'wb') as f: - f.write(truncated[:i]) - with BZ2File(self.filename) as f: - self.assertRaises(EOFError, f.read, 1) - + @unittest.skipIf(sys.platform == 'win32', + 'test depends on being able to delete a still-open file,' + ' which is not possible on Windows') + def testInitNonExistentFile(self): + # Issue #19878: Should not segfault when __init__ with non-existent + # file for the second time. + self.createTempFile() + # Test close(): + with BZ2File(self.filename, "wb") as f: + self.assertRaises(IOError, f.__init__, "non-existent-file") + # Test object deallocation without call to close(): + f = bz2.BZ2File(self.filename) + self.assertRaises(IOError, f.__init__, "non-existent-file") + del f class BZ2CompressorTest(BaseTest): def testCompress(self): @@ -431,9 +425,10 @@ # Issue #14398: decompression fails when output data is >=2GB. if size < _4G: self.skipTest("Test needs 5GB of memory to run.") - text = bz2.BZ2Decompressor().decompress(self.DATA_BIGMEM) + compressed = bz2.compress("a" * _4G) + text = bz2.BZ2Decompressor().decompress(compressed) self.assertEqual(len(text), _4G) - self.assertEqual(text.strip("\0"), "") + self.assertEqual(text.strip("a"), "") class FuncTest(BaseTest): @@ -482,9 +477,10 @@ # Issue #14398: decompression fails when output data is >=2GB. if size < _4G: self.skipTest("Test needs 5GB of memory to run.") - text = bz2.decompress(self.DATA_BIGMEM) + compressed = bz2.compress("a" * _4G) + text = bz2.decompress(compressed) self.assertEqual(len(text), _4G) - self.assertEqual(text.strip("\0"), "") + self.assertEqual(text.strip("a"), "") def test_main(): test_support.run_unittest( diff --git a/lib-python/2.7/test/testbz2_bigmem.bz2 b/lib-python/2.7/test/testbz2_bigmem.bz2 deleted file mode 100644 index c9a4616c8053b1c92a45023635c8610c26299fc2..0000000000000000000000000000000000000000 GIT binary patch [stripped] diff --git a/src/org/python/modules/time/Time.java b/src/org/python/modules/time/Time.java --- a/src/org/python/modules/time/Time.java +++ b/src/org/python/modules/time/Time.java @@ -688,7 +688,7 @@ */ private static PyTuple pystrptime(String data_string, String format) { return (PyTuple) __builtin__.__import__("_strptime") - .invoke("_strptime", + .invoke("_strptime_time", Py.newUnicode(data_string), Py.newUnicode(format)); } -- Repository URL: http://hg.python.org/jython