[Jython-checkins] jython: Fixes encodings._java for incremental mode of gbk/cp936
jeff.allen
jython-checkins at python.org
Sun May 21 05:06:53 EDT 2017
https://hg.python.org/jython/rev/05fc242d9dd2
changeset: 8089:05fc242d9dd2
user: Jeff Allen <ja.py at farowl.co.uk>
date: Sat May 13 17:11:05 2017 +0100
summary:
Fixes encodings._java for incremental mode of gbk/cp936
Addresses failures evident on Windows with code page 936 when running test_io
with non-ascii paths. Position 'cookie' not handled correctly.
files:
Lib/encodings/_java.py | 8 ++++++--
src/org/python/core/PyLong.java | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Lib/encodings/_java.py b/Lib/encodings/_java.py
--- a/Lib/encodings/_java.py
+++ b/Lib/encodings/_java.py
@@ -162,12 +162,16 @@
def reset(self):
self.buffer = ""
+ self.decoder.reset()
def getstate(self):
- return self.buffer or 0
+ # No way to extract the internal state of a Java decoder.
+ return self.buffer or "", 0
def setstate(self, state):
- self.buffer = state or ""
+ self.buffer, _ = state or ("", 0)
+ # No way to restore: reset possible EOF state.
+ self.decoder.reset()
class StreamWriter(NonfinalCodec, codecs.StreamWriter):
diff --git a/src/org/python/core/PyLong.java b/src/org/python/core/PyLong.java
--- a/src/org/python/core/PyLong.java
+++ b/src/org/python/core/PyLong.java
@@ -295,6 +295,9 @@
@Override
public Object __tojava__(Class<?> c) {
try {
+ if (c == Boolean.TYPE || c == Boolean.class) {
+ return new Boolean(!getValue().equals(BigInteger.ZERO));
+ }
if (c == Byte.TYPE || c == Byte.class) {
return new Byte((byte)getLong(Byte.MIN_VALUE, Byte.MAX_VALUE));
}
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list