From jython-checkins at python.org Sat May 4 12:25:59 2019 From: jython-checkins at python.org (jeff.allen) Date: Sat, 04 May 2019 16:25:59 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_Update_JNR/JFFI_and_ARM_st?= =?utf-8?q?ub=2E_Fixes_GH-108=2E?= Message-ID: <20190504162559.1.54F5B01271F53F84@mg.python.org> https://hg.python.org/jython/rev/6e25c0f19222 changeset: 8241:6e25c0f19222 user: James Mudd date: Fri May 03 20:38:26 2019 +0100 summary: Update JNR/JFFI and ARM stub. Fixes GH-108. Updates: - jnr-ffi 2.1.7 to 2.1.9 - jnr-posix 3.0.44 to 3.0.49 - jnr-constants 0.9.9 to 0.9.12 - jffi 1.2.15 to 1.2.18 This also updates the ARM stub for a newer one. This was recently updated to improve ARM hard float support and is needed to fix this bug. See https://github.com/jnr/jffi/commit/c29326dfd03a1eb3fe1b78b5934fc84a4b9cf16d files: NEWS | 1 + build.gradle | 8 ++++---- build.xml | 16 ++++++++-------- extlibs/jffi-1.2.18.jar | Bin extlibs/jffi-arm-Linux.jar | Bin extlibs/jnr-constants-0.9.12.jar | Bin extlibs/jnr-constants-0.9.9.jar | Bin extlibs/jnr-ffi-2.1.9.jar | Bin extlibs/jnr-posix-3.0.49.jar | Bin 9 files changed, 13 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ Development tip Bugs fixed + - [ GH-108 ] Updates to JNR/JFFI to improve ARM HF support - [ 2445 ] Eclipse's DelegatingFeatureMap has MRO conflict (and IBM's MQQueue) - [ GH-121 ] Allow struct unpack and unpack_from bytearray and buffer - [ 2635 ] AST.lineno ignored by compile diff --git a/build.gradle b/build.gradle --- a/build.gradle +++ b/build.gradle @@ -158,11 +158,11 @@ implementation group: 'com.carrotsearch', name: 'java-sizeof', version: '0.0.5' - implementation group: 'com.github.jnr', name: 'jffi', version: '1.2.16' + implementation group: 'com.github.jnr', name: 'jffi', version: '1.2.18' implementation group: 'com.github.jnr', name: 'jnr-netdb', version: '1.1.6' - implementation group: 'com.github.jnr', name: 'jnr-ffi', version: '2.1.7' - implementation group: 'com.github.jnr', name: 'jnr-posix', version: '3.0.44' - implementation group: 'com.github.jnr', name: 'jnr-constants', version: '0.9.9' + implementation group: 'com.github.jnr', name: 'jnr-ffi', version: '2.1.9' + implementation group: 'com.github.jnr', name: 'jnr-posix', version: '3.0.49' + implementation group: 'com.github.jnr', name: 'jnr-constants', version: '0.9.12' implementation group: 'jline', name: 'jline', version: '2.14.5' diff --git a/build.xml b/build.xml --- a/build.xml +++ b/build.xml @@ -152,12 +152,12 @@ - + - + - - + + @@ -600,11 +600,11 @@ - - + + - - + + diff --git a/extlibs/jffi-1.2.16.jar b/extlibs/jffi-1.2.18.jar rename from extlibs/jffi-1.2.16.jar rename to extlibs/jffi-1.2.18.jar index e253de5b1088af0042921ec07c507add06e5f858..d5218fad127e17baa4e761a03b218d99026f8eb6 GIT binary patch [stripped] diff --git a/extlibs/jffi-arm-Linux.jar b/extlibs/jffi-arm-Linux.jar index b3c5d977c1b7ad3fc196bfe2cd24fe56129dc8f9..f9a048b77d6af53661e9a9b5aae7e0f1ccabc599 GIT binary patch [stripped] diff --git a/extlibs/jnr-constants-0.9.12.jar b/extlibs/jnr-constants-0.9.12.jar new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..d894741f4b85d19b626a11f1220468ee5ba6d389 GIT binary patch [stripped] diff --git a/extlibs/jnr-constants-0.9.9.jar b/extlibs/jnr-constants-0.9.9.jar deleted file mode 100644 index a877bc42b6df7755e5eab266139a1c5bd8076a4d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] diff --git a/extlibs/jnr-ffi-2.1.7.jar b/extlibs/jnr-ffi-2.1.9.jar rename from extlibs/jnr-ffi-2.1.7.jar rename to extlibs/jnr-ffi-2.1.9.jar index 23d7e51a9fa8850123ae31025680f074db289861..df68592b92a779289093cf4569c952ab31432a5f GIT binary patch [stripped] diff --git a/extlibs/jnr-posix-3.0.44.jar b/extlibs/jnr-posix-3.0.49.jar rename from extlibs/jnr-posix-3.0.44.jar rename to extlibs/jnr-posix-3.0.49.jar index 2435a0d267ad23bea132f9cba6c845e0b5f211cf..bb75e304f466390878396ed62bf746cf8286149c GIT binary patch [stripped] -- Repository URL: https://hg.python.org/jython From jython-checkins at python.org Sat May 4 12:26:00 2019 From: jython-checkins at python.org (jeff.allen) Date: Sat, 04 May 2019 16:26:00 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_Avoid_some_deprecation_war?= =?utf-8?q?nings=2E_Remaining_ones_should_still_nag_us=2E?= Message-ID: <20190504162600.1.F9A4F56CE5EC69AC@mg.python.org> https://hg.python.org/jython/rev/87a5f7e8245b changeset: 8242:87a5f7e8245b user: Jeff Allen date: Sat May 04 16:25:47 2019 +0100 summary: Avoid some deprecation warnings. Remaining ones should still nag us. files: src/org/python/core/PyObject.java | 4 +--- src/org/python/core/imp.java | 2 +- src/org/python/modules/_py_compile.java | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/org/python/core/PyObject.java b/src/org/python/core/PyObject.java --- a/src/org/python/core/PyObject.java +++ b/src/org/python/core/PyObject.java @@ -123,19 +123,17 @@ } /** - *

* From Jython 2.7 on, {@code PyObject}s must not have finalizers directly. If a finalizer, * a.k.a. {@code __del__} is needed, follow the instructions in the documentation of * {@link org.python.core.finalization.FinalizablePyObject}. - *

*

* Note that this empty finalizer implementation is optimized away by the JVM. (See Discovering Objects with * Non-trivial Finalizers). So {@code PyObject}s are not expensively treated as finalizable * objects by the Java-GC. Its single intention is to prevent subclasses from having Java-style * finalizers. - *

*/ + @SuppressWarnings("deprecation") // See the Javadoc @Override protected final void finalize() throws Throwable {} 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 @@ -441,7 +441,7 @@ * @param sourceFilename explicit source file name (or {@code null} to use that in source) * @param compiledFilename ignored (huh?) * @return Java byte code as array - * @deprecated Use {@link #compileSource(String, File, String, String)} instead. + * @deprecated Use {@link #compileSource(String, File, String)} instead. */ @Deprecated public static byte[] compileSource(String name, File source, String sourceFilename, diff --git a/src/org/python/modules/_py_compile.java b/src/org/python/modules/_py_compile.java --- a/src/org/python/modules/_py_compile.java +++ b/src/org/python/modules/_py_compile.java @@ -34,7 +34,7 @@ // Convert file in which to put the byte code and display name (each may be null) String c = (compiledName == null) ? null : sys.getPath(Py.fileSystemDecode(compiledName)); String d = (displayName == null) ? null : Py.fileSystemDecode(displayName); - byte[] bytes = org.python.core.imp.compileSource(getModuleName(f), f, d, c); + byte[] bytes = org.python.core.imp.compileSource(getModuleName(f), f, d); org.python.core.imp.cacheCompiledSource(file, c, bytes); return bytes.length > 0; } -- Repository URL: https://hg.python.org/jython From jython-checkins at python.org Sun May 12 08:54:19 2019 From: jython-checkins at python.org (jeff.allen) Date: Sun, 12 May 2019 12:54:19 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_Upgrade_Apache_commons-com?= =?utf-8?q?press_to_1=2E18_=28fixes_=232762=29?= Message-ID: <20190512125419.1.086F39B1375CE72D@mg.python.org> https://hg.python.org/jython/rev/37616d952bde changeset: 8243:37616d952bde user: James Mudd date: Sat May 11 06:30:20 2019 +0100 summary: Upgrade Apache commons-compress to 1.18 (fixes #2762) files: NEWS | 1 + build.gradle | 2 +- build.xml | 4 ++-- extlibs/commons-compress-1.14.jar | Bin extlibs/commons-compress-1.18.jar | Bin 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ Development tip Bugs fixed + - [ 2762 ] Upgrade Apache commons-compress to 1.18 - [ GH-108 ] Updates to JNR/JFFI to improve ARM HF support - [ 2445 ] Eclipse's DelegatingFeatureMap has MRO conflict (and IBM's MQQueue) - [ GH-121 ] Allow struct unpack and unpack_from bytearray and buffer diff --git a/build.gradle b/build.gradle --- a/build.gradle +++ b/build.gradle @@ -147,7 +147,7 @@ implementation 'org.antlr:antlr-runtime:3.1.3' implementation 'org.antlr:stringtemplate:3.2.1' - implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.14' + implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.18' implementation group: 'org.ow2.asm', name: 'asm', version: '7.0' implementation group: 'org.ow2.asm', name: 'asm-commons', version: '7.0' diff --git a/build.xml b/build.xml --- a/build.xml +++ b/build.xml @@ -146,7 +146,7 @@ - + @@ -557,7 +557,7 @@ - + diff --git a/extlibs/commons-compress-1.14.jar b/extlibs/commons-compress-1.14.jar deleted file mode 100644 index 7490eb8996c5dd7b9be15ff01519767b10e907dc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] diff --git a/extlibs/commons-compress-1.18.jar b/extlibs/commons-compress-1.18.jar new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..e401046b5a6e5b1779fa8f50cc39dcd51a7da137 GIT binary patch [stripped] -- Repository URL: https://hg.python.org/jython From jython-checkins at python.org Sun May 12 08:54:20 2019 From: jython-checkins at python.org (jeff.allen) Date: Sun, 12 May 2019 12:54:20 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_Upgrade_BouncyCastle_JARs_?= =?utf-8?b?dG8gMS42MSAoZml4ZXMgIzI3NDIp?= Message-ID: <20190512125420.1.69797466149537BB@mg.python.org> https://hg.python.org/jython/rev/811692d463ac changeset: 8244:811692d463ac user: Jeff Allen date: Sat May 11 10:44:22 2019 +0100 summary: Upgrade BouncyCastle JARs to 1.61 (fixes #2742) Small change to _sslcerts.py addresses change in exceptions raised. files: Lib/_sslcerts.py | 23 +++++++++++++------ NEWS | 1 + build.gradle | 3 ++ build.xml | 4 +- extlibs/bcpkix-jdk15on-1.57.jar | Bin extlibs/bcpkix-jdk15on-1.61.jar | Bin extlibs/bcprov-jdk15on-1.57.jar | Bin extlibs/bcprov-jdk15on-1.61.jar | Bin 8 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Lib/_sslcerts.py b/Lib/_sslcerts.py --- a/Lib/_sslcerts.py +++ b/Lib/_sslcerts.py @@ -40,9 +40,10 @@ from org.bouncycastle.jce.provider import BouncyCastleProvider from org.bouncycastle.jce import ECNamedCurveTable from org.bouncycastle.jce.spec import ECNamedCurveSpec - from org.bouncycastle.openssl import PEMKeyPair, PEMParser, PEMEncryptedKeyPair, PEMException, \ - EncryptionException + from org.bouncycastle.openssl import PEMKeyPair, PEMParser, PEMEncryptedKeyPair, \ + PEMException, EncryptionException from org.bouncycastle.openssl.jcajce import JcaPEMKeyConverter, JcePEMDecryptorProviderBuilder + from org.bouncycastle.util.encoders import DecoderException except ImportError: # jarjar-ed version from org.python.bouncycastle.asn1.pkcs import PrivateKeyInfo @@ -51,9 +52,10 @@ from org.python.bouncycastle.jce.provider import BouncyCastleProvider from org.python.bouncycastle.jce import ECNamedCurveTable from org.python.bouncycastle.jce.spec import ECNamedCurveSpec - from org.python.bouncycastle.openssl import PEMKeyPair, PEMParser, PEMEncryptedKeyPair, PEMException, \ - EncryptionException + from org.python.bouncycastle.openssl import PEMKeyPair, PEMParser, PEMEncryptedKeyPair, \ + PEMException, EncryptionException from org.python.bouncycastle.openssl.jcajce import JcaPEMKeyConverter, JcePEMDecryptorProviderBuilder + from org.python.bouncycastle.util.encoders import DecoderException log = logging.getLogger("_socket") Security.addProvider(BouncyCastleProvider()) @@ -243,6 +245,11 @@ def _read_pem_cert_from_data(f, password, key_converter, cert_converter): + + def PEM_SSLError(err): # Shorthand + from _socket import SSLError, SSL_ERROR_SSL + return SSLError(SSL_ERROR_SSL, "PEM lib ({})".format(err)) + certs = [] private_key = None @@ -255,8 +262,9 @@ try: obj = PEMParser(br).readObject() except PEMException as err: - from _socket import SSLError, SSL_ERROR_SSL - raise SSLError(SSL_ERROR_SSL, "PEM lib ({})".format(err)) + raise PEM_SSLError(err) + except DecoderException as err: + raise PEM_SSLError(err) if obj is None: break @@ -272,8 +280,7 @@ try: key_pair = key_converter.getKeyPair(obj.decryptKeyPair(provider)) except EncryptionException as err: - from _socket import SSLError, SSL_ERROR_SSL - raise SSLError(SSL_ERROR_SSL, "PEM lib ({})".format(err)) + raise PEM_SSLError(err) private_key = key_pair.getPrivate() else: diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ Development tip Bugs fixed + - [ 2742 ] JARs for bouncycastle out of date (upgrade to 1.16) - [ 2762 ] Upgrade Apache commons-compress to 1.18 - [ GH-108 ] Updates to JNR/JFFI to improve ARM HF support - [ 2445 ] Eclipse's DelegatingFeatureMap has MRO conflict (and IBM's MQQueue) diff --git a/build.gradle b/build.gradle --- a/build.gradle +++ b/build.gradle @@ -149,6 +149,9 @@ implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.18' + implementation group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.61' + implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.61' + implementation group: 'org.ow2.asm', name: 'asm', version: '7.0' implementation group: 'org.ow2.asm', name: 'asm-commons', version: '7.0' implementation group: 'org.ow2.asm', name: 'asm-util', version: '7.0' diff --git a/build.xml b/build.xml --- a/build.xml +++ b/build.xml @@ -553,9 +553,9 @@ - + - + diff --git a/extlibs/bcpkix-jdk15on-1.57.jar b/extlibs/bcpkix-jdk15on-1.57.jar deleted file mode 100644 index 5ce7d5c5cc49c03102e3bb5248405b52431f9ebd..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] diff --git a/extlibs/bcpkix-jdk15on-1.61.jar b/extlibs/bcpkix-jdk15on-1.61.jar new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c9657cdbe99a935787404edc2a83d1e6b1732cf9 GIT binary patch [stripped] diff --git a/extlibs/bcprov-jdk15on-1.57.jar b/extlibs/bcprov-jdk15on-1.57.jar deleted file mode 100644 index 5a10986b3aac075df6f5400028cf2a6a0a8eb9fa..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] diff --git a/extlibs/bcprov-jdk15on-1.61.jar b/extlibs/bcprov-jdk15on-1.61.jar new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1fdff384b720e6ac563c80a6bdf7e8bc9f883367 GIT binary patch [stripped] -- Repository URL: https://hg.python.org/jython From jython-checkins at python.org Sun May 12 08:54:21 2019 From: jython-checkins at python.org (jeff.allen) Date: Sun, 12 May 2019 12:54:21 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_Upgrade_Google_guava_JAR_t?= =?utf-8?q?o_27=2E1_=28fixes_=232728=29?= Message-ID: <20190512125421.1.1325FDD490B90CF7@mg.python.org> https://hg.python.org/jython/rev/a1ae652df5e3 changeset: 8245:a1ae652df5e3 user: Jeff Allen date: Sat May 11 20:11:32 2019 +0100 summary: Upgrade Google guava JAR to 27.1 (fixes #2728) We add the failureaccess JAR because Google have unbundled some dependencies into it, previously found in the guava JAR. files: build.gradle | 4 +++- build.xml | 6 ++++-- extlibs/failureaccess-1.0.1.jar | Bin extlibs/guava-22.0-android.jar | Bin extlibs/guava-27.1-android.jar | Bin 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle --- a/build.gradle +++ b/build.gradle @@ -156,7 +156,9 @@ implementation group: 'org.ow2.asm', name: 'asm-commons', version: '7.0' implementation group: 'org.ow2.asm', name: 'asm-util', version: '7.0' - api group: 'com.google.guava', name: 'guava', version: '22.0-android' + api group: 'com.google.guava', name: 'guava', version: '27.1-android' + compile group: 'com.google.guava', name: 'failureaccess', version: '1.0.1' + implementation group: 'com.ibm.icu', name: 'icu4j', version: '59.1' implementation group: 'com.carrotsearch', name: 'java-sizeof', version: '0.0.5' diff --git a/build.xml b/build.xml --- a/build.xml +++ b/build.xml @@ -150,7 +150,8 @@ - + + @@ -559,7 +560,8 @@ - + + diff --git a/extlibs/failureaccess-1.0.1.jar b/extlibs/failureaccess-1.0.1.jar new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..9b56dc751c1cc7dff75ed80ccbb45f027058e8ce GIT binary patch [stripped] diff --git a/extlibs/guava-22.0-android.jar b/extlibs/guava-22.0-android.jar deleted file mode 100644 index 53a6c5cc369889ac0345959a8f8791fd0550b5b2..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] diff --git a/extlibs/guava-27.1-android.jar b/extlibs/guava-27.1-android.jar new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8648a6050037adf7b5eaccdf1c50f3f18d6f0740 GIT binary patch [stripped] -- Repository URL: https://hg.python.org/jython From jython-checkins at python.org Sun May 12 08:54:21 2019 From: jython-checkins at python.org (jeff.allen) Date: Sun, 12 May 2019 12:54:21 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_Add_skip_for_Java_7_to_fai?= =?utf-8?q?ling_test_in_test=5Fssl_=28see_bjo_=232770=29?= Message-ID: <20190512125421.1.CF93C331632498B9@mg.python.org> https://hg.python.org/jython/rev/0a29630db359 changeset: 8246:0a29630db359 user: Jeff Allen date: Sun May 12 09:22:13 2019 +0100 summary: Add skip for Java 7 to failing test in test_ssl (see bjo #2770) As observed on Java 7, test_ssl.ContextTests.test_load_cert_chain fails with "PBKDF-OpenSSL SecretKeyFactory not available". files: Lib/test/test_ssl.py | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -782,6 +782,8 @@ with self.assertRaises(TypeError): ctx.verify_flags = None + @unittest.skipIf(support.is_jython and support.get_java_version() < (8,), + "Fails on Java 7. See bjo #2770") def test_load_cert_chain(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) # Combined key and cert in a single file -- Repository URL: https://hg.python.org/jython From jython-checkins at python.org Sun May 12 17:16:37 2019 From: jython-checkins at python.org (jeff.allen) Date: Sun, 12 May 2019 21:16:37 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_Remove_now_unsupported_Ora?= =?utf-8?q?cle_JDK_7_Travis_target_=28bug_2766=29?= Message-ID: <20190512211637.1.E16B5F9323A4B1BF@mg.python.org> https://hg.python.org/jython/rev/525e6665e226 changeset: 8247:525e6665e226 user: Adam Burke date: Sun May 12 20:44:14 2019 +0100 summary: Remove now unsupported Oracle JDK 7 Travis target (bug 2766) files: .travis.yml | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,6 @@ env: matrix: - CUSTOM_JDK="default" - - CUSTOM_JDK="oraclejdk7" - CUSTOM_JDK="openjdk7" - CUSTOM_JDK="oraclejdk8" @@ -22,8 +21,6 @@ exclude: # On OSX, run with default JDK only. - os: osx - env: CUSTOM_JDK="oraclejdk7" - - os: osx env: CUSTOM_JDK="openjdk7" - os: osx env: CUSTOM_JDK="oraclejdk8" -- Repository URL: https://hg.python.org/jython From jython-checkins at python.org Fri May 17 14:00:27 2019 From: jython-checkins at python.org (jeff.allen) Date: Fri, 17 May 2019 18:00:27 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_=232768_Allow_bytearray_+_?= =?utf-8?q?and_+=3D_to_accept_buffer_protocol_objects?= Message-ID: <20190517180027.1.82378B356830BBC0@mg.python.org> https://hg.python.org/jython/rev/4c627b7d4612 changeset: 8248:4c627b7d4612 user: James Mudd date: Wed May 15 08:09:12 2019 +0100 summary: #2768 Allow bytearray + and += to accept buffer protocol objects files: Lib/test/test_bytes_jy.py | 52 ++++++++++++++++ NEWS | 1 + src/org/python/core/PyByteArray.java | 35 +++------- 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/Lib/test/test_bytes_jy.py b/Lib/test/test_bytes_jy.py --- a/Lib/test/test_bytes_jy.py +++ b/Lib/test/test_bytes_jy.py @@ -197,12 +197,64 @@ self.assertEqual(str(buf), expected) self.assertEqual(buf.__str__(), expected) + def test_add_memoryview(self): + b = buffer(b"abc") + # add memoryview + c = b + memoryview('xyz') + self.assertEqual(str(c), 'abcxyz') + + def test_add_bytearray(self): + b = buffer(b"abc") + # add bytearray + b += bytearray('xyz') + self.assertEqual(str(b), 'abcxyz') + + def test_iadd_memoryview(self): + b = buffer(b"abc") + # concatenate memoryview + b += memoryview('xyz') + self.assertEqual(str(b), 'abcxyz') + + def test_iadd_bytearray(self): + b = buffer(b"abc") + # concatenate bytearray + b += bytearray('xyz') + self.assertEqual(str(b), 'abcxyz') + + +class ByteArrayTest(unittest.TestCase): + # Tests additional to the CPython library, on bytearray + + def test_add_memoryview(self): + b = bytearray(b"abc") + # add memoryview + c = b + memoryview('xyz') + self.assertEqual(str(c), 'abcxyz') + + def test_add_buffer(self): + b = bytearray(b"abc") + # add buffer + c = b + buffer('xyz') + self.assertEqual(str(c), 'abcxyz') + + def test_iadd_memoryview(self): + b = bytearray(b"abc") + # concatenate memoryview + b += memoryview('xyz') + self.assertEqual(str(b), 'abcxyz') + + def test_iadd_buffer(self): + b = bytearray(b"abc") + # concatenate buffer + b += buffer('xyz') + self.assertEqual(str(b), 'abcxyz') def test_main(): test.test_support.run_unittest( ByteArraySubclassTest, BytesOperationsTest, BufferOperationsTest, + ByteArrayTest ) diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ Development tip Bugs fixed + - [ 2768 ] Allow bytearray + and += to accept buffer protocol objects - [ 2742 ] JARs for bouncycastle out of date (upgrade to 1.16) - [ 2762 ] Upgrade Apache commons-compress to 1.18 - [ GH-108 ] Updates to JNR/JFFI to improve ARM HF support diff --git a/src/org/python/core/PyByteArray.java b/src/org/python/core/PyByteArray.java --- a/src/org/python/core/PyByteArray.java +++ b/src/org/python/core/PyByteArray.java @@ -602,6 +602,7 @@ * @param stop one more than the position of the last element. * @param step the step size. * @param value an object possibly bearing the Buffer API + * @return true if the slice was set successfully, false otherwise * @throws PyException (SliceSizeError) if the value size is inconsistent with an extended slice */ private boolean setsliceFromBuffer(int start, int stop, int step, PyObject value) @@ -926,32 +927,13 @@ @ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.bytearray___add___doc) final synchronized PyObject bytearray___add__(PyObject o) { - PyByteArray sum = null; - - // XXX re-write using buffer API - - if (o instanceof BaseBytes) { - BaseBytes ob = (BaseBytes)o; - // Quick route: allocate the right size bytearray and copy the two parts in. - sum = new PyByteArray(size + ob.size); - System.arraycopy(storage, offset, sum.storage, sum.offset, size); - System.arraycopy(ob.storage, ob.offset, sum.storage, sum.offset + size, ob.size); + // Duplicate this buffer, but size it large enough to hold the sum + byte[] copy = new byte[size + o.__len__()]; + System.arraycopy(storage, offset, copy, 0, size); + PyByteArray sum = new PyByteArray(copy, size); - } else if (o.getType() == PyString.TYPE) { - // Support bytes type, which in in Python 2.7 is an alias of str. Remove in 3.0 - PyString os = (PyString)o; - // Allocate the right size bytearray and copy the two parts in. - sum = new PyByteArray(size + os.__len__()); - System.arraycopy(storage, offset, sum.storage, sum.offset, size); - sum.setslice(size, sum.size, 1, os); - - } else { - // Unsuitable type - // XXX note reversed order relative to __iadd__ may be wrong, matches Python 2.7 - throw ConcatenationTypeError(TYPE, o.getType()); - } - - return sum; + // Concatenate the other buffer + return sum.bytearray___iadd__(o); } /** @@ -1343,6 +1325,9 @@ } else if (oType == PyString.TYPE) { // Will fail if somehow not 8-bit clean setslice(size, size, 1, (PyString)o); + } else if (setsliceFromBuffer(size, size, 1, o)) { + // No-op setsliceFromBuffer has already done the work and if it returns true then were done. + // setsliceFromBuffer will return false for PyUnicode where the buffer cannot be obtained. } else { // Unsuitable type throw ConcatenationTypeError(oType, TYPE); -- Repository URL: https://hg.python.org/jython From jython-checkins at python.org Fri May 17 14:00:28 2019 From: jython-checkins at python.org (jeff.allen) Date: Fri, 17 May 2019 18:00:28 +0000 Subject: [Jython-checkins] =?utf-8?q?jython=3A_Upgrade_bundled_pip_and_se?= =?utf-8?q?tuptool?= Message-ID: <20190517180028.1.69C68A7A4029B0E5@mg.python.org> https://hg.python.org/jython/rev/2d62972ea150 changeset: 8249:2d62972ea150 user: James Mudd date: Wed May 15 08:21:23 2019 +0100 summary: Upgrade bundled pip and setuptool Update pip 9.0.1 to 19.1 Update setuptools 28.8.0 to 41.0.1 files: Lib/ensurepip/__init__.py | 8 ++++---- Lib/ensurepip/_bundled/pip-19.1-py2.py3-none-any.whl | Bin Lib/ensurepip/_bundled/pip-9.0.1-py2.py3-none-any.whl | Bin Lib/ensurepip/_bundled/setuptools-28.8.0-py2.py3-none-any.whl | Bin Lib/ensurepip/_bundled/setuptools-41.0.1-py2.py3-none-any.whl | Bin 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -12,9 +12,9 @@ __all__ = ["version", "bootstrap"] -_SETUPTOOLS_VERSION = "28.8.0" +_SETUPTOOLS_VERSION = "41.0.1" -_PIP_VERSION = "9.0.1" +_PIP_VERSION = "19.1" # pip currently requires ssl support, so we try to provide a nicer # error message when that is missing (http://bugs.python.org/issue19744) @@ -42,8 +42,8 @@ sys.path = additional_paths + sys.path # Install the bundled software - import pip - pip.main(args) + from pip._internal import main + main(args) def version(): diff --git a/Lib/ensurepip/_bundled/pip-19.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/pip-19.1-py2.py3-none-any.whl new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..2d3ac5d984a2b68ddcc405f104f546a4c01042f6 GIT binary patch [stripped] diff --git a/Lib/ensurepip/_bundled/pip-9.0.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/pip-9.0.1-py2.py3-none-any.whl deleted file mode 100644 index 4b8ecc69db7e37fc6dd7b6dd8f690508f42866a1..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] diff --git a/Lib/ensurepip/_bundled/setuptools-28.8.0-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-28.8.0-py2.py3-none-any.whl deleted file mode 100644 index 502e3cb418c154872ad6e677ef8b63557b38ec35..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 GIT binary patch [stripped] diff --git a/Lib/ensurepip/_bundled/setuptools-41.0.1-py2.py3-none-any.whl b/Lib/ensurepip/_bundled/setuptools-41.0.1-py2.py3-none-any.whl new file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..92836e98402648041d1bc2ae34aaf882d1ebb00b GIT binary patch [stripped] -- Repository URL: https://hg.python.org/jython