From jython-checkins at python.org Sat May 7 23:37:58 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sat, 07 May 2011 23:37:58 +0200 Subject: [Jython-checkins] jython (2.5): remove/hardcode more svn keywords I forgot before Message-ID: http://hg.python.org/jython/rev/af8a3b6579e9 changeset: 6198:af8a3b6579e9 branch: 2.5 parent: 6196:fd2130e12b7c user: Philip Jenvey date: Sat May 07 14:36:09 2011 -0700 summary: remove/hardcode more svn keywords I forgot before files: Lib/test/zxjdbc/test.xml | 2 -- Lib/xml/__init__.py | 5 +---- Misc/make_errno.py | 2 -- 3 files changed, 1 insertions(+), 8 deletions(-) diff --git a/Lib/test/zxjdbc/test.xml b/Lib/test/zxjdbc/test.xml --- a/Lib/test/zxjdbc/test.xml +++ b/Lib/test/zxjdbc/test.xml @@ -3,8 +3,6 @@ diff --git a/Lib/xml/__init__.py b/Lib/xml/__init__.py --- a/Lib/xml/__init__.py +++ b/Lib/xml/__init__.py @@ -13,10 +13,7 @@ __all__ = ['dom', 'sax'] -# When being checked-out without options, this has the form -# "Revision: x.y " -# When exported using -kv, it is "x.y". -__version__ = "$Revision$".split()[-2:][0] +__version__ = "7290" _MINIMUM_XMLPLUS_VERSION = (0, 8, 5) diff --git a/Misc/make_errno.py b/Misc/make_errno.py --- a/Misc/make_errno.py +++ b/Misc/make_errno.py @@ -1,7 +1,5 @@ # Asynchronous sockets in Jython. # -# $Id$ -# # Copyright (c) 2002 brian zimmer ''' -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sat May 7 23:37:58 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sat, 07 May 2011 23:37:58 +0200 Subject: [Jython-checkins] jython (merge 2.5 -> default): merge with 2.5, remove more svn keywords Message-ID: http://hg.python.org/jython/rev/f77a4bf6b24d changeset: 6199:f77a4bf6b24d parent: 6197:0c4ce8b0156c parent: 6198:af8a3b6579e9 user: Philip Jenvey date: Sat May 07 14:37:21 2011 -0700 summary: merge with 2.5, remove more svn keywords files: Lib/test/zxjdbc/test.xml | 2 -- Lib/xml/__init__.py | 5 ----- Misc/make_errno.py | 2 -- 3 files changed, 0 insertions(+), 9 deletions(-) diff --git a/Lib/test/zxjdbc/test.xml b/Lib/test/zxjdbc/test.xml --- a/Lib/test/zxjdbc/test.xml +++ b/Lib/test/zxjdbc/test.xml @@ -3,8 +3,6 @@ diff --git a/Lib/xml/__init__.py b/Lib/xml/__init__.py --- a/Lib/xml/__init__.py +++ b/Lib/xml/__init__.py @@ -13,11 +13,6 @@ __all__ = ['dom', 'sax'] -# When being checked-out without options, this has the form -# "Revision: x.y " -# When exported using -kv, it is "x.y". -__version__ = "$Revision$".split()[-2:][0] - _MINIMUM_XMLPLUS_VERSION = (0, 8, 5) diff --git a/Misc/make_errno.py b/Misc/make_errno.py --- a/Misc/make_errno.py +++ b/Misc/make_errno.py @@ -1,7 +1,5 @@ # Asynchronous sockets in Jython. # -# $Id$ -# # Copyright (c) 2002 brian zimmer ''' -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sat May 7 23:54:30 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sat, 07 May 2011 23:54:30 +0200 Subject: [Jython-checkins] jython (2.5): hg version support Message-ID: http://hg.python.org/jython/rev/f38f32d05761 changeset: 6200:f38f32d05761 branch: 2.5 parent: 6198:af8a3b6579e9 user: Philip Jenvey date: Sun Mar 20 06:07:17 2011 +0000 summary: hg version support (transplanted from 5ea8da7349edef793af8a3714517263735f5cf01) files: build.xml | 28 ++++++++++- src/org/python/Version.java | 36 ++++++++++++++ src/org/python/core/PySystemState.java | 4 + 3 files changed, 67 insertions(+), 1 deletions(-) diff --git a/build.xml b/build.xml --- a/build.xml +++ b/build.xml @@ -398,10 +398,33 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -416,7 +439,10 @@ jython.release_serial=${jython.release_serial} jython.build.date=${build.date} jython.build.time=${build.time} -jython.build.svn_revision=${build.svn.revision} +jython.build.svn_revision=${build.svn.revision} +jython.build.hg_branch=${build.hg.branch} +jython.build.hg_tag=${build.hg.tag} +jython.build.hg_version=${build.hg.version} diff --git a/src/org/python/Version.java b/src/org/python/Version.java --- a/src/org/python/Version.java +++ b/src/org/python/Version.java @@ -34,6 +34,8 @@ public static String DATE; public static String TIME; public static String SVN_REVISION; + /** Current hg global revision id (hg id -i). */ + public static String HG_VERSION; /** Determined from headURL, branch is the path under the * subversion root, e.g. branches/asm. */ @@ -42,6 +44,12 @@ /** Short version of branch, e.g. asm. */ public static String SHORT_BRANCH; + /** Current hg branch (hg id -b). */ + public static String HG_BRANCH; + + /** Current hg tag (hg id -t), e.g. 'tip'. */ + public static String HG_TAG; + /** The flags that are set by default in a code object. */ private static final Collection defaultCodeFlags = Arrays.asList( CodeFlag.CO_NESTED, CodeFlag.CO_GENERATOR_ALLOWED); @@ -103,6 +111,9 @@ DATE = properties.getProperty("jython.build.date"); TIME = properties.getProperty("jython.build.time"); SVN_REVISION = properties.getProperty("jython.build.svn_revision"); + HG_BRANCH = properties.getProperty("jython.build.hg_branch"); + HG_TAG = properties.getProperty("jython.build.hg_tag"); + HG_VERSION = properties.getProperty("jython.build.hg_version"); } catch (IOException ioe) { System.err.println("There was a problem loading ".concat(versionProperties) .concat(":")); @@ -137,6 +148,21 @@ } /** + * Return the current hg version number. May be an empty string on environments that + * can't determine it. + */ + public static String getHGVersion() { + return HG_VERSION; + } + + /** + * Return the current hg identifier name, either the current branch or tag. + */ + public static String getHGIdentifier() { + return "".equals(HG_TAG) || "tip".equals(HG_TAG) ? HG_BRANCH : HG_TAG; + } + + /** * Return the current build information, including revision and * timestamp. */ @@ -148,6 +174,16 @@ } /** + * Return the current build information, including revision and timestamp. + */ + public static String getBuildInfoHG() { + String revision = getHGVersion(); + String sep = "".equals(revision) ? "" : ":"; + String hgId = getHGIdentifier(); + return String.format("%s%s%s, %.20s, %.9s", hgId, sep, revision, DATE, TIME); + } + + /** * Describe the current Java VM. */ public static String getVM() { diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java --- a/src/org/python/core/PySystemState.java +++ b/src/org/python/core/PySystemState.java @@ -66,6 +66,8 @@ public final static int maxunicode = 1114111; public static PyTuple subversion; + + public static PyTuple _mercurial; /** * The copyright notice for this release. */ @@ -946,6 +948,8 @@ Py.newInteger(Version.PY_RELEASE_SERIAL)); subversion = new PyTuple(Py.newString("Jython"), Py.newString(Version.BRANCH), Py.newString(Version.SVN_REVISION)); + _mercurial = new PyTuple(Py.newString("Jython"), Py.newString(Version.getHGIdentifier()), + Py.newString(Version.getHGVersion())); } public static boolean isPackageCacheEnabled() { -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sat May 7 23:54:30 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sat, 07 May 2011 23:54:30 +0200 Subject: [Jython-checkins] jython (2.5): auto-toggle hg/svn version support Message-ID: http://hg.python.org/jython/rev/6addc109c69c changeset: 6201:6addc109c69c branch: 2.5 user: Philip Jenvey date: Fri Apr 01 05:22:39 2011 +0000 summary: auto-toggle hg/svn version support (transplanted from a828011c71d594f41e46ff425f2a31185ff3acbb) files: build.xml | 42 +++++++++++++++++------- src/org/python/Version.java | 3 + 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/build.xml b/build.xml --- a/build.xml +++ b/build.xml @@ -393,38 +393,56 @@ - - - + + + + + + + + + + - - + - + - + - + + + + + + + + + + + + + + + - - - + + diff --git a/src/org/python/Version.java b/src/org/python/Version.java --- a/src/org/python/Version.java +++ b/src/org/python/Version.java @@ -167,6 +167,9 @@ * timestamp. */ public static String getBuildInfo() { + if (HG_VERSION != null && !"".equals(HG_VERSION)) { + return getBuildInfoHG(); + } String revision = getSubversionRevision(); String sep = "".equals(revision) ? "" : ":"; String branch = getSubversionShortBranch(); -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sat May 7 23:54:30 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sat, 07 May 2011 23:54:30 +0200 Subject: [Jython-checkins] jython (merge 2.5 -> default): merge with 2.5 Message-ID: http://hg.python.org/jython/rev/fa7102ff8ba9 changeset: 6202:fa7102ff8ba9 parent: 6199:f77a4bf6b24d parent: 6201:6addc109c69c user: Philip Jenvey date: Sat May 07 14:54:10 2011 -0700 summary: merge with 2.5 files: -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sun May 8 00:09:09 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sun, 08 May 2011 00:09:09 +0200 Subject: [Jython-checkins] jython (2.5): remove svn version support, hardcode sys.subversion Message-ID: http://hg.python.org/jython/rev/250d80c48c23 changeset: 6203:250d80c48c23 branch: 2.5 parent: 6201:6addc109c69c user: Philip Jenvey date: Sat May 07 15:04:50 2011 -0700 summary: remove svn version support, hardcode sys.subversion files: build.xml | 19 +--- src/org/python/Version.java | 79 +------------- src/org/python/core/PySystemState.java | 3 +- 3 files changed, 7 insertions(+), 94 deletions(-) diff --git a/build.xml b/build.xml --- a/build.xml +++ b/build.xml @@ -421,28 +421,12 @@ - - - - - - - - - - - - - - - - + - @@ -457,7 +441,6 @@ jython.release_serial=${jython.release_serial} jython.build.date=${build.date} jython.build.time=${build.time} -jython.build.svn_revision=${build.svn.revision} jython.build.hg_branch=${build.hg.branch} jython.build.hg_tag=${build.hg.tag} jython.build.hg_version=${build.hg.version} diff --git a/src/org/python/Version.java b/src/org/python/Version.java --- a/src/org/python/Version.java +++ b/src/org/python/Version.java @@ -30,19 +30,9 @@ public static int PY_RELEASE_LEVEL; public static int PY_RELEASE_SERIAL; - /** Timestamp and revision number of the current build. */ + /** Timestamp of the current build. */ public static String DATE; public static String TIME; - public static String SVN_REVISION; - /** Current hg global revision id (hg id -i). */ - public static String HG_VERSION; - - /** Determined from headURL, branch is the path under the - * subversion root, e.g. branches/asm. */ - public static String BRANCH; - - /** Short version of branch, e.g. asm. */ - public static String SHORT_BRANCH; /** Current hg branch (hg id -b). */ public static String HG_BRANCH; @@ -50,44 +40,15 @@ /** Current hg tag (hg id -t), e.g. 'tip'. */ public static String HG_TAG; + /** Current hg global revision id (hg id -i). */ + public static String HG_VERSION; + /** The flags that are set by default in a code object. */ private static final Collection defaultCodeFlags = Arrays.asList( CodeFlag.CO_NESTED, CodeFlag.CO_GENERATOR_ALLOWED); - private static final String headURL = - "$HeadURL$"; - static { - initVersion(); - } - - /** - * Load the version information and determine BRANCH and - * SHORT_BRANCH from headURL. - */ - private static void initVersion() { loadProperties(); - - int jython = headURL.indexOf("/jython/"); - if (jython > -1) { - int brStart = jython + 8; - String end = headURL.substring(brStart, headURL.length()); - - if (end.startsWith("trunk/")) { - BRANCH = SHORT_BRANCH = "trunk"; - return; - } else if (end.startsWith("tags/") || end.startsWith("branches/")) { - int brEnd = end.indexOf('/'); - int brEnd2 = end.indexOf('/', brEnd + 1); - if (brEnd2 > -1) { - BRANCH = end.substring(0, brEnd2); - SHORT_BRANCH = end.substring(brEnd + 1, brEnd2); - return; - } - } - } - BRANCH = ""; - SHORT_BRANCH = "unknown"; } /** @@ -110,7 +71,6 @@ PY_RELEASE_SERIAL = Integer.valueOf(properties.getProperty("jython.release_serial")); DATE = properties.getProperty("jython.build.date"); TIME = properties.getProperty("jython.build.time"); - SVN_REVISION = properties.getProperty("jython.build.svn_revision"); HG_BRANCH = properties.getProperty("jython.build.hg_branch"); HG_TAG = properties.getProperty("jython.build.hg_tag"); HG_VERSION = properties.getProperty("jython.build.hg_version"); @@ -133,21 +93,6 @@ } /** - * Return the current subversion revision number. May be an empty - * string on environments that can't determine it. - */ - public static String getSubversionRevision() { - return SVN_REVISION; - } - - /** - * Return the current branch name. - */ - public static String getSubversionShortBranch() { - return SHORT_BRANCH; - } - - /** * Return the current hg version number. May be an empty string on environments that * can't determine it. */ @@ -163,23 +108,9 @@ } /** - * Return the current build information, including revision and - * timestamp. + * Return the current build information, including revision and timestamp. */ public static String getBuildInfo() { - if (HG_VERSION != null && !"".equals(HG_VERSION)) { - return getBuildInfoHG(); - } - String revision = getSubversionRevision(); - String sep = "".equals(revision) ? "" : ":"; - String branch = getSubversionShortBranch(); - return String.format("%s%s%s, %.20s, %.9s", branch, sep, revision, DATE, TIME); - } - - /** - * Return the current build information, including revision and timestamp. - */ - public static String getBuildInfoHG() { String revision = getHGVersion(); String sep = "".equals(revision) ? "" : ":"; String hgId = getHGIdentifier(); diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java --- a/src/org/python/core/PySystemState.java +++ b/src/org/python/core/PySystemState.java @@ -946,8 +946,7 @@ Py.newInteger(Version.PY_MICRO_VERSION), Py.newString(s), Py.newInteger(Version.PY_RELEASE_SERIAL)); - subversion = new PyTuple(Py.newString("Jython"), Py.newString(Version.BRANCH), - Py.newString(Version.SVN_REVISION)); + subversion = new PyTuple(Py.newString("Jython"), Py.EmptyString, Py.EmptyString); _mercurial = new PyTuple(Py.newString("Jython"), Py.newString(Version.getHGIdentifier()), Py.newString(Version.getHGVersion())); } -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sun May 8 00:09:09 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sun, 08 May 2011 00:09:09 +0200 Subject: [Jython-checkins] jython (merge 2.5 -> default): merge with 2.5 and remove sys.subversion Message-ID: http://hg.python.org/jython/rev/416db1c28e21 changeset: 6204:416db1c28e21 parent: 6202:fa7102ff8ba9 parent: 6203:250d80c48c23 user: Philip Jenvey date: Sat May 07 15:08:41 2011 -0700 summary: merge with 2.5 and remove sys.subversion files: build.xml | 19 +--- src/org/python/Version.java | 79 +------------- src/org/python/core/PySystemState.java | 4 - 3 files changed, 6 insertions(+), 96 deletions(-) diff --git a/build.xml b/build.xml --- a/build.xml +++ b/build.xml @@ -421,28 +421,12 @@ - - - - - - - - - - - - - - - - + - @@ -457,7 +441,6 @@ jython.release_serial=${jython.release_serial} jython.build.date=${build.date} jython.build.time=${build.time} -jython.build.svn_revision=${build.svn.revision} jython.build.hg_branch=${build.hg.branch} jython.build.hg_tag=${build.hg.tag} jython.build.hg_version=${build.hg.version} diff --git a/src/org/python/Version.java b/src/org/python/Version.java --- a/src/org/python/Version.java +++ b/src/org/python/Version.java @@ -30,19 +30,9 @@ public static int PY_RELEASE_LEVEL; public static int PY_RELEASE_SERIAL; - /** Timestamp and revision number of the current build. */ + /** Timestamp of the current build. */ public static String DATE; public static String TIME; - public static String SVN_REVISION; - /** Current hg global revision id (hg id -i). */ - public static String HG_VERSION; - - /** Determined from headURL, branch is the path under the - * subversion root, e.g. branches/asm. */ - public static String BRANCH; - - /** Short version of branch, e.g. asm. */ - public static String SHORT_BRANCH; /** Current hg branch (hg id -b). */ public static String HG_BRANCH; @@ -50,44 +40,15 @@ /** Current hg tag (hg id -t), e.g. 'tip'. */ public static String HG_TAG; + /** Current hg global revision id (hg id -i). */ + public static String HG_VERSION; + /** The flags that are set by default in a code object. */ private static final Collection defaultCodeFlags = Arrays.asList( CodeFlag.CO_NESTED, CodeFlag.CO_GENERATOR_ALLOWED, CodeFlag.CO_FUTURE_WITH_STATEMENT); - private static final String headURL = - "$HeadURL$"; - static { - initVersion(); - } - - /** - * Load the version information and determine BRANCH and - * SHORT_BRANCH from headURL. - */ - private static void initVersion() { loadProperties(); - - int jython = headURL.indexOf("/jython/"); - if (jython > -1) { - int brStart = jython + 8; - String end = headURL.substring(brStart, headURL.length()); - - if (end.startsWith("trunk/")) { - BRANCH = SHORT_BRANCH = "trunk"; - return; - } else if (end.startsWith("tags/") || end.startsWith("branches/")) { - int brEnd = end.indexOf('/'); - int brEnd2 = end.indexOf('/', brEnd + 1); - if (brEnd2 > -1) { - BRANCH = end.substring(0, brEnd2); - SHORT_BRANCH = end.substring(brEnd + 1, brEnd2); - return; - } - } - } - BRANCH = ""; - SHORT_BRANCH = "unknown"; } /** @@ -110,7 +71,6 @@ PY_RELEASE_SERIAL = Integer.valueOf(properties.getProperty("jython.release_serial")); DATE = properties.getProperty("jython.build.date"); TIME = properties.getProperty("jython.build.time"); - SVN_REVISION = properties.getProperty("jython.build.svn_revision"); HG_BRANCH = properties.getProperty("jython.build.hg_branch"); HG_TAG = properties.getProperty("jython.build.hg_tag"); HG_VERSION = properties.getProperty("jython.build.hg_version"); @@ -133,21 +93,6 @@ } /** - * Return the current subversion revision number. May be an empty - * string on environments that can't determine it. - */ - public static String getSubversionRevision() { - return SVN_REVISION; - } - - /** - * Return the current branch name. - */ - public static String getSubversionShortBranch() { - return SHORT_BRANCH; - } - - /** * Return the current hg version number. May be an empty string on environments that * can't determine it. */ @@ -163,23 +108,9 @@ } /** - * Return the current build information, including revision and - * timestamp. + * Return the current build information, including revision and timestamp. */ public static String getBuildInfo() { - if (HG_VERSION != null && !"".equals(HG_VERSION)) { - return getBuildInfoHG(); - } - String revision = getSubversionRevision(); - String sep = "".equals(revision) ? "" : ":"; - String branch = getSubversionShortBranch(); - return String.format("%s%s%s, %.20s, %.9s", branch, sep, revision, DATE, TIME); - } - - /** - * Return the current build information, including revision and timestamp. - */ - public static String getBuildInfoHG() { String revision = getHGVersion(); String sep = "".equals(revision) ? "" : ":"; String hgId = getHGIdentifier(); diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java --- a/src/org/python/core/PySystemState.java +++ b/src/org/python/core/PySystemState.java @@ -74,8 +74,6 @@ public final static Class flags = Options.class; - public static PyTuple subversion; - public static PyTuple _mercurial; /** * The copyright notice for this release. @@ -956,8 +954,6 @@ Py.newInteger(Version.PY_MICRO_VERSION), Py.newString(s), Py.newInteger(Version.PY_RELEASE_SERIAL)); - subversion = new PyTuple(Py.newString("Jython"), Py.newString(Version.BRANCH), - Py.newString(Version.SVN_REVISION)); _mercurial = new PyTuple(Py.newString("Jython"), Py.newString(Version.getHGIdentifier()), Py.newString(Version.getHGVersion())); } -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sun May 8 00:15:30 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sun, 08 May 2011 00:15:30 +0200 Subject: [Jython-checkins] jython (2.5): update maven scm info per hg Message-ID: http://hg.python.org/jython/rev/c61d91f0de79 changeset: 6205:c61d91f0de79 branch: 2.5 parent: 6203:250d80c48c23 user: Philip Jenvey date: Sat May 07 15:15:06 2011 -0700 summary: update maven scm info per hg files: maven/pom.xml | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/maven/pom.xml b/maven/pom.xml --- a/maven/pom.xml +++ b/maven/pom.xml @@ -23,6 +23,8 @@ - http://jython.svn.sourceforge.net/viewvc/jython/ + scm:hg:http://hg.python.org/jython + scm:hg:ssh://hg at hg.python.org/jython + http://hg.python.org/jython - \ No newline at end of file + -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Sun May 8 00:15:30 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sun, 08 May 2011 00:15:30 +0200 Subject: [Jython-checkins] jython (merge 2.5 -> default): merge with 2.5 Message-ID: http://hg.python.org/jython/rev/dbe48139a5ab changeset: 6206:dbe48139a5ab parent: 6204:416db1c28e21 parent: 6205:c61d91f0de79 user: Philip Jenvey date: Sat May 07 15:15:17 2011 -0700 summary: merge with 2.5 files: maven/pom.xml | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/maven/pom.xml b/maven/pom.xml --- a/maven/pom.xml +++ b/maven/pom.xml @@ -23,6 +23,8 @@ - http://jython.svn.sourceforge.net/viewvc/jython/ + scm:hg:http://hg.python.org/jython + scm:hg:ssh://hg at hg.python.org/jython + http://hg.python.org/jython - \ No newline at end of file + -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Thu May 12 03:00:40 2011 From: jython-checkins at python.org (philip.jenvey) Date: Thu, 12 May 2011 03:00:40 +0200 Subject: [Jython-checkins] jython: add -B command line arg (sys.dont_write_bytecode) Message-ID: http://hg.python.org/jython/rev/6de378e5a0a8 changeset: 6207:6de378e5a0a8 user: Philip Jenvey date: Wed May 11 17:57:45 2011 -0700 summary: add -B command line arg (sys.dont_write_bytecode) files: src/org/python/core/Options.java | 5 ++++- src/org/python/core/PySystemState.java | 4 ++++ src/org/python/core/imp.java | 4 +++- src/org/python/util/jython.java | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/org/python/core/Options.java b/src/org/python/core/Options.java --- a/src/org/python/core/Options.java +++ b/src/org/python/core/Options.java @@ -76,9 +76,12 @@ * binary mode */ public static boolean unbuffered = false; - /** Whether -3 (py3k warnings) were enabled via the command line. */ + /** Whether -3 (py3k warnings) was enabled via the command line. */ public static boolean py3kwarning = false; + /** Whether -B (don't write bytecode on import) was enabled via the command line. */ + public static boolean dontWriteBytecode = false; + //XXX: place holder public static int bytes_warning = 0; diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java --- a/src/org/python/core/PySystemState.java +++ b/src/org/python/core/PySystemState.java @@ -162,6 +162,9 @@ /** true when a SystemRestart is triggered. */ public boolean _systemRestart = false; + /** Whether bytecode should be written to disk on import. */ + public boolean dont_write_bytecode = false; + // Automatically close resources associated with a PySystemState when they get GCed private final PySystemStateCloser closer; private static final ReferenceQueue systemStateQueue = @@ -189,6 +192,7 @@ currentWorkingDir = new File("").getAbsolutePath(); + dont_write_bytecode = Options.dontWriteBytecode; py3kwarning = Options.py3kwarning; // Set up the initial standard ins and outs String mode = Options.unbuffered ? "b" : ""; diff --git a/src/org/python/core/imp.java b/src/org/python/core/imp.java --- a/src/org/python/core/imp.java +++ b/src/org/python/core/imp.java @@ -341,7 +341,9 @@ public static PyObject createFromSource(String name, InputStream fp, String filename, String outFilename, long mtime) { byte[] bytes = compileSource(name, fp, filename, mtime); - outFilename = cacheCompiledSource(filename, outFilename, bytes); + if (!Py.getSystemState().dont_write_bytecode) { + outFilename = cacheCompiledSource(filename, outFilename, bytes); + } Py.writeComment(IMPORT_LOG, "'" + name + "' as " + filename); diff --git a/src/org/python/util/jython.java b/src/org/python/util/jython.java --- a/src/org/python/util/jython.java +++ b/src/org/python/util/jython.java @@ -39,7 +39,7 @@ private static final String usage = usageHeader + "Options and arguments:\n" + //(and corresponding environment variables):\n" + - //"-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n" + + "-B : don't write .py[co] files on import\n" + // "; also PYTHONDONTWRITEBYTECODE=x\n" + "-c cmd : program passed in as string (terminates option list)\n" + //"-d : debug output from parser (also PYTHONDEBUG=x)\n" + "-Dprop=v : Set the property `prop' to value `v'\n"+ @@ -435,6 +435,8 @@ Options.verbose +=3 ; } else if (arg.equals("-S")) { Options.importSite = false; + } else if (arg.equals("-B")) { + Options.dontWriteBytecode = true; } else if (arg.startsWith("-c")) { runCommand = true; if (arg.length() > 2) { -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Thu May 12 03:31:11 2011 From: jython-checkins at python.org (philip.jenvey) Date: Thu, 12 May 2011 03:31:11 +0200 Subject: [Jython-checkins] jython (2.5): bump to 2.5.2+ Message-ID: http://hg.python.org/jython/rev/69dfd5ee9d84 changeset: 6208:69dfd5ee9d84 branch: 2.5 parent: 6205:c61d91f0de79 user: Philip Jenvey date: Wed May 11 18:29:52 2011 -0700 summary: bump to 2.5.2+ files: build.xml | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/build.xml b/build.xml --- a/build.xml +++ b/build.xml @@ -123,7 +123,7 @@ - + -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Thu May 12 03:31:11 2011 From: jython-checkins at python.org (philip.jenvey) Date: Thu, 12 May 2011 03:31:11 +0200 Subject: [Jython-checkins] jython (merge 2.5 -> default): merge with 2.5 Message-ID: http://hg.python.org/jython/rev/54ab8647cb83 changeset: 6209:54ab8647cb83 parent: 6207:6de378e5a0a8 parent: 6208:69dfd5ee9d84 user: Philip Jenvey date: Wed May 11 18:30:38 2011 -0700 summary: merge with 2.5 files: -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Tue May 17 04:32:56 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Tue, 17 May 2011 04:32:56 +0200 Subject: [Jython-checkins] jython: Grammar changes needed to support print_function. Message-ID: http://hg.python.org/jython/rev/1aed2fedd01b changeset: 6210:1aed2fedd01b user: Frank Wierzbicki date: Mon May 16 19:32:48 2011 -0700 summary: Grammar changes needed to support print_function. files: grammar/Python.g | 31 ++++++++++++++++++++++++++----- 1 files changed, 26 insertions(+), 5 deletions(-) diff --git a/grammar/Python.g b/grammar/Python.g --- a/grammar/Python.g +++ b/grammar/Python.g @@ -165,6 +165,8 @@ private String encoding; + private boolean printStatement = true; + public void setErrorHandler(ErrorHandler eh) { this.errorHandler = eh; actions.setErrorHandler(eh); @@ -374,6 +376,19 @@ ) ; +//not in CPython's Grammar file +// This is used to allow PRINT as a NAME for the __future__ print_function. +name_or_print + returns [Token tok] + : NAME { + $tok = $name_or_print.start; + } + | {!printStatement}? => PRINT { + $tok = $name_or_print.start; + } + ; + +//not in CPython's Grammar file //attr is here for Java compatibility. A Java foo.getIf() can be called from Jython as foo.if // so we need to support any keyword as an attribute. @@ -456,13 +471,13 @@ @after { $funcdef.tree = stype; } - : decorators? DEF NAME parameters COLON suite[false] + : decorators? DEF name_or_print parameters COLON suite[false] { Token t = $DEF; if ($decorators.start != null) { t = $decorators.start; } - stype = actions.makeFuncdef(t, $NAME, $parameters.args, $suite.stypes, $decorators.etypes); + stype = actions.makeFuncdef(t, $name_or_print.start, $parameters.args, $suite.stypes, $decorators.etypes); } ; @@ -584,7 +599,6 @@ //small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | // import_stmt | global_stmt | exec_stmt | assert_stmt) small_stmt : expr_stmt - | print_stmt | del_stmt | pass_stmt | flow_stmt @@ -592,6 +606,7 @@ | global_stmt | exec_stmt | assert_stmt + | {printStatement}? => print_stmt ; //expr_stmt: testlist (augassign (yield_expr|testlist) | @@ -916,6 +931,12 @@ } | i1=import_as_names { + String dottedText = $dotted_name.text; + String importText = $i1.text; + if (dottedText != null && dottedText.equals("__future__") && + importText != null && importText.equals("print_function")) { + printStatement = false; + } stype = new ImportFrom($FROM, actions.makeFromText($d, $dotted_name.names), actions.makeModuleNameNode($d, $dotted_name.names), actions.makeAliases($i1.atypes), actions.makeLevel($d)); @@ -1691,9 +1712,9 @@ { etype = new Repr($lb, actions.castExpr($testlist.tree)); } - | NAME + | name_or_print { - etype = new Name($NAME, $NAME.text, $expr::ctype); + etype = new Name($name_or_print.start, $name_or_print.text, $expr::ctype); } | INT { -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Wed May 18 02:53:30 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Wed, 18 May 2011 02:53:30 +0200 Subject: [Jython-checkins] jython: Reverted some name changes, better print_function support. Message-ID: http://hg.python.org/jython/rev/1219ca492d71 changeset: 6214:1219ca492d71 user: Frank Wierzbicki date: Fri May 13 22:28:07 2011 -0700 summary: Reverted some name changes, better print_function support. files: src/org/python/core/StdoutWrapper.java | 137 +++++++----- src/org/python/core/__builtin__.java | 10 +- 2 files changed, 88 insertions(+), 59 deletions(-) diff --git a/src/org/python/core/StdoutWrapper.java b/src/org/python/core/StdoutWrapper.java --- a/src/org/python/core/StdoutWrapper.java +++ b/src/org/python/core/StdoutWrapper.java @@ -99,11 +99,60 @@ } } - public void print(PyObject obj, boolean space, boolean newline) { - print(new PyObject[] {obj}, space, newline, null); + private String printToFile(PyFile file, PyObject o) { + String s; + if (o instanceof PyUnicode && file.encoding != null) { + s = ((PyUnicode)o).encode(file.encoding, "strict"); + } else { + s = o.__str__().toString(); + } + file.write(s); + return s; } - public void print(PyObject[] objs, boolean space, boolean newline, PyObject sep) { + private String printToFileWriter(PyFileWriter file, PyObject o) { + // since we are outputting directly to a character stream, + // avoid doing an encoding + String s; + if (o instanceof PyString) { + s = ((PyString) o).getString(); + } else { + s = o.toString(); + } + file.write(s); + return s; + } + + private void printToObject(PyObject file, PyObject o) { + if (!(o instanceof PyUnicode)) { + o = o.__str__(); + } + file.invoke("write", o); + } + + /** + * For __future__ print_function. + */ + public void print(PyObject[] args, PyObject sep, PyObject end) { + PyObject out = myFile(); + + if (out instanceof PyFile) { + PyFile file = (PyFile)out; + for (int i=0;i keyargs = new HashMap(); + //XXX: preloading defaults for now. + keyargs.put("sep", Py.newString(" ")); + keyargs.put("end", Py.newString("\n")); int kwlen = kwds.length; for (int i=kwlen; i>0; i--) { keyargs.put(kwds[kwlen - i], args[args.length - i]); @@ -1352,16 +1355,17 @@ } private static PyObject print(PyObject values[], PyObject sep, PyObject end, PyObject file) { - StdoutWrapper out = Py.stdout; + StdoutWrapper out; if (file != null && file != Py.None) { out = new FixedFileWrapper(file); + } else { + out = Py.stdout; } if (values.length == 0) { out.println(); } else { - boolean newline = end == null || end.__nonzero__(); - out.print(values, false, newline, sep); + out.print(values, sep, end); } return Py.None; } -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Wed May 18 02:53:30 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Wed, 18 May 2011 02:53:30 +0200 Subject: [Jython-checkins] jython: Grammar changes, flag support, and some scaffolding to support print_function. Message-ID: http://hg.python.org/jython/rev/396bb06115a2 changeset: 6211:396bb06115a2 parent: 6206:dbe48139a5ab user: Frank Wierzbicki date: Wed May 11 05:04:09 2011 -0700 summary: Grammar changes, flag support, and some scaffolding to support print_function. files: grammar/Python.g | 28 +++++++++++-- src/org/python/compiler/Future.java | 2 + src/org/python/core/CodeFlag.java | 7 +++- src/org/python/core/FutureFeature.java | 4 ++ src/org/python/core/__builtin__.java | 25 ++++++++++++ 5 files changed, 60 insertions(+), 6 deletions(-) diff --git a/grammar/Python.g b/grammar/Python.g --- a/grammar/Python.g +++ b/grammar/Python.g @@ -165,6 +165,8 @@ private String encoding; + private boolean printStatement = true; + public void setErrorHandler(ErrorHandler eh) { this.errorHandler = eh; actions.setErrorHandler(eh); @@ -374,6 +376,19 @@ ) ; +//not in CPython's Grammar file +// This is used to allow PRINT as a NAME for the __future__ print_function. +name_or_print + returns [Token tok] + : NAME { + $tok = $name_or_print.start; + } + | {!printStatement}? => PRINT { + $tok = $name_or_print.start; + } + ; + +//not in CPython's Grammar file //attr is here for Java compatibility. A Java foo.getIf() can be called from Jython as foo.if // so we need to support any keyword as an attribute. @@ -456,13 +471,13 @@ @after { $funcdef.tree = stype; } - : decorators? DEF NAME parameters COLON suite[false] + : decorators? DEF name_or_print parameters COLON suite[false] { Token t = $DEF; if ($decorators.start != null) { t = $decorators.start; } - stype = actions.makeFuncdef(t, $NAME, $parameters.args, $suite.stypes, $decorators.etypes); + stype = actions.makeFuncdef(t, $name_or_print.start, $parameters.args, $suite.stypes, $decorators.etypes); } ; @@ -584,7 +599,6 @@ //small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | // import_stmt | global_stmt | exec_stmt | assert_stmt) small_stmt : expr_stmt - | print_stmt | del_stmt | pass_stmt | flow_stmt @@ -592,6 +606,7 @@ | global_stmt | exec_stmt | assert_stmt + | {printStatement}? => print_stmt ; //expr_stmt: testlist (augassign (yield_expr|testlist) | @@ -916,6 +931,9 @@ } | i1=import_as_names { + if ($dotted_name.text.equals("__future__") && $i1.text.equals("print_function")) { + printStatement = false; + } stype = new ImportFrom($FROM, actions.makeFromText($d, $dotted_name.names), actions.makeModuleNameNode($d, $dotted_name.names), actions.makeAliases($i1.atypes), actions.makeLevel($d)); @@ -1691,9 +1709,9 @@ { etype = new Repr($lb, actions.castExpr($testlist.tree)); } - | NAME + | name_or_print { - etype = new Name($NAME, $NAME.text, $expr::ctype); + etype = new Name($name_or_print.start, $name_or_print.text, $expr::ctype); } | INT { diff --git a/src/org/python/compiler/Future.java b/src/org/python/compiler/Future.java --- a/src/org/python/compiler/Future.java +++ b/src/org/python/compiler/Future.java @@ -60,6 +60,8 @@ FutureFeature.with_statement.addTo(features); if (cflags.isFlagSet(CodeFlag.CO_FUTURE_ABSOLUTE_IMPORT)) FutureFeature.absolute_import.addTo(features); + if (cflags.isFlagSet(CodeFlag.CO_FUTURE_PRINT_FUNCTION)) + FutureFeature.print_function.addTo(features); } int beg = 0; List suite = null; diff --git a/src/org/python/core/CodeFlag.java b/src/org/python/core/CodeFlag.java --- a/src/org/python/core/CodeFlag.java +++ b/src/org/python/core/CodeFlag.java @@ -50,7 +50,12 @@ /** * With statement. */ - CO_FUTURE_WITH_STATEMENT(0x8000); + CO_FUTURE_WITH_STATEMENT(0x8000), + /** + * print function. + */ + CO_FUTURE_PRINT_FUNCTION(0x10000); + public final int flag; private static Iterable allFlags = Collections.unmodifiableList(Arrays.asList(values())); diff --git a/src/org/python/core/FutureFeature.java b/src/org/python/core/FutureFeature.java --- a/src/org/python/core/FutureFeature.java +++ b/src/org/python/core/FutureFeature.java @@ -24,6 +24,10 @@ */ with_statement(CodeFlag.CO_FUTURE_WITH_STATEMENT), /** + * Enables the print function. + */ + print_function(CodeFlag.CO_FUTURE_PRINT_FUNCTION), + /** * Use braces for block delimiters instead of indentation. */ braces { diff --git a/src/org/python/core/__builtin__.java b/src/org/python/core/__builtin__.java --- a/src/org/python/core/__builtin__.java +++ b/src/org/python/core/__builtin__.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -359,6 +360,7 @@ dict.__setitem__("all", new AllFunction()); dict.__setitem__("any", new AnyFunction()); dict.__setitem__("format", new FormatFunction()); + dict.__setitem__("print", new PrintFunction()); } public static PyObject abs(PyObject o) { @@ -1323,6 +1325,29 @@ } } +class PrintFunction extends PyBuiltinFunction { + PrintFunction() { + + super("print", + "print(value, ..., sep=' ', end='\\n', file=sys.stdout)\n\n" + + "Prints the values to a stream, or to sys.stdout by default.\n" + + "Optional keyword arguments:\n" + + "file: a file-like object (stream); defaults to the current sys.stdout.\n" + + "sep: string inserted between values, default a space.\n" + + "end: string appended after the last value, default a newline.\n"); + } + + @Override + public PyObject __call__(PyObject args[], String kwds[]) { + Map keyargs = new HashMap(); + int kwlen = kwds.length; + for (int i=kwlen;i>0;i--) { + keyargs.put(kwds[kwlen - i], args[args.length - i]); + } + return Py.None; + } +} + class MaxFunction extends PyBuiltinFunction { MaxFunction() { super("max", -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Wed May 18 02:53:30 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Wed, 18 May 2011 02:53:30 +0200 Subject: [Jython-checkins] jython: Add support for multiple objects passed to print. Message-ID: http://hg.python.org/jython/rev/67f89e017e31 changeset: 6212:67f89e017e31 user: Frank Wierzbicki date: Thu May 12 23:22:18 2011 -0700 summary: Add support for multiple objects passed to print. files: src/org/python/core/Py.java | 2 +- src/org/python/core/StdoutWrapper.java | 178 ++++++------ src/org/python/core/__builtin__.java | 21 +- 3 files changed, 115 insertions(+), 86 deletions(-) diff --git a/src/org/python/core/Py.java b/src/org/python/core/Py.java --- a/src/org/python/core/Py.java +++ b/src/org/python/core/Py.java @@ -2092,7 +2092,7 @@ } } - class FixedFileWrapper extends StdoutWrapper { +class FixedFileWrapper extends StdoutWrapper { private PyObject file; diff --git a/src/org/python/core/StdoutWrapper.java b/src/org/python/core/StdoutWrapper.java --- a/src/org/python/core/StdoutWrapper.java +++ b/src/org/python/core/StdoutWrapper.java @@ -16,20 +16,20 @@ return ss.stdout; } - protected void setObject(PySystemState ss, PyObject obj) { - ss.stdout = obj; + protected void setObject(PySystemState ss, PyObject out) { + ss.stdout = out; } protected PyObject myFile() { PySystemState ss = Py.getSystemState(); - PyObject obj = getObject(ss); - if (obj == null) { + PyObject out = getObject(ss); + if (out == null) { throw Py.AttributeError("missing sys." + this.name); } - if (obj.getJavaProxy() != null) { + if (out.getJavaProxy() != null) { PyFile f = null; - Object tojava = obj.__tojava__(OutputStream.class); + Object tojava = out.__tojava__(OutputStream.class); if (tojava != null && tojava != Py.NoConversion) { f = new PyFile((OutputStream)tojava); } @@ -38,17 +38,17 @@ return f; } } - return obj; + return out; } @Override public void flush() { - PyObject obj = myFile(); - if (obj instanceof PyFile) { - ((PyFile) obj).flush(); + PyObject out = myFile(); + if (out instanceof PyFile) { + ((PyFile) out).flush(); } else { try { - obj.invoke("flush"); + out.invoke("flush"); } catch (PyException pye) { // ok } @@ -56,12 +56,12 @@ } public void write(String s) { - PyObject obj = myFile(); + PyObject out = myFile(); - if (obj instanceof PyFile) { - ((PyFile) obj).write(s); + if (out instanceof PyFile) { + ((PyFile) out).write(s); } else { - obj.invoke("write", new PyString(s)); + out.invoke("write", new PyString(s)); } } @@ -76,55 +76,61 @@ } public void flushLine() { - PyObject obj = myFile(); + PyObject out = myFile(); - if (obj instanceof PyFile) { - PyFile file = (PyFile) obj; + if (out instanceof PyFile) { + PyFile file = (PyFile) out; if (file.softspace) { file.write("\n"); file.flush(); } file.softspace = false; } else { - PyObject ss = obj.__findattr__("softspace"); + PyObject ss = out.__findattr__("softspace"); if (ss != null && ss.__nonzero__()) { - obj.invoke("write", Py.Newline); + out.invoke("write", Py.Newline); } try { - obj.invoke("flush"); + out.invoke("flush"); } catch (PyException pye) { // ok } - obj.__setattr__("softspace", Py.Zero); + out.__setattr__("softspace", Py.Zero); } } - public void print(PyObject o, boolean space, boolean newline) { - PyObject obj = myFile(); + public void print(PyObject obj, boolean space, boolean newline) { + print(new PyObject[] {obj}, space, newline, null); + } - if (obj instanceof PyFile) { - PyFile file = (PyFile)obj; + public void print(PyObject[] objs, boolean space, boolean newline, PyObject sep) { + PyObject out = myFile(); + + if (out instanceof PyFile) { + PyFile file = (PyFile)out; if (file.softspace) { file.write(" "); file.softspace = false; } - String s; - if (o instanceof PyUnicode && file.encoding != null) { - s = ((PyUnicode)o).encode(file.encoding, "strict"); - } else { - s = o.__str__().toString(); - } - file.write(s); + for (PyObject obj: objs) { + String s; + if (obj instanceof PyUnicode && file.encoding != null) { + s = ((PyUnicode)obj).encode(file.encoding, "strict"); + } else { + s = obj.__str__().toString(); + } + file.write(s); - if (o instanceof PyString) { - int len = s.length(); - if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) - || s.charAt(len - 1) == ' ') { + if (obj instanceof PyString) { + int len = s.length(); + if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) + || s.charAt(len - 1) == ' ') { + file.softspace = space; + } + } else { file.softspace = space; } - } else { - file.softspace = space; } if (newline) { @@ -132,31 +138,33 @@ file.softspace = false; } file.flush(); - } else if (obj instanceof PyFileWriter) { - PyFileWriter file = (PyFileWriter)obj; + } else if (out instanceof PyFileWriter) { + PyFileWriter file = (PyFileWriter)out; if (file.softspace) { file.write(" "); file.softspace = false; } - // since we are outputting directly to a character stream, - // avoid doing an encoding - String s; - if (o instanceof PyString) { - s = ((PyString) o).getString(); - } else { - s = o.toString(); - } - file.write(s); + for (PyObject obj: objs) { + // since we are outputting directly to a character stream, + // avoid doing an encoding + String s; + if (obj instanceof PyString) { + s = ((PyString) obj).getString(); + } else { + s = obj.toString(); + } + file.write(s); - if (o instanceof PyString) { - int len = s.length(); - if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) - || s.charAt(len - 1) == ' ') { + if (obj instanceof PyString) { + int len = s.length(); + if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) + || s.charAt(len - 1) == ' ') { + file.softspace = space; + } + } else { file.softspace = space; } - } else { - file.softspace = space; } if (newline) { @@ -165,31 +173,33 @@ } file.flush(); } else { - PyObject ss = obj.__findattr__("softspace"); + PyObject ss = out.__findattr__("softspace"); if (ss != null && ss.__nonzero__()) { - obj.invoke("write", Py.Space); - obj.__setattr__("softspace", Py.Zero); + out.invoke("write", Py.Space); + out.__setattr__("softspace", Py.Zero); } - if (!(o instanceof PyUnicode)) { - o = o.__str__(); - } - obj.invoke("write", o); + for (PyObject obj: objs) { + if (!(obj instanceof PyUnicode)) { + obj = obj.__str__(); + } + out.invoke("write", obj); - if (o instanceof PyString) { - String s = o.toString(); - int len = s.length(); - if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) - || s.charAt(len - 1) == ' ') { - obj.__setattr__("softspace", space ? Py.One : Py.Zero); + if (obj instanceof PyString) { + String s = obj.toString(); + int len = s.length(); + if (len == 0 || !Character.isWhitespace(s.charAt(len - 1)) + || s.charAt(len - 1) == ' ') { + out.__setattr__("softspace", space ? Py.One : Py.Zero); + } + } else { + out.__setattr__("softspace", space ? Py.One : Py.Zero); } - } else { - obj.__setattr__("softspace", space ? Py.One : Py.Zero); } if (newline) { - obj.invoke("write", Py.Newline); - obj.__setattr__("softspace", Py.Zero); + out.invoke("write", Py.Newline); + out.__setattr__("softspace", Py.Zero); } } } @@ -202,29 +212,29 @@ print(new PyString(s), false, true); } - public void print(PyObject o) { - print(o, false, false); + public void print(PyObject obj) { + print(obj, false, false); } - public void printComma(PyObject o) { - print(o, true, false); + public void printComma(PyObject obj) { + print(obj, true, false); } - public void println(PyObject o) { - print(o, false, true); + public void println(PyObject obj) { + print(obj, false, true); } public void println() { - PyObject obj = myFile(); + PyObject out = myFile(); - if (obj instanceof PyFile) { - PyFile file = (PyFile) obj; + if (out instanceof PyFile) { + PyFile file = (PyFile) out; file.write("\n"); file.flush(); file.softspace = false; } else { - obj.invoke("write", Py.Newline); - obj.__setattr__("softspace", Py.Zero); + out.invoke("write", Py.Newline); + out.__setattr__("softspace", Py.Zero); } } } diff --git a/src/org/python/core/__builtin__.java b/src/org/python/core/__builtin__.java --- a/src/org/python/core/__builtin__.java +++ b/src/org/python/core/__builtin__.java @@ -1339,11 +1339,30 @@ @Override public PyObject __call__(PyObject args[], String kwds[]) { + //XXX: integrate into ArgParser - need key checks etc. + // ArgParser will need to be extended to take keyword-only args. Map keyargs = new HashMap(); int kwlen = kwds.length; - for (int i=kwlen;i>0;i--) { + for (int i=kwlen; i>0; i--) { keyargs.put(kwds[kwlen - i], args[args.length - i]); } + PyObject values[] = new PyObject[args.length - kwlen]; + System.arraycopy(args, 0, values, 0, args.length - kwlen); + return print(values, keyargs.get("sep"), keyargs.get("end"), keyargs.get("file")); + } + + private static PyObject print(PyObject values[], PyObject sep, PyObject end, PyObject file) { + StdoutWrapper out = Py.stdout; + if (file != null && file != Py.None) { + out = new FixedFileWrapper(file); + } + + if (values.length == 0) { + out.println(); + } else { + boolean newline = end == null || end.__nonzero__(); + out.print(values, false, newline, sep); + } return Py.None; } } -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Wed May 18 02:53:30 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Wed, 18 May 2011 02:53:30 +0200 Subject: [Jython-checkins] jython (merge default -> default): Merge with trunk. Message-ID: http://hg.python.org/jython/rev/afae29255c2c changeset: 6213:afae29255c2c parent: 6212:67f89e017e31 parent: 6209:54ab8647cb83 user: Frank Wierzbicki date: Thu May 12 23:24:52 2011 -0700 summary: Merge with trunk. files: src/org/python/core/Options.java | 5 ++++- src/org/python/core/PySystemState.java | 4 ++++ src/org/python/core/imp.java | 4 +++- src/org/python/util/jython.java | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/org/python/core/Options.java b/src/org/python/core/Options.java --- a/src/org/python/core/Options.java +++ b/src/org/python/core/Options.java @@ -76,9 +76,12 @@ * binary mode */ public static boolean unbuffered = false; - /** Whether -3 (py3k warnings) were enabled via the command line. */ + /** Whether -3 (py3k warnings) was enabled via the command line. */ public static boolean py3kwarning = false; + /** Whether -B (don't write bytecode on import) was enabled via the command line. */ + public static boolean dontWriteBytecode = false; + //XXX: place holder public static int bytes_warning = 0; diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java --- a/src/org/python/core/PySystemState.java +++ b/src/org/python/core/PySystemState.java @@ -162,6 +162,9 @@ /** true when a SystemRestart is triggered. */ public boolean _systemRestart = false; + /** Whether bytecode should be written to disk on import. */ + public boolean dont_write_bytecode = false; + // Automatically close resources associated with a PySystemState when they get GCed private final PySystemStateCloser closer; private static final ReferenceQueue systemStateQueue = @@ -189,6 +192,7 @@ currentWorkingDir = new File("").getAbsolutePath(); + dont_write_bytecode = Options.dontWriteBytecode; py3kwarning = Options.py3kwarning; // Set up the initial standard ins and outs String mode = Options.unbuffered ? "b" : ""; diff --git a/src/org/python/core/imp.java b/src/org/python/core/imp.java --- a/src/org/python/core/imp.java +++ b/src/org/python/core/imp.java @@ -341,7 +341,9 @@ public static PyObject createFromSource(String name, InputStream fp, String filename, String outFilename, long mtime) { byte[] bytes = compileSource(name, fp, filename, mtime); - outFilename = cacheCompiledSource(filename, outFilename, bytes); + if (!Py.getSystemState().dont_write_bytecode) { + outFilename = cacheCompiledSource(filename, outFilename, bytes); + } Py.writeComment(IMPORT_LOG, "'" + name + "' as " + filename); diff --git a/src/org/python/util/jython.java b/src/org/python/util/jython.java --- a/src/org/python/util/jython.java +++ b/src/org/python/util/jython.java @@ -39,7 +39,7 @@ private static final String usage = usageHeader + "Options and arguments:\n" + //(and corresponding environment variables):\n" + - //"-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x\n" + + "-B : don't write .py[co] files on import\n" + // "; also PYTHONDONTWRITEBYTECODE=x\n" + "-c cmd : program passed in as string (terminates option list)\n" + //"-d : debug output from parser (also PYTHONDEBUG=x)\n" + "-Dprop=v : Set the property `prop' to value `v'\n"+ @@ -435,6 +435,8 @@ Options.verbose +=3 ; } else if (arg.equals("-S")) { Options.importSite = false; + } else if (arg.equals("-B")) { + Options.dontWriteBytecode = true; } else if (arg.startsWith("-c")) { runCommand = true; if (arg.length() > 2) { -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Wed May 18 02:53:30 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Wed, 18 May 2011 02:53:30 +0200 Subject: [Jython-checkins] jython (merge default -> default): Merge + unbreak test_softspace. Message-ID: http://hg.python.org/jython/rev/dace7d6d2a57 changeset: 6216:dace7d6d2a57 parent: 6210:1aed2fedd01b parent: 6215:59d70d13e445 user: Frank Wierzbicki date: Mon May 16 21:01:45 2011 -0700 summary: Merge + unbreak test_softspace. files: src/org/python/compiler/Future.java | 2 + src/org/python/core/CodeFlag.java | 7 +- src/org/python/core/FutureFeature.java | 4 + src/org/python/core/Py.java | 6 +- src/org/python/core/PySystemState.java | 2 + src/org/python/core/StdoutWrapper.java | 176 ++++++++---- src/org/python/core/__builtin__.java | 69 +++++ 7 files changed, 204 insertions(+), 62 deletions(-) diff --git a/src/org/python/compiler/Future.java b/src/org/python/compiler/Future.java --- a/src/org/python/compiler/Future.java +++ b/src/org/python/compiler/Future.java @@ -60,6 +60,8 @@ FutureFeature.with_statement.addTo(features); if (cflags.isFlagSet(CodeFlag.CO_FUTURE_ABSOLUTE_IMPORT)) FutureFeature.absolute_import.addTo(features); + if (cflags.isFlagSet(CodeFlag.CO_FUTURE_PRINT_FUNCTION)) + FutureFeature.print_function.addTo(features); } int beg = 0; List suite = null; diff --git a/src/org/python/core/CodeFlag.java b/src/org/python/core/CodeFlag.java --- a/src/org/python/core/CodeFlag.java +++ b/src/org/python/core/CodeFlag.java @@ -50,7 +50,12 @@ /** * With statement. */ - CO_FUTURE_WITH_STATEMENT(0x8000); + CO_FUTURE_WITH_STATEMENT(0x8000), + /** + * print function. + */ + CO_FUTURE_PRINT_FUNCTION(0x10000); + public final int flag; private static Iterable allFlags = Collections.unmodifiableList(Arrays.asList(values())); diff --git a/src/org/python/core/FutureFeature.java b/src/org/python/core/FutureFeature.java --- a/src/org/python/core/FutureFeature.java +++ b/src/org/python/core/FutureFeature.java @@ -24,6 +24,10 @@ */ with_statement(CodeFlag.CO_FUTURE_WITH_STATEMENT), /** + * Enables the print function. + */ + print_function(CodeFlag.CO_FUTURE_PRINT_FUNCTION), + /** * Use braces for block delimiters instead of indentation. */ braces { diff --git a/src/org/python/core/Py.java b/src/org/python/core/Py.java --- a/src/org/python/core/Py.java +++ b/src/org/python/core/Py.java @@ -80,8 +80,12 @@ public static PyString EmptyString; /** A Python string containing '\n' **/ public static PyString Newline; + /** A Python unicode string containing '\n' **/ + public static PyUnicode UnicodeNewline; /** A Python string containing ' ' **/ public static PyString Space; + /** A Python unicode string containing ' ' **/ + public static PyString UnicodeSpace; /** Set if the type object is dynamically allocated */ public static long TPFLAGS_HEAPTYPE = 1L << 9; /** Set if the type allows subclassing */ @@ -2092,7 +2096,7 @@ } } - class FixedFileWrapper extends StdoutWrapper { +class FixedFileWrapper extends StdoutWrapper { private PyObject file; diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java --- a/src/org/python/core/PySystemState.java +++ b/src/org/python/core/PySystemState.java @@ -933,7 +933,9 @@ Py.EmptyString = new PyString(""); Py.Newline = new PyString("\n"); + Py.UnicodeNewline = new PyUnicode("\n"); Py.Space = new PyString(" "); + Py.UnicodeSpace = new PyUnicode(" "); // Setup standard wrappers for stdout and stderr... Py.stderr = new StderrWrapper(); diff --git a/src/org/python/core/StdoutWrapper.java b/src/org/python/core/StdoutWrapper.java --- a/src/org/python/core/StdoutWrapper.java +++ b/src/org/python/core/StdoutWrapper.java @@ -16,20 +16,20 @@ return ss.stdout; } - protected void setObject(PySystemState ss, PyObject obj) { - ss.stdout = obj; + protected void setObject(PySystemState ss, PyObject out) { + ss.stdout = out; } protected PyObject myFile() { PySystemState ss = Py.getSystemState(); - PyObject obj = getObject(ss); - if (obj == null) { + PyObject out = getObject(ss); + if (out == null) { throw Py.AttributeError("missing sys." + this.name); } - if (obj.getJavaProxy() != null) { + if (out.getJavaProxy() != null) { PyFile f = null; - Object tojava = obj.__tojava__(OutputStream.class); + Object tojava = out.__tojava__(OutputStream.class); if (tojava != null && tojava != Py.NoConversion) { f = new PyFile((OutputStream)tojava); } @@ -38,17 +38,17 @@ return f; } } - return obj; + return out; } @Override public void flush() { - PyObject obj = myFile(); - if (obj instanceof PyFile) { - ((PyFile) obj).flush(); + PyObject out = myFile(); + if (out instanceof PyFile) { + ((PyFile) out).flush(); } else { try { - obj.invoke("flush"); + out.invoke("flush"); } catch (PyException pye) { // ok } @@ -56,12 +56,12 @@ } public void write(String s) { - PyObject obj = myFile(); + PyObject out = myFile(); - if (obj instanceof PyFile) { - ((PyFile) obj).write(s); + if (out instanceof PyFile) { + ((PyFile) out).write(s); } else { - obj.invoke("write", new PyString(s)); + out.invoke("write", new PyString(s)); } } @@ -76,46 +76,106 @@ } public void flushLine() { - PyObject obj = myFile(); + PyObject out = myFile(); - if (obj instanceof PyFile) { - PyFile file = (PyFile) obj; + if (out instanceof PyFile) { + PyFile file = (PyFile) out; if (file.softspace) { file.write("\n"); file.flush(); } file.softspace = false; } else { - PyObject ss = obj.__findattr__("softspace"); + PyObject ss = out.__findattr__("softspace"); if (ss != null && ss.__nonzero__()) { - obj.invoke("write", Py.Newline); + out.invoke("write", Py.Newline); } try { - obj.invoke("flush"); + out.invoke("flush"); } catch (PyException pye) { // ok } - obj.__setattr__("softspace", Py.Zero); + out.__setattr__("softspace", Py.Zero); + } + } + + private String printToFile(PyFile file, PyObject o) { + String s; + if (o instanceof PyUnicode && file.encoding != null) { + s = ((PyUnicode)o).encode(file.encoding, "strict"); + } else { + s = o.__str__().toString(); + } + file.write(s); + return s; + } + + private String printToFileWriter(PyFileWriter file, PyObject o) { + // since we are outputting directly to a character stream, + // avoid doing an encoding + String s; + if (o instanceof PyString) { + s = ((PyString) o).getString(); + } else { + s = o.toString(); + } + file.write(s); + return s; + } + + private void printToFileObject(PyObject file, PyObject o) { + if (!(o instanceof PyUnicode)) { + o = o.__str__(); + } + file.invoke("write", o); + } + + /** + * For __future__ print_function. + */ + public void print(PyObject[] args, PyObject sep, PyObject end) { + PyObject out = myFile(); + + if (out instanceof PyFile) { + PyFile file = (PyFile)out; + for (int i=0;i http://hg.python.org/jython/rev/59d70d13e445 changeset: 6215:59d70d13e445 user: Frank Wierzbicki date: Mon May 16 15:43:16 2011 -0700 summary: Get test_print passing! files: src/org/python/core/Py.java | 4 + src/org/python/core/PySystemState.java | 2 + src/org/python/core/StdoutWrapper.java | 27 ++++++- src/org/python/core/__builtin__.java | 51 +++++++++---- 4 files changed, 66 insertions(+), 18 deletions(-) diff --git a/src/org/python/core/Py.java b/src/org/python/core/Py.java --- a/src/org/python/core/Py.java +++ b/src/org/python/core/Py.java @@ -80,8 +80,12 @@ public static PyString EmptyString; /** A Python string containing '\n' **/ public static PyString Newline; + /** A Python unicode string containing '\n' **/ + public static PyUnicode UnicodeNewline; /** A Python string containing ' ' **/ public static PyString Space; + /** A Python unicode string containing ' ' **/ + public static PyString UnicodeSpace; /** Set if the type object is dynamically allocated */ public static long TPFLAGS_HEAPTYPE = 1L << 9; /** Set if the type allows subclassing */ diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java --- a/src/org/python/core/PySystemState.java +++ b/src/org/python/core/PySystemState.java @@ -933,7 +933,9 @@ Py.EmptyString = new PyString(""); Py.Newline = new PyString("\n"); + Py.UnicodeNewline = new PyUnicode("\n"); Py.Space = new PyString(" "); + Py.UnicodeSpace = new PyUnicode(" "); // Setup standard wrappers for stdout and stderr... Py.stderr = new StderrWrapper(); diff --git a/src/org/python/core/StdoutWrapper.java b/src/org/python/core/StdoutWrapper.java --- a/src/org/python/core/StdoutWrapper.java +++ b/src/org/python/core/StdoutWrapper.java @@ -123,7 +123,7 @@ return s; } - private void printToObject(PyObject file, PyObject o) { + private void printToFileObject(PyObject file, PyObject o) { if (!(o instanceof PyUnicode)) { o = o.__str__(); } @@ -147,8 +147,21 @@ printToFile(file, end); } else if (out instanceof PyFileWriter) { PyFileWriter file = (PyFileWriter)out; + for (int i=0;i keyargs = new HashMap(); - //XXX: preloading defaults for now. - keyargs.put("sep", Py.newString(" ")); - keyargs.put("end", Py.newString("\n")); int kwlen = kwds.length; - for (int i=kwlen; i>0; i--) { - keyargs.put(kwds[kwlen - i], args[args.length - i]); + int argslen = args.length; + boolean useUnicode = false; + PyObject values[] = new PyObject[argslen - kwlen]; + System.arraycopy(args, 0, values, 0, argslen - kwlen); + PyObject keyValues[] = new PyObject[kwlen]; + System.arraycopy(args, argslen - kwlen, keyValues, 0, kwlen); + ArgParser ap = new ArgParser("print", keyValues, kwds, new String[] {"sep", "end", "file"}); + for (PyObject keyValue: keyValues) { + if (keyValue instanceof PyUnicode) { + //If "file" is passed in as PyUnicode, that's OK as it will error later. + useUnicode = true; + } } - PyObject values[] = new PyObject[args.length - kwlen]; - System.arraycopy(args, 0, values, 0, args.length - kwlen); - return print(values, keyargs.get("sep"), keyargs.get("end"), keyargs.get("file")); + String sep = ap.getString(0, null); + String end = ap.getString(1, null); + PyObject file = ap.getPyObject(2, null); + return print(values, sep, end, file, useUnicode); } - private static PyObject print(PyObject values[], PyObject sep, PyObject end, PyObject file) { + private static PyObject print(PyObject values[], String sep, String end, + PyObject file, boolean useUnicode) { StdoutWrapper out; if (file != null && file != Py.None) { out = new FixedFileWrapper(file); } else { out = Py.stdout; } - if (values.length == 0) { - out.println(); + out.println(useUnicode); } else { - out.print(values, sep, end); + if (sep == null) { + sep = " "; + } + if (end == null) { + end = "\n"; + } + if (!useUnicode) { + for (PyObject value: values) { + if (value instanceof PyUnicode) { + useUnicode = true; + break; + } + } + } + out.print(values, + useUnicode ? Py.newUnicode(sep) : Py.newString(sep), + useUnicode ? Py.newUnicode(end) : Py.newString(end)); } return Py.None; } -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Wed May 18 02:53:30 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Wed, 18 May 2011 02:53:30 +0200 Subject: [Jython-checkins] jython: Use cached newlines and spaces where possible. Message-ID: http://hg.python.org/jython/rev/a51c53c858b6 changeset: 6217:a51c53c858b6 user: Frank Wierzbicki date: Tue May 17 14:32:31 2011 -0700 summary: Use cached newlines and spaces where possible. files: src/org/python/core/Py.java | 2 +- src/org/python/core/__builtin__.java | 25 ++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/org/python/core/Py.java b/src/org/python/core/Py.java --- a/src/org/python/core/Py.java +++ b/src/org/python/core/Py.java @@ -85,7 +85,7 @@ /** A Python string containing ' ' **/ public static PyString Space; /** A Python unicode string containing ' ' **/ - public static PyString UnicodeSpace; + public static PyUnicode UnicodeSpace; /** Set if the type object is dynamically allocated */ public static long TPFLAGS_HEAPTYPE = 1L << 9; /** Set if the type allows subclassing */ diff --git a/src/org/python/core/__builtin__.java b/src/org/python/core/__builtin__.java --- a/src/org/python/core/__builtin__.java +++ b/src/org/python/core/__builtin__.java @@ -1370,12 +1370,6 @@ if (values.length == 0) { out.println(useUnicode); } else { - if (sep == null) { - sep = " "; - } - if (end == null) { - end = "\n"; - } if (!useUnicode) { for (PyObject value: values) { if (value instanceof PyUnicode) { @@ -1384,9 +1378,22 @@ } } } - out.print(values, - useUnicode ? Py.newUnicode(sep) : Py.newString(sep), - useUnicode ? Py.newUnicode(end) : Py.newString(end)); + + PyObject sepObject; + if (sep == null) { + sepObject = useUnicode ? Py.UnicodeSpace : Py.Space; + } else { + sepObject = useUnicode ? Py.newUnicode(sep) : Py.newString(sep); + } + + PyObject endObject; + if (end == null) { + endObject = useUnicode ? Py.UnicodeNewline : Py.Newline; + } else { + endObject = useUnicode ? Py.newUnicode(end) : Py.newString(end); + } + + out.print(values, sepObject, endObject); } return Py.None; } -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Wed May 18 07:28:33 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Wed, 18 May 2011 07:28:33 +0200 Subject: [Jython-checkins] jython: Fix repr for time module. Fixes test_structseq. Message-ID: http://hg.python.org/jython/rev/be6acf97f743 changeset: 6218:be6acf97f743 parent: 6210:1aed2fedd01b user: Frank Wierzbicki date: Tue May 17 22:26:35 2011 -0700 summary: Fix repr for time module. Fixes test_structseq. files: src/org/python/modules/time/PyTimeTuple.java | 11 ++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/src/org/python/modules/time/PyTimeTuple.java b/src/org/python/modules/time/PyTimeTuple.java --- a/src/org/python/modules/time/PyTimeTuple.java +++ b/src/org/python/modules/time/PyTimeTuple.java @@ -112,4 +112,15 @@ public PyTuple __getnewargs__() { return new PyTuple(new PyList(getArray())); } + + @Override + public String toString() { + return struct_time_toString(); + } + + @ExposedMethod(names = {"__str__", "__repr__"}) + final String struct_time_toString() { + return String.format("time.struct_time(tm_year=%s, tm_mon=%s, tm_mday=%s, tm_hour=%s, tm_min=%s, tm_sec=%s, tm_wday=%s, tm_yday=%s, tm_isdst=%s)", + tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst); + } } -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Wed May 18 07:28:34 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Wed, 18 May 2011 07:28:34 +0200 Subject: [Jython-checkins] jython (merge default -> default): Merge with trunk. Message-ID: http://hg.python.org/jython/rev/ecc27ed463e3 changeset: 6219:ecc27ed463e3 parent: 6218:be6acf97f743 parent: 6217:a51c53c858b6 user: Frank Wierzbicki date: Tue May 17 22:28:20 2011 -0700 summary: Merge with trunk. files: src/org/python/compiler/Future.java | 2 + src/org/python/core/CodeFlag.java | 7 +- src/org/python/core/FutureFeature.java | 4 + src/org/python/core/Py.java | 6 +- src/org/python/core/PySystemState.java | 2 + src/org/python/core/StdoutWrapper.java | 176 ++++++++---- src/org/python/core/__builtin__.java | 76 +++++ 7 files changed, 211 insertions(+), 62 deletions(-) diff --git a/src/org/python/compiler/Future.java b/src/org/python/compiler/Future.java --- a/src/org/python/compiler/Future.java +++ b/src/org/python/compiler/Future.java @@ -60,6 +60,8 @@ FutureFeature.with_statement.addTo(features); if (cflags.isFlagSet(CodeFlag.CO_FUTURE_ABSOLUTE_IMPORT)) FutureFeature.absolute_import.addTo(features); + if (cflags.isFlagSet(CodeFlag.CO_FUTURE_PRINT_FUNCTION)) + FutureFeature.print_function.addTo(features); } int beg = 0; List suite = null; diff --git a/src/org/python/core/CodeFlag.java b/src/org/python/core/CodeFlag.java --- a/src/org/python/core/CodeFlag.java +++ b/src/org/python/core/CodeFlag.java @@ -50,7 +50,12 @@ /** * With statement. */ - CO_FUTURE_WITH_STATEMENT(0x8000); + CO_FUTURE_WITH_STATEMENT(0x8000), + /** + * print function. + */ + CO_FUTURE_PRINT_FUNCTION(0x10000); + public final int flag; private static Iterable allFlags = Collections.unmodifiableList(Arrays.asList(values())); diff --git a/src/org/python/core/FutureFeature.java b/src/org/python/core/FutureFeature.java --- a/src/org/python/core/FutureFeature.java +++ b/src/org/python/core/FutureFeature.java @@ -24,6 +24,10 @@ */ with_statement(CodeFlag.CO_FUTURE_WITH_STATEMENT), /** + * Enables the print function. + */ + print_function(CodeFlag.CO_FUTURE_PRINT_FUNCTION), + /** * Use braces for block delimiters instead of indentation. */ braces { diff --git a/src/org/python/core/Py.java b/src/org/python/core/Py.java --- a/src/org/python/core/Py.java +++ b/src/org/python/core/Py.java @@ -80,8 +80,12 @@ public static PyString EmptyString; /** A Python string containing '\n' **/ public static PyString Newline; + /** A Python unicode string containing '\n' **/ + public static PyUnicode UnicodeNewline; /** A Python string containing ' ' **/ public static PyString Space; + /** A Python unicode string containing ' ' **/ + public static PyUnicode UnicodeSpace; /** Set if the type object is dynamically allocated */ public static long TPFLAGS_HEAPTYPE = 1L << 9; /** Set if the type allows subclassing */ @@ -2092,7 +2096,7 @@ } } - class FixedFileWrapper extends StdoutWrapper { +class FixedFileWrapper extends StdoutWrapper { private PyObject file; diff --git a/src/org/python/core/PySystemState.java b/src/org/python/core/PySystemState.java --- a/src/org/python/core/PySystemState.java +++ b/src/org/python/core/PySystemState.java @@ -933,7 +933,9 @@ Py.EmptyString = new PyString(""); Py.Newline = new PyString("\n"); + Py.UnicodeNewline = new PyUnicode("\n"); Py.Space = new PyString(" "); + Py.UnicodeSpace = new PyUnicode(" "); // Setup standard wrappers for stdout and stderr... Py.stderr = new StderrWrapper(); diff --git a/src/org/python/core/StdoutWrapper.java b/src/org/python/core/StdoutWrapper.java --- a/src/org/python/core/StdoutWrapper.java +++ b/src/org/python/core/StdoutWrapper.java @@ -16,20 +16,20 @@ return ss.stdout; } - protected void setObject(PySystemState ss, PyObject obj) { - ss.stdout = obj; + protected void setObject(PySystemState ss, PyObject out) { + ss.stdout = out; } protected PyObject myFile() { PySystemState ss = Py.getSystemState(); - PyObject obj = getObject(ss); - if (obj == null) { + PyObject out = getObject(ss); + if (out == null) { throw Py.AttributeError("missing sys." + this.name); } - if (obj.getJavaProxy() != null) { + if (out.getJavaProxy() != null) { PyFile f = null; - Object tojava = obj.__tojava__(OutputStream.class); + Object tojava = out.__tojava__(OutputStream.class); if (tojava != null && tojava != Py.NoConversion) { f = new PyFile((OutputStream)tojava); } @@ -38,17 +38,17 @@ return f; } } - return obj; + return out; } @Override public void flush() { - PyObject obj = myFile(); - if (obj instanceof PyFile) { - ((PyFile) obj).flush(); + PyObject out = myFile(); + if (out instanceof PyFile) { + ((PyFile) out).flush(); } else { try { - obj.invoke("flush"); + out.invoke("flush"); } catch (PyException pye) { // ok } @@ -56,12 +56,12 @@ } public void write(String s) { - PyObject obj = myFile(); + PyObject out = myFile(); - if (obj instanceof PyFile) { - ((PyFile) obj).write(s); + if (out instanceof PyFile) { + ((PyFile) out).write(s); } else { - obj.invoke("write", new PyString(s)); + out.invoke("write", new PyString(s)); } } @@ -76,46 +76,106 @@ } public void flushLine() { - PyObject obj = myFile(); + PyObject out = myFile(); - if (obj instanceof PyFile) { - PyFile file = (PyFile) obj; + if (out instanceof PyFile) { + PyFile file = (PyFile) out; if (file.softspace) { file.write("\n"); file.flush(); } file.softspace = false; } else { - PyObject ss = obj.__findattr__("softspace"); + PyObject ss = out.__findattr__("softspace"); if (ss != null && ss.__nonzero__()) { - obj.invoke("write", Py.Newline); + out.invoke("write", Py.Newline); } try { - obj.invoke("flush"); + out.invoke("flush"); } catch (PyException pye) { // ok } - obj.__setattr__("softspace", Py.Zero); + out.__setattr__("softspace", Py.Zero); + } + } + + private String printToFile(PyFile file, PyObject o) { + String s; + if (o instanceof PyUnicode && file.encoding != null) { + s = ((PyUnicode)o).encode(file.encoding, "strict"); + } else { + s = o.__str__().toString(); + } + file.write(s); + return s; + } + + private String printToFileWriter(PyFileWriter file, PyObject o) { + // since we are outputting directly to a character stream, + // avoid doing an encoding + String s; + if (o instanceof PyString) { + s = ((PyString) o).getString(); + } else { + s = o.toString(); + } + file.write(s); + return s; + } + + private void printToFileObject(PyObject file, PyObject o) { + if (!(o instanceof PyUnicode)) { + o = o.__str__(); + } + file.invoke("write", o); + } + + /** + * For __future__ print_function. + */ + public void print(PyObject[] args, PyObject sep, PyObject end) { + PyObject out = myFile(); + + if (out instanceof PyFile) { + PyFile file = (PyFile)out; + for (int i=0;i http://hg.python.org/jython/rev/593addebd500 changeset: 6221:593addebd500 user: Frank Wierzbicki date: Wed May 18 09:56:21 2011 -0700 summary: Skip gc bound test. files: Lib/test/test_class.py | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py --- a/Lib/test/test_class.py +++ b/Lib/test/test_class.py @@ -466,16 +466,19 @@ self.assertCallStack([('__delattr__', (testme, "cardinal"))]) def testDel(self): - x = [] + #XXX: gc.collect is not deterministic on Jython, but it would be nice + # to find a way to test this. + if not test_support.is_jython: + x = [] - class DelTest: - def __del__(self): - x.append("crab people, crab people") - testme = DelTest() - del testme - import gc - gc.collect() - self.assertEquals(["crab people, crab people"], x) + class DelTest: + def __del__(self): + x.append("crab people, crab people") + testme = DelTest() + del testme + import gc + gc.collect() + self.assertEquals(["crab people, crab people"], x) def testBadTypeReturned(self): # return values of some method are type-checked -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Thu May 19 05:10:23 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Thu, 19 May 2011 05:10:23 +0200 Subject: [Jython-checkins] jython: Allowing Jython's old style classes to have some really subtle new style Message-ID: http://hg.python.org/jython/rev/2673b3b2df10 changeset: 6222:2673b3b2df10 user: Frank Wierzbicki date: Wed May 18 10:20:47 2011 -0700 summary: Allowing Jython's old style classes to have some really subtle new style behavior with respect to slicing. files: Lib/test/test_class.py | 27 ++++++++++++++++++++++----- 1 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py --- a/Lib/test/test_class.py +++ b/Lib/test/test_class.py @@ -331,18 +331,35 @@ # XXX when using new-style classes the slice testme[:42] produces # slice(None, 42, None) instead of slice(0, 42, None). py3k will have - # to change this test. + # to change this test. Jython already shows the py3k behavior by + # default. callLst[:] = [] testme[:42] - self.assertCallStack([('__getitem__', (testme, slice(0, 42, None)))]) + if test_support.is_jython: + self.assertCallStack([('__getitem__', (testme, + slice(None, 42, None)))]) + else: + self.assertCallStack([('__getitem__', (testme, + slice(0, 42, None)))]) callLst[:] = [] testme[:42] = "The Answer" - self.assertCallStack([('__setitem__', (testme, slice(0, 42, None), - "The Answer"))]) + if test_support.is_jython: + self.assertCallStack([('__setitem__',(testme, + slice(None, 42, None), + "The Answer"))]) + else: + self.assertCallStack([('__setitem__', (testme, + slice(0, 42, None), + "The Answer"))]) callLst[:] = [] del testme[:42] - self.assertCallStack([('__delitem__', (testme, slice(0, 42, None)))]) + if test_support.is_jython: + self.assertCallStack([('__delitem__', (testme, + slice(None, 42, None)))]) + else: + self.assertCallStack([('__delitem__', (testme, + slice(0, 42, None)))]) # Restore the slice methods, or the tests will fail with regrtest -R. AllTests.__getslice__ = getslice -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Thu May 19 05:10:23 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Thu, 19 May 2011 05:10:23 +0200 Subject: [Jython-checkins] jython: from Message-ID: http://hg.python.org/jython/rev/f7d670cff26b changeset: 6220:f7d670cff26b user: Frank Wierzbicki date: Wed May 18 09:37:41 2011 -0700 summary: from https://svn.python.org/projects/python/branches/release26-maint/Lib/test/test_class.py at 88766 files: Lib/test/test_class.py | 692 ++++++++++++++++++---------- 1 files changed, 453 insertions(+), 239 deletions(-) diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py --- a/Lib/test/test_class.py +++ b/Lib/test/test_class.py @@ -1,6 +1,8 @@ "Test the functionality of Python classes implementing operators." -from test.test_support import TestFailed +import unittest + +from test import test_support testmeths = [ @@ -64,55 +66,62 @@ # "setattr", # "delattr", +callLst = [] +def trackCall(f): + def track(*args, **kwargs): + callLst.append((f.__name__, args)) + return f(*args, **kwargs) + return track + class AllTests: + trackCall = trackCall + + @trackCall def __coerce__(self, *args): - print "__coerce__:", args return (self,) + args + @trackCall def __hash__(self, *args): - print "__hash__:", args return hash(id(self)) + @trackCall def __str__(self, *args): - print "__str__:", args return "AllTests" + @trackCall def __repr__(self, *args): - print "__repr__:", args return "AllTests" + @trackCall def __int__(self, *args): - print "__int__:", args return 1 + @trackCall def __float__(self, *args): - print "__float__:", args return 1.0 + @trackCall def __long__(self, *args): - print "__long__:", args return 1L + @trackCall def __oct__(self, *args): - print "__oct__:", args return '01' + @trackCall def __hex__(self, *args): - print "__hex__:", args return '0x1' + @trackCall def __cmp__(self, *args): - print "__cmp__:", args return 0 - def __del__(self, *args): - print "__del__:", args - -# Synthesize AllTests methods from the names in testmeths. +# Synthesize all the other AllTests methods from the names in testmeths. method_template = """\ + at trackCall def __%(method)s__(self, *args): - print "__%(method)s__:", args + pass """ for method in testmeths: @@ -120,293 +129,498 @@ del method, method_template -# this also tests __init__ of course. -testme = AllTests() +class ClassTests(unittest.TestCase): + def setUp(self): + callLst[:] = [] -# Binary operations + def assertCallStack(self, expected_calls): + actualCallList = callLst[:] # need to copy because the comparison below will add + # additional calls to callLst + if expected_calls != actualCallList: + self.fail("Expected call list:\n %s\ndoes not match actual call list\n %s" % + (expected_calls, actualCallList)) -testme + 1 -1 + testme + def testInit(self): + foo = AllTests() + self.assertCallStack([("__init__", (foo,))]) -testme - 1 -1 - testme + def testBinaryOps(self): + testme = AllTests() + # Binary operations -testme * 1 -1 * testme + callLst[:] = [] + testme + 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__add__", (testme, 1))]) -if 1/2 == 0: - testme / 1 - 1 / testme -else: - # True division is in effect, so "/" doesn't map to __div__ etc; but - # the canned expected-output file requires that __div__ etc get called. - testme.__coerce__(1) - testme.__div__(1) - testme.__coerce__(1) - testme.__rdiv__(1) + callLst[:] = [] + 1 + testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__radd__", (testme, 1))]) -testme % 1 -1 % testme + callLst[:] = [] + testme - 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__sub__", (testme, 1))]) -divmod(testme,1) -divmod(1, testme) + callLst[:] = [] + 1 - testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__rsub__", (testme, 1))]) -testme ** 1 -1 ** testme + callLst[:] = [] + testme * 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__mul__", (testme, 1))]) -testme >> 1 -1 >> testme + callLst[:] = [] + 1 * testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__rmul__", (testme, 1))]) -testme << 1 -1 << testme + if 1/2 == 0: + callLst[:] = [] + testme / 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__div__", (testme, 1))]) -testme & 1 -1 & testme -testme | 1 -1 | testme + callLst[:] = [] + 1 / testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__rdiv__", (testme, 1))]) -testme ^ 1 -1 ^ testme + callLst[:] = [] + testme % 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__mod__", (testme, 1))]) + callLst[:] = [] + 1 % testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__rmod__", (testme, 1))]) -# List/dict operations -class Empty: pass + callLst[:] = [] + divmod(testme,1) + self.assertCallStack([("__coerce__", (testme, 1)), ("__divmod__", (testme, 1))]) -try: - 1 in Empty() - print 'failed, should have raised TypeError' -except TypeError: - pass + callLst[:] = [] + divmod(1, testme) + self.assertCallStack([("__coerce__", (testme, 1)), ("__rdivmod__", (testme, 1))]) -1 in testme + callLst[:] = [] + testme ** 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__pow__", (testme, 1))]) -testme[1] -testme[1] = 1 -del testme[1] + callLst[:] = [] + 1 ** testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__rpow__", (testme, 1))]) -testme[:42] -testme[:42] = "The Answer" -del testme[:42] + callLst[:] = [] + testme >> 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__rshift__", (testme, 1))]) -testme[2:1024:10] -testme[2:1024:10] = "A lot" -del testme[2:1024:10] + callLst[:] = [] + 1 >> testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__rrshift__", (testme, 1))]) -testme[:42, ..., :24:, 24, 100] -testme[:42, ..., :24:, 24, 100] = "Strange" -del testme[:42, ..., :24:, 24, 100] + callLst[:] = [] + testme << 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__lshift__", (testme, 1))]) + callLst[:] = [] + 1 << testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__rlshift__", (testme, 1))]) -# Now remove the slice hooks to see if converting normal slices to slice -# object works. + callLst[:] = [] + testme & 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__and__", (testme, 1))]) -del AllTests.__getslice__ -del AllTests.__setslice__ -del AllTests.__delslice__ + callLst[:] = [] + 1 & testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__rand__", (testme, 1))]) -import sys -if sys.platform[:4] != 'java': - testme[:42] - testme[:42] = "The Answer" - del testme[:42] -else: - # This works under Jython, but the actual slice values are - # different. - print "__getitem__: (slice(0, 42, None),)" - print "__setitem__: (slice(0, 42, None), 'The Answer')" - print "__delitem__: (slice(0, 42, None),)" + callLst[:] = [] + testme | 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__or__", (testme, 1))]) -# Unary operations + callLst[:] = [] + 1 | testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__ror__", (testme, 1))]) --testme -+testme -abs(testme) -int(testme) -long(testme) -float(testme) -oct(testme) -hex(testme) + callLst[:] = [] + testme ^ 1 + self.assertCallStack([("__coerce__", (testme, 1)), ("__xor__", (testme, 1))]) -# And the rest... + callLst[:] = [] + 1 ^ testme + self.assertCallStack([("__coerce__", (testme, 1)), ("__rxor__", (testme, 1))]) -hash(testme) -repr(testme) -str(testme) + def testListAndDictOps(self): + testme = AllTests() -testme == 1 -testme < 1 -testme > 1 -testme <> 1 -testme != 1 -1 == testme -1 < testme -1 > testme -1 <> testme -1 != testme + # List/dict operations -# This test has to be last (duh.) + class Empty: pass -del testme -if sys.platform[:4] == 'java': - from test_weakref import extra_collect - extra_collect() + try: + 1 in Empty() + self.fail('failed, should have raised TypeError') + except TypeError: + pass -# Interfering tests + callLst[:] = [] + 1 in testme + self.assertCallStack([('__contains__', (testme, 1))]) -class ExtraTests: - def __getattr__(self, *args): - print "__getattr__:", args - return "SomeVal" + callLst[:] = [] + testme[1] + self.assertCallStack([('__getitem__', (testme, 1))]) - def __setattr__(self, *args): - print "__setattr__:", args + callLst[:] = [] + testme[1] = 1 + self.assertCallStack([('__setitem__', (testme, 1, 1))]) - def __delattr__(self, *args): - print "__delattr__:", args + callLst[:] = [] + del testme[1] + self.assertCallStack([('__delitem__', (testme, 1))]) -testme = ExtraTests() -testme.spam -testme.eggs = "spam, spam, spam and ham" -del testme.cardinal + callLst[:] = [] + testme[:42] + self.assertCallStack([('__getslice__', (testme, 0, 42))]) + callLst[:] = [] + testme[:42] = "The Answer" + self.assertCallStack([('__setslice__', (testme, 0, 42, "The Answer"))]) -# return values of some method are type-checked -class BadTypeClass: - def __int__(self): - return None - __float__ = __int__ - __long__ = __int__ - __str__ = __int__ - __repr__ = __int__ - __oct__ = __int__ - __hex__ = __int__ + callLst[:] = [] + del testme[:42] + self.assertCallStack([('__delslice__', (testme, 0, 42))]) -def check_exc(stmt, exception): - """Raise TestFailed if executing 'stmt' does not raise 'exception' - """ - try: - exec stmt - except exception: - pass - else: - raise TestFailed, "%s should raise %s" % (stmt, exception) + callLst[:] = [] + testme[2:1024:10] + self.assertCallStack([('__getitem__', (testme, slice(2, 1024, 10)))]) -check_exc("int(BadTypeClass())", TypeError) -check_exc("float(BadTypeClass())", TypeError) -check_exc("long(BadTypeClass())", TypeError) -check_exc("str(BadTypeClass())", TypeError) -check_exc("repr(BadTypeClass())", TypeError) -check_exc("oct(BadTypeClass())", TypeError) -check_exc("hex(BadTypeClass())", TypeError) + callLst[:] = [] + testme[2:1024:10] = "A lot" + self.assertCallStack([('__setitem__', (testme, slice(2, 1024, 10), + "A lot"))]) + callLst[:] = [] + del testme[2:1024:10] + self.assertCallStack([('__delitem__', (testme, slice(2, 1024, 10)))]) -# mixing up ints and longs is okay -class IntLongMixClass: - def __int__(self): - return 0L + callLst[:] = [] + testme[:42, ..., :24:, 24, 100] + self.assertCallStack([('__getitem__', (testme, (slice(None, 42, None), + Ellipsis, + slice(None, 24, None), + 24, 100)))]) + callLst[:] = [] + testme[:42, ..., :24:, 24, 100] = "Strange" + self.assertCallStack([('__setitem__', (testme, (slice(None, 42, None), + Ellipsis, + slice(None, 24, None), + 24, 100), "Strange"))]) + callLst[:] = [] + del testme[:42, ..., :24:, 24, 100] + self.assertCallStack([('__delitem__', (testme, (slice(None, 42, None), + Ellipsis, + slice(None, 24, None), + 24, 100)))]) - def __long__(self): - return 0 + # Now remove the slice hooks to see if converting normal slices to + # slice object works. -try: - int(IntLongMixClass()) -except TypeError: - raise TestFailed, "TypeError should not be raised" + getslice = AllTests.__getslice__ + del AllTests.__getslice__ + setslice = AllTests.__setslice__ + del AllTests.__setslice__ + delslice = AllTests.__delslice__ + del AllTests.__delslice__ -try: - long(IntLongMixClass()) -except TypeError: - raise TestFailed, "TypeError should not be raised" + # XXX when using new-style classes the slice testme[:42] produces + # slice(None, 42, None) instead of slice(0, 42, None). py3k will have + # to change this test. + callLst[:] = [] + testme[:42] + self.assertCallStack([('__getitem__', (testme, slice(0, 42, None)))]) + callLst[:] = [] + testme[:42] = "The Answer" + self.assertCallStack([('__setitem__', (testme, slice(0, 42, None), + "The Answer"))]) + callLst[:] = [] + del testme[:42] + self.assertCallStack([('__delitem__', (testme, slice(0, 42, None)))]) -# Test correct errors from hash() on objects with comparisons but no __hash__ + # Restore the slice methods, or the tests will fail with regrtest -R. + AllTests.__getslice__ = getslice + AllTests.__setslice__ = setslice + AllTests.__delslice__ = delslice -class C0: - pass -hash(C0()) # This should work; the next two should raise TypeError + def testUnaryOps(self): + testme = AllTests() -class C1: - def __cmp__(self, other): return 0 + callLst[:] = [] + -testme + self.assertCallStack([('__neg__', (testme,))]) + callLst[:] = [] + +testme + self.assertCallStack([('__pos__', (testme,))]) + callLst[:] = [] + abs(testme) + self.assertCallStack([('__abs__', (testme,))]) + callLst[:] = [] + int(testme) + self.assertCallStack([('__int__', (testme,))]) + callLst[:] = [] + long(testme) + self.assertCallStack([('__long__', (testme,))]) + callLst[:] = [] + float(testme) + self.assertCallStack([('__float__', (testme,))]) + callLst[:] = [] + oct(testme) + self.assertCallStack([('__oct__', (testme,))]) + callLst[:] = [] + hex(testme) + self.assertCallStack([('__hex__', (testme,))]) -check_exc("hash(C1())", TypeError) -class C2: - def __eq__(self, other): return 1 + def testMisc(self): + testme = AllTests() -check_exc("hash(C2())", TypeError) + callLst[:] = [] + hash(testme) + self.assertCallStack([('__hash__', (testme,))]) -# Test for SF bug 532646 + callLst[:] = [] + repr(testme) + self.assertCallStack([('__repr__', (testme,))]) -class A: - pass -A.__call__ = A() -a = A() -try: - a() # This should not segfault -except RuntimeError: - pass -else: - raise TestFailed, "how could this not have overflowed the stack?" + callLst[:] = [] + str(testme) + self.assertCallStack([('__str__', (testme,))]) + callLst[:] = [] + testme == 1 + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) -# Tests for exceptions raised in instance_getattr2(). + callLst[:] = [] + testme < 1 + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) -def booh(self): - raise AttributeError, "booh" + callLst[:] = [] + testme > 1 + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) -class A: - a = property(booh) -try: - A().a # Raised AttributeError: A instance has no attribute 'a' -except AttributeError, x: - if str(x) != "booh": - print "attribute error for A().a got masked:", str(x) + callLst[:] = [] + eval('testme <> 1') # XXX kill this in py3k + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) -class E: - __eq__ = property(booh) -E() == E() # In debug mode, caused a C-level assert() to fail + callLst[:] = [] + testme != 1 + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))]) -class I: - __init__ = property(booh) -try: - I() # In debug mode, printed XXX undetected error and raises AttributeError -except AttributeError, x: - pass -else: - print "attribute error for I.__init__ got masked" + callLst[:] = [] + 1 == testme + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) + callLst[:] = [] + 1 < testme + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) -# Test comparison and hash of methods -class A: - def __init__(self, x): - self.x = x - def f(self): - pass - def g(self): - pass - def __eq__(self, other): - return self.x == other.x - def __hash__(self): - return self.x -class B(A): - pass + callLst[:] = [] + 1 > testme + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) -a1 = A(1) -a2 = A(2) -assert a1.f == a1.f -assert a1.f != a2.f -assert a1.f != a1.g -assert a1.f == A(1).f -assert hash(a1.f) == hash(a1.f) -assert hash(a1.f) == hash(A(1).f) + callLst[:] = [] + eval('1 <> testme') + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) -assert A.f != a1.f -assert A.f != A.g -assert B.f == A.f -assert hash(B.f) == hash(A.f) + callLst[:] = [] + 1 != testme + self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))]) -# the following triggers a SystemError in 2.4 -a = A(hash(A.f.im_func)^(-1)) -hash(a.f) + + def testGetSetAndDel(self): + # Interfering tests + class ExtraTests(AllTests): + @trackCall + def __getattr__(self, *args): + return "SomeVal" + + @trackCall + def __setattr__(self, *args): + pass + + @trackCall + def __delattr__(self, *args): + pass + + testme = ExtraTests() + + callLst[:] = [] + testme.spam + self.assertCallStack([('__getattr__', (testme, "spam"))]) + + callLst[:] = [] + testme.eggs = "spam, spam, spam and ham" + self.assertCallStack([('__setattr__', (testme, "eggs", + "spam, spam, spam and ham"))]) + + callLst[:] = [] + del testme.cardinal + self.assertCallStack([('__delattr__', (testme, "cardinal"))]) + + def testDel(self): + x = [] + + class DelTest: + def __del__(self): + x.append("crab people, crab people") + testme = DelTest() + del testme + import gc + gc.collect() + self.assertEquals(["crab people, crab people"], x) + + def testBadTypeReturned(self): + # return values of some method are type-checked + class BadTypeClass: + def __int__(self): + return None + __float__ = __int__ + __long__ = __int__ + __str__ = __int__ + __repr__ = __int__ + __oct__ = __int__ + __hex__ = __int__ + + for f in [int, float, long, str, repr, oct, hex]: + self.assertRaises(TypeError, f, BadTypeClass()) + + def testMixIntsAndLongs(self): + # mixing up ints and longs is okay + class IntLongMixClass: + @trackCall + def __int__(self): + return 42L + + @trackCall + def __long__(self): + return 64 + + mixIntAndLong = IntLongMixClass() + + callLst[:] = [] + as_int = int(mixIntAndLong) + self.assertEquals(type(as_int), long) + self.assertEquals(as_int, 42L) + self.assertCallStack([('__int__', (mixIntAndLong,))]) + + callLst[:] = [] + as_long = long(mixIntAndLong) + self.assertEquals(type(as_long), int) + self.assertEquals(as_long, 64) + self.assertCallStack([('__long__', (mixIntAndLong,))]) + + def testHashStuff(self): + # Test correct errors from hash() on objects with comparisons but + # no __hash__ + + class C0: + pass + + hash(C0()) # This should work; the next two should raise TypeError + + class C1: + def __cmp__(self, other): return 0 + + self.assertRaises(TypeError, hash, C1()) + + class C2: + def __eq__(self, other): return 1 + + self.assertRaises(TypeError, hash, C2()) + + + def testSFBug532646(self): + # Test for SF bug 532646 + + class A: + pass + A.__call__ = A() + a = A() + + try: + a() # This should not segfault + except RuntimeError: + pass + else: + self.fail("Failed to raise RuntimeError") + + def testForExceptionsRaisedInInstanceGetattr2(self): + # Tests for exceptions raised in instance_getattr2(). + + def booh(self): + raise AttributeError("booh") + + class A: + a = property(booh) + try: + A().a # Raised AttributeError: A instance has no attribute 'a' + except AttributeError, x: + if str(x) != "booh": + self.fail("attribute error for A().a got masked: %s" % x) + + class E: + __eq__ = property(booh) + E() == E() # In debug mode, caused a C-level assert() to fail + + class I: + __init__ = property(booh) + try: + # In debug mode, printed XXX undetected error and + # raises AttributeError + I() + except AttributeError, x: + pass + else: + self.fail("attribute error for I.__init__ got masked") + + def testHashComparisonOfMethods(self): + # Test comparison and hash of methods + class A: + def __init__(self, x): + self.x = x + def f(self): + pass + def g(self): + pass + def __eq__(self, other): + return self.x == other.x + def __hash__(self): + return self.x + class B(A): + pass + + a1 = A(1) + a2 = A(2) + self.assertEquals(a1.f, a1.f) + self.assertNotEquals(a1.f, a2.f) + self.assertNotEquals(a1.f, a1.g) + self.assertEquals(a1.f, A(1).f) + self.assertEquals(hash(a1.f), hash(a1.f)) + self.assertEquals(hash(a1.f), hash(A(1).f)) + + self.assertNotEquals(A.f, a1.f) + self.assertNotEquals(A.f, A.g) + self.assertEquals(B.f, A.f) + self.assertEquals(hash(B.f), hash(A.f)) + + # the following triggers a SystemError in 2.4 + a = A(hash(A.f.im_func)^(-1)) + hash(a.f) + +def test_main(): + with test_support._check_py3k_warnings( + (".+__(get|set|del)slice__ has been removed", DeprecationWarning), + ("classic int division", DeprecationWarning), + ("<> not supported", DeprecationWarning)): + test_support.run_unittest(ClassTests) + +if __name__=='__main__': + test_main() -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Thu May 19 05:20:07 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Thu, 19 May 2011 05:20:07 +0200 Subject: [Jython-checkins] jython: Modernize test_jbasic. Message-ID: http://hg.python.org/jython/rev/3853119592b5 changeset: 6223:3853119592b5 user: Frank Wierzbicki date: Wed May 18 20:19:58 2011 -0700 summary: Modernize test_jbasic. files: Lib/test/test_jbasic.py | 227 +++++++++++++++------------ 1 files changed, 122 insertions(+), 105 deletions(-) diff --git a/Lib/test/test_jbasic.py b/Lib/test/test_jbasic.py --- a/Lib/test/test_jbasic.py +++ b/Lib/test/test_jbasic.py @@ -1,119 +1,136 @@ -from test_support import * +import unittest -print 'Basic Java Integration (test_jbasic.py)' - -print 'type conversions' -print 'numbers' - -from java.lang.Math import abs -assert abs(-2.) == 2., 'Python float to Java double' -assert abs(-2) == 2l, 'Python int to Java long' -assert abs(-2l) == 2l, 'Python long to Java long' - -try: abs(-123456789123456789123l) -except TypeError: pass - -print 'strings' -from java.lang import Integer, String - -assert Integer.valueOf('42') == 42, 'Python string to Java string' - -print 'arrays' -chars = ['a', 'b', 'c'] -assert String.valueOf(chars) == 'abc', 'char array' - -print 'Enumerations' -from java.util import Vector - -vec = Vector() -items = range(10) -for i in items: - vec.addElement(i) - -expected = 0 -for i in vec: - assert i == expected, 'testing __iter__ on java.util.Vector' - expected = expected+1 - -expected = 0 -for i in iter(vec): - assert i == expected, 'testing iter(java.util.Vector)' - expected = expected+1 - - -print 'create java objects' - -from java.math import BigInteger - -assert BigInteger('1234', 10).intValue() == 1234, 'BigInteger(string)' -assert BigInteger([0x11, 0x11, 0x11]).intValue() == 0x111111, 'BigInteger(byte[])' -assert BigInteger(-1, [0x11, 0x11, 0x11]).intValue() == -0x111111, 'BigInteger(int, byte[])' - -print 'call static methods' -s1 = String.valueOf(['1', '2', '3']) -s2 = String.valueOf('123') -s3 = String.valueOf(123) -s4 = String.valueOf(123l) -s5 = String.valueOf(['0', '1', '2', '3', 'a', 'b'], 1, 3) -assert s1 == s2 == s3 == s4 == s5, 'String.valueOf method with different arguments' - -print 'call instance methods' -s = String('hello') -assert s.regionMatches(1, 1, 'ell', 0, 3), 'method call with boolean true' -assert s.regionMatches(0, 1, 'ell', 0, 3), 'method call with boolean false' -assert s.regionMatches(1, 'ell', 0, 3), 'method call no boolean' - -assert s.regionMatches(1, 1, 'eLl', 0, 3), 'method call ignore case' -assert not s.regionMatches(1, 'eLl', 0, 3), 'should ignore case' +from test import test_support from java.awt import Dimension +from java.awt.event import ActionEvent +from java.lang import Integer, String +from java.lang.Math import abs +from java.math import BigInteger +from java.util import Vector +from javax import swing -print 'get/set fields' -d = Dimension(3,9) -assert d.width == 3 and d.height == 9, 'getting fields' -d.width = 42 -assert d.width == 42 and d.height == 9, 'setting fields' -#Make sure non-existent fields fail -try: - print d.foo -except AttributeError: - pass -else: - raise AssertionError, 'd.foo should throw type error' +class JythonBasicTests(unittest.TestCase): -print 'get/set bean properties' + def test_numbers(self): + self.assertEquals(abs(-2.), 2., 'Python float to Java double') + self.assertEquals(abs(-2), 2l, 'Python int to Java long') + self.assertEquals(abs(-2l), 2l, 'Python long to Java long') -from javax import swing -b1 = swing.JButton() -b1.label = 'foo' -b2 = swing.JButton(label='foo') -assert b1.label == b2.label == 'foo', 'Button label bean property' + try: abs(-123456789123456789123l) + except TypeError: pass -print 'bean event properties' -# Test bean event properties - single and multiple -flag = 0 -def testAction(event): - global flag - flag = flag + 1 + def test_strings(self): + self.assertEquals(Integer.valueOf('42'), 42, + 'Python string to Java string') -from java.awt.event import ActionEvent + def test_arrays(self): + chars = ['a', 'b', 'c'] + self.assertEquals(String.valueOf(chars), 'abc', 'char array') -doit = ActionEvent(b1, ActionEvent.ACTION_PERFORMED, "") + def test_enumerations(self): + vec = Vector() + items = range(10) + for i in items: + vec.addElement(i) -b1.actionPerformed = testAction -flag = 0 -b1.doClick() -assert flag == 1, 'expected one action per event but got %s' % flag + expected = 0 + for i in vec: + self.assertEquals(i, expected, + 'testing __iter__ on java.util.Vector') + expected = expected+1 -b1.actionPerformed.append(testAction) -flag = 0 -b1.doClick() -assert flag == 2, 'two actions per event' + expected = 0 + for i in iter(vec): + self.assertEquals(i, expected, 'testing iter(java.util.Vector)') + expected = expected+1 -b1.actionPerformed = testAction -flag = 0 -b1.doClick() -assert flag == 1, 'one actions per event - again' -# TBD: Jython does not properly exit after this code! + def test_java_objects(self): + self.assertEquals(BigInteger('1234', 10).intValue(), 1234, + 'BigInteger(string)') + self.assertEquals(BigInteger([0x11, 0x11, 0x11]).intValue(), 0x111111, + 'BigInteger(byte[])') + self.assertEquals(BigInteger(-1, [0x11, 0x11, 0x11]).intValue(), + -0x111111, 'BigInteger(int, byte[])') + + def test_call_static_methods(self): + s1 = String.valueOf(['1', '2', '3']) + s2 = String.valueOf('123') + s3 = String.valueOf(123) + s4 = String.valueOf(123l) + s5 = String.valueOf(['0', '1', '2', '3', 'a', 'b'], 1, 3) + self.assertEquals(s1, s2) + self.assertEquals(s1, s3) + self.assertEquals(s1, s4) + self.assertEquals(s1, s5) + + def test_call_instance_methods(self): + s = String('hello') + self.assertTrue(s.regionMatches(1, 1, 'ell', 0, 3), + 'method call with boolean true') + self.assertTrue(s.regionMatches(0, 1, 'ell', 0, 3), + 'method call with boolean false') + self.assertTrue(s.regionMatches(1, 'ell', 0, 3), + 'method call no boolean') + + self.assertTrue(s.regionMatches(1, 1, 'eLl', 0, 3), + 'method call ignore case') + self.assertFalse(s.regionMatches(1, 'eLl', 0, 3), 'should ignore case') + + def test_get_set(self): + d = Dimension(3,9) + self.assertEquals(d.width, 3) + self.assertEquals(d.height, 9) + d.width = 42 + self.assertEquals(d.width, 42) + self.assertEquals(d.height, 9) + + try: + d.foo + except AttributeError: + pass + else: + raise AssertionError, 'd.foo should throw type error' + + # Used in test_java_bean_properties. + flag = 0 + + def test_java_bean_properties(self): + + b1 = swing.JButton() + b1.label = 'foo' + b2 = swing.JButton(label='foo') + self.assertEquals(b1.label, b2.label) + self.assertEquals(b1.label, 'foo') + + # Test bean event properties - single and multiple + def testAction(event): + JythonBasicTests.flag += 1 + + doit = ActionEvent(b1, ActionEvent.ACTION_PERFORMED, "") + + b1.actionPerformed = testAction + JythonBasicTests.flag = 0 + b1.doClick() + self.assertEquals( + JythonBasicTests.flag, 1, + 'expected one action per event but got %s' % JythonBasicTests.flag) + + b1.actionPerformed.append(testAction) + JythonBasicTests.flag = 0 + b1.doClick() + self.assertEquals(JythonBasicTests.flag, 2, 'two actions per event') + + b1.actionPerformed = testAction + JythonBasicTests.flag = 0 + b1.doClick() + self.assertEquals(JythonBasicTests.flag, 1, + 'one actions per event - again') + +def test_main(): + test_support.run_unittest(JythonBasicTests) + +if __name__=='__main__': + test_main() -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Thu May 19 05:41:34 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Thu, 19 May 2011 05:41:34 +0200 Subject: [Jython-checkins] jython: Modernize test_jser.py. Message-ID: http://hg.python.org/jython/rev/e3f2f660c2d9 changeset: 6224:e3f2f660c2d9 user: Frank Wierzbicki date: Wed May 18 20:41:27 2011 -0700 summary: Modernize test_jser.py. files: Lib/test/test_jser.py | 86 ++++++++++++++++-------------- 1 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Lib/test/test_jser.py b/Lib/test/test_jser.py --- a/Lib/test/test_jser.py +++ b/Lib/test/test_jser.py @@ -1,57 +1,65 @@ -from test_support import * +import unittest -print 'Java Serialization (test_jser.py)' +from test import test_support from java import io, awt -import os, sys +import os +import sys -object1 = 42 -object2 = ['a', 1, 1.0] + class Foo: def bar(self): return 'bar' -object3 = Foo() -object3.baz = 99 -object4 = awt.Color(1,2,3) +class JavaSerializationTests(unittest.TestCase): -print 'writing' + def setUp(self): + self.sername = os.path.join(sys.prefix, "test.ser") -sername = os.path.join(sys.prefix, "test.ser") -fout = io.ObjectOutputStream(io.FileOutputStream(sername)) -print 'Python int' -fout.writeObject(object1) -print 'Python list' -fout.writeObject(object2) -print 'Python instance' -fout.writeObject(object3) -print 'Java instance' -fout.writeObject(object4) -fout.close() + def tearDown(self): + os.remove(self.sername) -fin = io.ObjectInputStream(io.FileInputStream(sername)) -print 'reading' -iobject1 = fin.readObject() -iobject2 = fin.readObject() -iobject3 = fin.readObject() -iobject4 = fin.readObject() -fin.close() + def test_serialization(self): + object1 = 42 + object2 = ['a', 1, 1.0] + object3 = Foo() + object3.baz = 99 -#print iobject1, iobject2, iobject3, iobject3.__class__, iobject4 + object4 = awt.Color(1, 2, 3) -print 'Python int' -assert iobject1 == object1 + #writing + fout = io.ObjectOutputStream(io.FileOutputStream(self.sername)) + #Python int + fout.writeObject(object1) + #Python list + fout.writeObject(object2) + #Python instance + fout.writeObject(object3) + #Java instance + fout.writeObject(object4) + fout.close() -print 'Python list' -assert iobject2 == object2 + fin = io.ObjectInputStream(io.FileInputStream(self.sername)) -print 'Python instance' -assert iobject3.baz == 99 -assert iobject3.bar() == 'bar' -assert iobject3.__class__ == Foo + #reading + iobject1 = fin.readObject() + iobject2 = fin.readObject() + iobject3 = fin.readObject() + iobject4 = fin.readObject() + fin.close() -print 'Java instance' -assert iobject4 == object4 + self.assertEquals(iobject1, object1) + self.assertEquals(iobject2, object2) + self.assertEquals(iobject3.baz, 99) + self.assertEquals(iobject3.bar(), 'bar') + self.assertEquals(iobject3.__class__, Foo) + self.assertEquals(iobject4, object4) -os.remove(sername) + +def test_main(): + test_support.run_unittest(JavaSerializationTests) + + +if __name__ == "__main__": + test_main() -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Thu May 19 06:51:05 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Thu, 19 May 2011 06:51:05 +0200 Subject: [Jython-checkins] jython: Allow print_function in import __future__ print_function, ... Message-ID: http://hg.python.org/jython/rev/64f9685743f6 changeset: 6225:64f9685743f6 user: Frank Wierzbicki date: Wed May 18 21:50:58 2011 -0700 summary: Allow print_function in import __future__ print_function, ... files: grammar/Python.g | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/grammar/Python.g b/grammar/Python.g --- a/grammar/Python.g +++ b/grammar/Python.g @@ -932,10 +932,14 @@ | i1=import_as_names { String dottedText = $dotted_name.text; - String importText = $i1.text; - if (dottedText != null && dottedText.equals("__future__") && - importText != null && importText.equals("print_function")) { - printStatement = false; + if (dottedText != null && dottedText.equals("__future__")) { + List aliases = $i1.atypes; + for(alias a: aliases) { + if (a != null && a.getInternalName().equals("print_function")) { + printStatement = false; + break; + } + } } stype = new ImportFrom($FROM, actions.makeFromText($d, $dotted_name.names), actions.makeModuleNameNode($d, $dotted_name.names), -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Thu May 19 06:58:09 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Thu, 19 May 2011 06:58:09 +0200 Subject: [Jython-checkins] jython: Move test_janoninner into test_jbasic + pep8 cleanups. Message-ID: http://hg.python.org/jython/rev/87355ff944c5 changeset: 6226:87355ff944c5 user: Frank Wierzbicki date: Wed May 18 21:58:02 2011 -0700 summary: Move test_janoninner into test_jbasic + pep8 cleanups. files: Lib/test/test_janoninner.py | 15 --------------- Lib/test/test_jbasic.py | 23 +++++++++++++++-------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/Lib/test/test_janoninner.py b/Lib/test/test_janoninner.py deleted file mode 100644 --- a/Lib/test/test_janoninner.py +++ /dev/null @@ -1,15 +0,0 @@ -# test of PR#201 - -import sys -from test_support import * - -print 'Java Anonymous Inner Classes (test_janoninner.py)' - -print 'importing' -import javatests.AnonInner - -print 'instantiating' -x = javatests.AnonInner() - -print 'invoking' -assert x.doit() == 2000 diff --git a/Lib/test/test_jbasic.py b/Lib/test/test_jbasic.py --- a/Lib/test/test_jbasic.py +++ b/Lib/test/test_jbasic.py @@ -18,8 +18,10 @@ self.assertEquals(abs(-2), 2l, 'Python int to Java long') self.assertEquals(abs(-2l), 2l, 'Python long to Java long') - try: abs(-123456789123456789123l) - except TypeError: pass + try: + abs(-123456789123456789123l) + except TypeError: + pass def test_strings(self): self.assertEquals(Integer.valueOf('42'), 42, @@ -39,13 +41,12 @@ for i in vec: self.assertEquals(i, expected, 'testing __iter__ on java.util.Vector') - expected = expected+1 + expected = expected + 1 expected = 0 for i in iter(vec): self.assertEquals(i, expected, 'testing iter(java.util.Vector)') - expected = expected+1 - + expected = expected + 1 def test_java_objects(self): self.assertEquals(BigInteger('1234', 10).intValue(), 1234, @@ -80,7 +81,7 @@ self.assertFalse(s.regionMatches(1, 'eLl', 0, 3), 'should ignore case') def test_get_set(self): - d = Dimension(3,9) + d = Dimension(3, 9) self.assertEquals(d.width, 3) self.assertEquals(d.height, 9) d.width = 42 @@ -92,7 +93,7 @@ except AttributeError: pass else: - raise AssertionError, 'd.foo should throw type error' + raise AssertionError('d.foo should throw type error') # Used in test_java_bean_properties. flag = 0 @@ -129,8 +130,14 @@ self.assertEquals(JythonBasicTests.flag, 1, 'one actions per event - again') + def test_anonymous_inner_classes(self): + import javatests.AnonInner + x = javatests.AnonInner() + self.assertEquals(x.doit(), 2000) + + def test_main(): test_support.run_unittest(JythonBasicTests) -if __name__=='__main__': +if __name__ == '__main__': test_main() -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Fri May 20 05:12:18 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Fri, 20 May 2011 05:12:18 +0200 Subject: [Jython-checkins] =?utf8?q?jython=3A_This_ancient_test_is_IMO_ful?= =?utf8?q?ly_covered_by_more_modern_testing=2E?= Message-ID: http://hg.python.org/jython/rev/b7663d3b664b changeset: 6228:b7663d3b664b user: Frank Wierzbicki date: Thu May 19 14:42:43 2011 -0700 summary: This ancient test is IMO fully covered by more modern testing. files: Lib/test/test_methods.py | 62 ---------------------------- 1 files changed, 0 insertions(+), 62 deletions(-) diff --git a/Lib/test/test_methods.py b/Lib/test/test_methods.py deleted file mode 100644 --- a/Lib/test/test_methods.py +++ /dev/null @@ -1,62 +0,0 @@ -# Python test set -- part 7, bound and unbound methods - -from test_support import * - -print 'Bound and unbound methods (test_methods.py)' - -class A: - def one(self): return 'one' - -class B(A): - def two(self): return 'two' - -class C(A): - def one(self): return 'another one' - -a = A() -b = B() -c = C() - -print 'unbound method equality' -assert A.one == B.one -assert A.one <> C.one - -print 'method attributes' -assert A.one.im_func == a.one.im_func -assert a.one.im_self == a -assert a.one.im_class == A -assert b.one.im_self == b -assert b.one.im_class == B - -print 'unbound method invocation w/ explicit self' -assert A.one(b) == 'one' -assert B.two(b) == 'two' -assert B.one(b) == 'one' - -assert A.one(c) == 'one' -assert C.one(c) == 'another one' - -assert A.one(a) == 'one' -try: - B.one(a) - assert 0 -except TypeError: - pass -try: - C.one(a) - assert 0 -except TypeError: - pass - -print '"unbound" methods of builtin types' -w = [1,2,3].append -x = [4,5,6].append -assert w <> x -assert w.__self__ <> x.__self__ - -y = w.__self__[:] -z = x.__self__[:] - -assert y.append.__self__ <> w -z.append(7) -assert z == (x.__self__+[7]) -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Fri May 20 05:12:18 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Fri, 20 May 2011 05:12:18 +0200 Subject: [Jython-checkins] =?utf8?q?jython=3A_Merge_test=5Fjavalist_into_t?= =?utf8?q?est=5Fjbasic=2E?= Message-ID: http://hg.python.org/jython/rev/ebbe7b0253e9 changeset: 6227:ebbe7b0253e9 user: Frank Wierzbicki date: Thu May 19 08:24:50 2011 -0700 summary: Merge test_javalist into test_jbasic. files: Lib/test/test_javalist.py | 52 --------------------------- Lib/test/test_jbasic.py | 44 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 52 deletions(-) diff --git a/Lib/test/test_javalist.py b/Lib/test/test_javalist.py deleted file mode 100644 --- a/Lib/test/test_javalist.py +++ /dev/null @@ -1,52 +0,0 @@ -from javatests import ListTest - -class PyListTest(ListTest): - - def __init__(self): - ListTest.__init__(self) - - def newInstance(self, coll): - if coll is None: - return list() - else: - return list(coll) - - def isReadOnly(self): - return False - - -class PyTupleTest(ListTest): - - def __init__(self): - ListTest.__init__(self) - - def newInstance(self, coll): - if coll is None: - return tuple() - else: - return tuple(coll) - - def isReadOnly(self): - return True - - -# these first two tests just verify that we have a good unit test -print "ListTest.java driver (test_javalist.py)" -print "running test on ArrayList" -alt = ListTest.getArrayListTest(False) -alt.testAll() - -print "running test on ArrayList (read-only)" -alt = ListTest.getArrayListTest(True) -alt.testAll() - - -# Now run the critical tests - -print "running test on PyListTest" -plt = PyListTest() -plt.testAll() - -print "running test on PyTupleTest" -ptt = PyTupleTest() -ptt.testAll() diff --git a/Lib/test/test_jbasic.py b/Lib/test/test_jbasic.py --- a/Lib/test/test_jbasic.py +++ b/Lib/test/test_jbasic.py @@ -10,6 +10,37 @@ from java.util import Vector from javax import swing +from javatests import ListTest + +class PyListTest(ListTest): + + def __init__(self): + ListTest.__init__(self) + + def newInstance(self, coll): + if coll is None: + return list() + else: + return list(coll) + + def isReadOnly(self): + return False + + +class PyTupleTest(ListTest): + + def __init__(self): + ListTest.__init__(self) + + def newInstance(self, coll): + if coll is None: + return tuple() + else: + return tuple(coll) + + def isReadOnly(self): + return True + class JythonBasicTests(unittest.TestCase): @@ -135,6 +166,19 @@ x = javatests.AnonInner() self.assertEquals(x.doit(), 2000) + def test_javalists(self): + # these first two tests just verify that we have a good unit test + alt = ListTest.getArrayListTest(False) + alt.testAll() + + alt = ListTest.getArrayListTest(True) + alt.testAll() + + # Now run the tests + plt = PyListTest() + plt.testAll() + ptt = PyTupleTest() + ptt.testAll() def test_main(): test_support.run_unittest(JythonBasicTests) -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Fri May 20 05:12:18 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Fri, 20 May 2011 05:12:18 +0200 Subject: [Jython-checkins] =?utf8?q?jython=3A_Reapply_Jython_exclusion_to_?= =?utf8?q?test=2E?= Message-ID: http://hg.python.org/jython/rev/fef14f50cdff changeset: 6230:fef14f50cdff user: Frank Wierzbicki date: Thu May 19 20:11:54 2011 -0700 summary: Reapply Jython exclusion to test. files: Lib/test/test_new.py | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_new.py b/Lib/test/test_new.py --- a/Lib/test/test_new.py +++ b/Lib/test/test_new.py @@ -101,8 +101,7 @@ test_closure(g, (1, 1), ValueError) # closure is wrong size test_closure(f, g.func_closure, ValueError) # no closure needed - # Note: Jython will never have new.code() - if hasattr(new, 'code'): + if hasattr(new, 'code') and not test_support.is_jython: def test_code(self): # bogus test of new.code() def f(a): pass -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Fri May 20 05:12:18 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Fri, 20 May 2011 05:12:18 +0200 Subject: [Jython-checkins] =?utf8?q?jython=3A_from?= Message-ID: http://hg.python.org/jython/rev/2ec714793ece changeset: 6229:2ec714793ece user: Frank Wierzbicki date: Thu May 19 16:44:23 2011 -0700 summary: from https://svn.python.org/projects/python/branches/release26-maint/Lib/test/test_new.py at 88766 files: Lib/test/test_new.py | 301 ++++++++++++++---------------- 1 files changed, 141 insertions(+), 160 deletions(-) diff --git a/Lib/test/test_new.py b/Lib/test/test_new.py --- a/Lib/test/test_new.py +++ b/Lib/test/test_new.py @@ -1,182 +1,163 @@ -from test.test_support import verbose, verify, TestFailed +import unittest +from test import test_support import sys -import new +new = test_support.import_module('new', deprecated=True) -class Eggs: - def get_yolks(self): - return self.yolks +class NewTest(unittest.TestCase): + def test_spam(self): + class Eggs: + def get_yolks(self): + return self.yolks -print 'new.module()' -m = new.module('Spam') -if verbose: - print m -m.Eggs = Eggs -sys.modules['Spam'] = m -import Spam + m = new.module('Spam') + m.Eggs = Eggs + sys.modules['Spam'] = m + import Spam -def get_more_yolks(self): - return self.yolks + 3 + def get_more_yolks(self): + return self.yolks + 3 -print 'new.classobj()' -C = new.classobj('Spam', (Spam.Eggs,), {'get_more_yolks': get_more_yolks}) -if verbose: - print C -print 'new.instance()' -c = new.instance(C, {'yolks': 3}) -if verbose: - print c -o = new.instance(C) -verify(o.__dict__ == {}, - "new __dict__ should be empty") -del o -o = new.instance(C, None) -verify(o.__dict__ == {}, - "new __dict__ should be empty") -del o + # new.classobj() + C = new.classobj('Spam', (Spam.Eggs,), {'get_more_yolks': get_more_yolks}) -def break_yolks(self): - self.yolks = self.yolks - 2 -print 'new.instancemethod()' -im = new.instancemethod(break_yolks, c, C) -if verbose: - print im + # new.instance() + c = new.instance(C, {'yolks': 3}) -verify(c.get_yolks() == 3 and c.get_more_yolks() == 6, - 'Broken call of hand-crafted class instance') -im() -verify(c.get_yolks() == 1 and c.get_more_yolks() == 4, - 'Broken call of hand-crafted instance method') + o = new.instance(C) + self.assertEqual(o.__dict__, {}, "new __dict__ should be empty") + del o + o = new.instance(C, None) + self.assertEqual(o.__dict__, {}, "new __dict__ should be empty") + del o -im = new.instancemethod(break_yolks, c) -im() -verify(c.get_yolks() == -1) -try: - new.instancemethod(break_yolks, None) -except TypeError: - pass -else: - raise TestFailed, "dangerous instance method creation allowed" + def break_yolks(self): + self.yolks = self.yolks - 2 -# Verify that instancemethod() doesn't allow keyword args -try: - new.instancemethod(break_yolks, c, kw=1) -except TypeError: - pass -else: - raise TestFailed, "instancemethod shouldn't accept keyword args" + # new.instancemethod() + im = new.instancemethod(break_yolks, c, C) -# It's unclear what the semantics should be for a code object compiled at -# module scope, but bound and run in a function. In CPython, `c' is global -# (by accident?) while in Jython, `c' is local. The intent of the test -# clearly is to make `c' global, so let's be explicit about it. -codestr = ''' -global c -a = 1 -b = 2 -c = a + b -''' + self.assertEqual(c.get_yolks(), 3, + 'Broken call of hand-crafted class instance') + self.assertEqual(c.get_more_yolks(), 6, + 'Broken call of hand-crafted class instance') -ccode = compile(codestr, '', 'exec') -# Jython doesn't have a __builtins__, so use a portable alternative -import __builtin__ -g = {'c': 0, '__builtins__': __builtin__} -# this test could be more robust -print 'new.function()' -func = new.function(ccode, g) -if verbose: - print func -func() -verify(g['c'] == 3, - 'Could not create a proper function object') + im() + self.assertEqual(c.get_yolks(), 1, + 'Broken call of hand-crafted instance method') + self.assertEqual(c.get_more_yolks(), 4, + 'Broken call of hand-crafted instance method') -# test the various extended flavors of function.new -def f(x): - def g(y): - return x + y - return g -g = f(4) -new.function(f.func_code, {}, "blah") -g2 = new.function(g.func_code, {}, "blah", (2,), g.func_closure) -verify(g2() == 6) -g3 = new.function(g.func_code, {}, "blah", None, g.func_closure) -verify(g3(5) == 9) -def test_closure(func, closure, exc): - try: - new.function(func.func_code, {}, "", None, closure) - except exc: - pass - else: - print "corrupt closure accepted" + im = new.instancemethod(break_yolks, c) + im() + self.assertEqual(c.get_yolks(), -1) -test_closure(g, None, TypeError) # invalid closure -test_closure(g, (1,), TypeError) # non-cell in closure -test_closure(g, (1, 1), ValueError) # closure is wrong size -test_closure(f, g.func_closure, ValueError) # no closure needed + # Verify that dangerous instance method creation is forbidden + self.assertRaises(TypeError, new.instancemethod, break_yolks, None) -print 'new.code()' -# bogus test of new.code() -if hasattr(new, 'code') and not sys.platform.startswith('java'): - def f(a): pass + # Verify that instancemethod() doesn't allow keyword args + self.assertRaises(TypeError, new.instancemethod, break_yolks, c, kw=1) - c = f.func_code - argcount = c.co_argcount - nlocals = c.co_nlocals - stacksize = c.co_stacksize - flags = c.co_flags - codestring = c.co_code - constants = c.co_consts - names = c.co_names - varnames = c.co_varnames - filename = c.co_filename - name = c.co_name - firstlineno = c.co_firstlineno - lnotab = c.co_lnotab - freevars = c.co_freevars - cellvars = c.co_cellvars + def test_scope(self): + # It's unclear what the semantics should be for a code object compiled + # at module scope, but bound and run in a function. In CPython, `c' is + # global (by accident?) while in Jython, `c' is local. The intent of + # the test clearly is to make `c' global, so let's be explicit about it. + codestr = ''' + global c + a = 1 + b = 2 + c = a + b + ''' - d = new.code(argcount, nlocals, stacksize, flags, codestring, - constants, names, varnames, filename, name, - firstlineno, lnotab, freevars, cellvars) + codestr = "\n".join(l.strip() for l in codestr.splitlines()) - # test backwards-compatibility version with no freevars or cellvars - d = new.code(argcount, nlocals, stacksize, flags, codestring, - constants, names, varnames, filename, name, - firstlineno, lnotab) + ccode = compile(codestr, '', 'exec') + # Jython doesn't have a __builtins__, so use a portable alternative + import __builtin__ + g = {'c': 0, '__builtins__': __builtin__} - try: # this used to trigger a SystemError - d = new.code(-argcount, nlocals, stacksize, flags, codestring, - constants, names, varnames, filename, name, - firstlineno, lnotab) - except ValueError: - pass - else: - raise TestFailed, "negative co_argcount didn't trigger an exception" + # this test could be more robust + func = new.function(ccode, g) + func() + self.assertEqual(g['c'], 3, 'Could not create a proper function object') - try: # this used to trigger a SystemError - d = new.code(argcount, -nlocals, stacksize, flags, codestring, - constants, names, varnames, filename, name, - firstlineno, lnotab) - except ValueError: - pass - else: - raise TestFailed, "negative co_nlocals didn't trigger an exception" + def test_function(self): + # test the various extended flavors of function.new + def f(x): + def g(y): + return x + y + return g + g = f(4) + new.function(f.func_code, {}, "blah") + g2 = new.function(g.func_code, {}, "blah", (2,), g.func_closure) + self.assertEqual(g2(), 6) + g3 = new.function(g.func_code, {}, "blah", None, g.func_closure) + self.assertEqual(g3(5), 9) + def test_closure(func, closure, exc): + self.assertRaises(exc, new.function, func.func_code, {}, "", None, closure) - try: # this used to trigger a Py_FatalError! - d = new.code(argcount, nlocals, stacksize, flags, codestring, - constants, (5,), varnames, filename, name, - firstlineno, lnotab) - except TypeError: - pass - else: - raise TestFailed, "non-string co_name didn't trigger an exception" + test_closure(g, None, TypeError) # invalid closure + test_closure(g, (1,), TypeError) # non-cell in closure + test_closure(g, (1, 1), ValueError) # closure is wrong size + test_closure(f, g.func_closure, ValueError) # no closure needed - # new.code used to be a way to mutate a tuple... - class S(str): pass - t = (S("ab"),) - d = new.code(argcount, nlocals, stacksize, flags, codestring, - constants, t, varnames, filename, name, - firstlineno, lnotab) - verify(type(t[0]) is S, "eek, tuple changed under us!") + # Note: Jython will never have new.code() + if hasattr(new, 'code'): + def test_code(self): + # bogus test of new.code() + def f(a): pass - if verbose: - print d + c = f.func_code + argcount = c.co_argcount + nlocals = c.co_nlocals + stacksize = c.co_stacksize + flags = c.co_flags + codestring = c.co_code + constants = c.co_consts + names = c.co_names + varnames = c.co_varnames + filename = c.co_filename + name = c.co_name + firstlineno = c.co_firstlineno + lnotab = c.co_lnotab + freevars = c.co_freevars + cellvars = c.co_cellvars + + d = new.code(argcount, nlocals, stacksize, flags, codestring, + constants, names, varnames, filename, name, + firstlineno, lnotab, freevars, cellvars) + + # test backwards-compatibility version with no freevars or cellvars + d = new.code(argcount, nlocals, stacksize, flags, codestring, + constants, names, varnames, filename, name, + firstlineno, lnotab) + + # negative co_argcount used to trigger a SystemError + self.assertRaises(ValueError, new.code, + -argcount, nlocals, stacksize, flags, codestring, + constants, names, varnames, filename, name, firstlineno, lnotab) + + # negative co_nlocals used to trigger a SystemError + self.assertRaises(ValueError, new.code, + argcount, -nlocals, stacksize, flags, codestring, + constants, names, varnames, filename, name, firstlineno, lnotab) + + # non-string co_name used to trigger a Py_FatalError + self.assertRaises(TypeError, new.code, + argcount, nlocals, stacksize, flags, codestring, + constants, (5,), varnames, filename, name, firstlineno, lnotab) + + # new.code used to be a way to mutate a tuple... + class S(str): + pass + t = (S("ab"),) + d = new.code(argcount, nlocals, stacksize, flags, codestring, + constants, t, varnames, filename, name, + firstlineno, lnotab) + self.assert_(type(t[0]) is S, "eek, tuple changed under us!") + +def test_main(): + test_support.run_unittest(NewTest) + +if __name__ == "__main__": + test_main() -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Fri May 20 07:55:48 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Fri, 20 May 2011 07:55:48 +0200 Subject: [Jython-checkins] =?utf8?q?jython=3A_CPython_test=5Fpopen2=2Epy_w?= =?utf8?q?orks_for_me=2C_so_deleting_our_copy=2E?= Message-ID: http://hg.python.org/jython/rev/1f9ba25135d2 changeset: 6231:1f9ba25135d2 user: Frank Wierzbicki date: Thu May 19 22:55:40 2011 -0700 summary: CPython test_popen2.py works for me, so deleting our copy. files: Lib/test/test_popen2.py | 78 ----------------------------- 1 files changed, 0 insertions(+), 78 deletions(-) diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py deleted file mode 100644 --- a/Lib/test/test_popen2.py +++ /dev/null @@ -1,78 +0,0 @@ -#! /usr/bin/env python -"""Test script for popen2.py - Christian Tismer -""" - -import os -import sys -from test.test_support import TestSkipped, is_jython, reap_children - -# popen2 contains its own testing routine -# which is especially useful to see if open files -# like stdin can be read successfully by a forked -# subprocess. - -def main(): - print "Test popen2 module:" - if (sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos') \ - and __name__ != '__main__': - # Locks get messed up or something. Generally we're supposed - # to avoid mixing "posix" fork & exec with native threads, and - # they may be right about that after all. - raise TestSkipped, "popen2() doesn't work during import on " + sys.platform - try: - from os import popen - except ImportError: - # if we don't have os.popen, check that - # we have os.fork. if not, skip the test - # (by raising an ImportError) - from os import fork - import popen2 - popen2._test() - - -def _test(): - # same test as popen2._test(), but using the os.popen*() API - print "Testing os module:" - import popen2 - # When the test runs, there shouldn't be any open pipes - popen2._cleanup() - assert not popen2._active, "Active pipes when test starts " + repr([c.cmd for c in popen2._active]) - cmd = "cat" - teststr = "ab cd\n" - if os.name == "nt" or (is_jython and os._name == 'nt'): - cmd = "more" - # "more" doesn't act the same way across Windows flavors, - # sometimes adding an extra newline at the start or the - # end. So we strip whitespace off both ends for comparison. - expected = teststr.strip() - print "testing popen2..." - w, r = os.popen2(cmd) - w.write(teststr) - w.close() - got = r.read() - if got.strip() != expected: - raise ValueError("wrote %r read %r" % (teststr, got)) - print "testing popen3..." - try: - w, r, e = os.popen3([cmd]) - except: - w, r, e = os.popen3(cmd) - w.write(teststr) - w.close() - got = r.read() - if got.strip() != expected: - raise ValueError("wrote %r read %r" % (teststr, got)) - got = e.read() - if got: - raise ValueError("unexpected %r on stderr" % (got,)) - for inst in popen2._active[:]: - inst.wait() - popen2._cleanup() - if popen2._active: - raise ValueError("_active not empty") - print "All OK" - -main() -_test() -reap_children() -- Repository URL: http://hg.python.org/jython From jython-checkins at python.org Fri May 20 08:09:30 2011 From: jython-checkins at python.org (frank.wierzbicki) Date: Fri, 20 May 2011 08:09:30 +0200 Subject: [Jython-checkins] =?utf8?q?jython=3A_Allow_br=27foo=27_string_exp?= =?utf8?q?ressions=2E?= Message-ID: http://hg.python.org/jython/rev/b75d6d8f75ed changeset: 6232:b75d6d8f75ed user: Frank Wierzbicki date: Thu May 19 23:09:22 2011 -0700 summary: Allow br'foo' string expressions. files: grammar/Python.g | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/grammar/Python.g b/grammar/Python.g --- a/grammar/Python.g +++ b/grammar/Python.g @@ -2295,7 +2295,7 @@ * should make us exit loop not continue. */ STRING - : ('r'|'u'|'b'|'ur'|'R'|'U'|'B'|'UR'|'uR'|'Ur')? + : ('r'|'u'|'b'|'ur'|'br'|'R'|'U'|'B'|'UR'|'BR'|'uR'|'Ur'|'Br'|'bR')? ( '\'\'\'' (options {greedy=false;}:TRIAPOS)* '\'\'\'' | '"""' (options {greedy=false;}:TRIQUOTE)* '"""' | '"' (ESC|~('\\'|'\n'|'"'))* '"' -- Repository URL: http://hg.python.org/jython From pjenvey at underboss.org Fri May 20 22:19:00 2011 From: pjenvey at underboss.org (Philip Jenvey) Date: Fri, 20 May 2011 13:19:00 -0700 Subject: [Jython-checkins] jython: CPython test_popen2.py works for me, so deleting our copy. In-Reply-To: References: Message-ID: I think test_popen2 will still need our modification for Windows ( http://hg.python.org/jython/rev/2cd6e2b49156 ). Wish we had a Windows buildbot =[ On May 19, 2011, at 10:55 PM, frank.wierzbicki wrote: > http://hg.python.org/jython/rev/1f9ba25135d2 > changeset: 6231:1f9ba25135d2 > user: Frank Wierzbicki > date: Thu May 19 22:55:40 2011 -0700 > summary: > CPython test_popen2.py works for me, so deleting our copy. > > files: > Lib/test/test_popen2.py | 78 ----------------------------- > 1 files changed, 0 insertions(+), 78 deletions(-) > > > diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py > deleted file mode 100644 > --- a/Lib/test/test_popen2.py > +++ /dev/null > @@ -1,78 +0,0 @@ > -#! /usr/bin/env python > -"""Test script for popen2.py > - Christian Tismer > -""" > - > -import os > -import sys > -from test.test_support import TestSkipped, is_jython, reap_children > - > -# popen2 contains its own testing routine > -# which is especially useful to see if open files > -# like stdin can be read successfully by a forked > -# subprocess. > - > -def main(): > - print "Test popen2 module:" > - if (sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos') \ > - and __name__ != '__main__': > - # Locks get messed up or something. Generally we're supposed > - # to avoid mixing "posix" fork & exec with native threads, and > - # they may be right about that after all. > - raise TestSkipped, "popen2() doesn't work during import on " + sys.platform > - try: > - from os import popen > - except ImportError: > - # if we don't have os.popen, check that > - # we have os.fork. if not, skip the test > - # (by raising an ImportError) > - from os import fork > - import popen2 > - popen2._test() > - > - > -def _test(): > - # same test as popen2._test(), but using the os.popen*() API > - print "Testing os module:" > - import popen2 > - # When the test runs, there shouldn't be any open pipes > - popen2._cleanup() > - assert not popen2._active, "Active pipes when test starts " + repr([c.cmd for c in popen2._active]) > - cmd = "cat" > - teststr = "ab cd\n" > - if os.name == "nt" or (is_jython and os._name == 'nt'): > - cmd = "more" > - # "more" doesn't act the same way across Windows flavors, > - # sometimes adding an extra newline at the start or the > - # end. So we strip whitespace off both ends for comparison. > - expected = teststr.strip() > - print "testing popen2..." > - w, r = os.popen2(cmd) > - w.write(teststr) > - w.close() > - got = r.read() > - if got.strip() != expected: > - raise ValueError("wrote %r read %r" % (teststr, got)) > - print "testing popen3..." > - try: > - w, r, e = os.popen3([cmd]) > - except: > - w, r, e = os.popen3(cmd) > - w.write(teststr) > - w.close() > - got = r.read() > - if got.strip() != expected: > - raise ValueError("wrote %r read %r" % (teststr, got)) > - got = e.read() > - if got: > - raise ValueError("unexpected %r on stderr" % (got,)) > - for inst in popen2._active[:]: > - inst.wait() > - popen2._cleanup() > - if popen2._active: > - raise ValueError("_active not empty") > - print "All OK" > - > -main() > -_test() > -reap_children() > > -- > Repository URL: http://hg.python.org/jython > _______________________________________________ > Jython-checkins mailing list > Jython-checkins at python.org > http://mail.python.org/mailman/listinfo/jython-checkins -- Philip Jenvey From fwierzbicki at gmail.com Sat May 21 19:32:07 2011 From: fwierzbicki at gmail.com (fwierzbicki at gmail.com) Date: Sat, 21 May 2011 10:32:07 -0700 Subject: [Jython-checkins] jython: CPython test_popen2.py works for me, so deleting our copy. In-Reply-To: References: Message-ID: On Fri, May 20, 2011 at 1:19 PM, Philip Jenvey wrote: > I think test_popen2 will still need our modification for Windows ( http://hg.python.org/jython/rev/2cd6e2b49156 ). Wish we had a Windows buildbot =[ > oh crud - since I touched it last I'll find a windows machine this weekend and see if I can put things back together. :( -- it needed updating anyway. -Frank From pjenvey at underboss.org Sat May 21 21:28:49 2011 From: pjenvey at underboss.org (Philip Jenvey) Date: Sat, 21 May 2011 12:28:49 -0700 Subject: [Jython-checkins] jython: CPython test_popen2.py works for me, so deleting our copy. In-Reply-To: References: Message-ID: <8A3EEBBF-DC07-4056-B78A-EA268C7C516C@underboss.org> On May 21, 2011, at 10:32 AM, fwierzbicki at gmail.com wrote: > On Fri, May 20, 2011 at 1:19 PM, Philip Jenvey wrote: >> I think test_popen2 will still need our modification for Windows ( http://hg.python.org/jython/rev/2cd6e2b49156 ). Wish we had a Windows buildbot =[ >> > oh crud - since I touched it last I'll find a windows machine this > weekend and see if I can put things back together. :( -- it needed > updating anyway. I wouldn't worry too much about it, I don't think test_popen2 really changed all that much from 2.5 anyway. They mostly just converted it to use unittest. -- Philip Jenvey From fwierzbicki at gmail.com Mon May 23 18:52:15 2011 From: fwierzbicki at gmail.com (fwierzbicki at gmail.com) Date: Mon, 23 May 2011 09:52:15 -0700 Subject: [Jython-checkins] jython: CPython test_popen2.py works for me, so deleting our copy. In-Reply-To: <8A3EEBBF-DC07-4056-B78A-EA268C7C516C@underboss.org> References: <8A3EEBBF-DC07-4056-B78A-EA268C7C516C@underboss.org> Message-ID: On Sat, May 21, 2011 at 12:28 PM, Philip Jenvey wrote: > > On May 21, 2011, at 10:32 AM, fwierzbicki at gmail.com wrote: > >> On Fri, May 20, 2011 at 1:19 PM, Philip Jenvey wrote: >>> I think test_popen2 will still need our modification for Windows ( http://hg.python.org/jython/rev/2cd6e2b49156 ). Wish we had a Windows buildbot =[ >>> >> oh crud - since I touched it last I'll find a windows machine this >> weekend and see if I can put things back together. :( -- it needed >> updating anyway. > > I wouldn't worry too much about it, I don't think test_popen2 really changed all that much from 2.5 anyway. They mostly just converted it to use unittest. > True, but since we deleted the output/ directory it shows up as a failure (and I don't want to bring it back since I think this is the last test like that). My only windows machine is giving me trouble with Java for some reason - but I'll get to it soonish. -Frank