Join GitHub today
IllegalArgumentException: Cannot create PyString with non-byte value #90
2017-09-19 13:02:58 INFO jython script : OracleExtract:-2 - Found 43 record for partition info
Caused by: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
@Stewori It's clear what's happening I think without a sample, although it would be nice to confirm what kind of str is being written. The csv module is supposed to take bytes (that may be UTF-8) but we are handling these as char, with the failure we've got used to since we got strict. Unfortunately, the regression tests don't test with UTF-8.
@wzfxue is this happening with text you have encoded to UTF-8?
Almost certainly we should use a ByteBuffer where we presently use a StringBuilder since the file is in binary mode and the user should expect to encode the text before calling csv.writer.writerow(). Use of PyStringOrUnicode here would just dig the hole deeper.
When Jython 3 comes along we reverse all that, accepting unicode, using char internally and writing a text mode file. 2.7.2?
I use the code as follows：https://github.com/linkedin/WhereHows/blob/master/wherehows-etl/src/main/java/metadata/etl/JythonEtlJob.java
I try to set the encoding (utf-8),the problem still exists：
the problem still exists.
referenced this issue
Oct 21, 2017
@wzfxue : Having looked into this, I'm not so sure it is a Jython bug after all. The
I can create a test that does this and it fails with the same kind of message. The way this module is implemented in Jython results in UTF-16 data buffered up as if it were bytes, and then when we try to write it as bytes, we get this error. If you run this in CPython, you get a message like:
The "fixed" behaviour for Jython would be to produce that kind of message. This is not much comfort for you as your application would continue to throw at the same point.
Assuming you are calling
In response to your issue linkedin/WhereHows#754, that project could perhaps create a version of
Let us know if that helps. If I've guessed wrong, could you show us more of your code, or create an isolated demonstration of the problem, separate from the WhereHows library.