Uh oh!
There was an error while loading. Please reload this page.
[SPARK-21045][PYTHON] Allow non-ascii string as an exception message from python execution in Python 2 - #25847
Conversation
advancedxy
commented
Sep 19, 2019
cc @HyukjinKwon, @ueshin and @cloud-fan |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| self.assertIsInstance(t.exception, Py4JJavaError) | ||
| if sys.version_info.major < 3: | ||
| # we have to use unicode here to avoid UnicodeDecodeError | ||
| self.assertRegexpMatches(unicode(t.exception).encode("utf-8"), "exception with 中") |
There was a problem hiding this comment.
Yes, str against Py4j exception doesn't properly handle non-ascii codes (py4j/py4j#308)
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
HyukjinKwon
commented
Sep 19, 2019
ok to test |
| except Exception: | ||
| try: | ||
| exc_info = traceback.format_exc() | ||
| if sys.version_info.major < 3: |
There was a problem hiding this comment.
Likewise, let's drop this right after we drop Python 2, which I will do right after Spark 3.
SparkQA
commented
Sep 19, 2019
Test build #110987 has finished for PR 25847 at commit
|
srowen
left a comment
There was a problem hiding this comment.
Out of curiosity, when does an exception have non-ASCII chars? when it reports a table name or input value from the user app?
Uh oh!
There was an error while loading. Please reload this page.
HyukjinKwon
commented
Sep 19, 2019
@srowen, for instance, users could manually throw an exception with python native function execution like udf or rdd. |
SparkQA
commented
Sep 19, 2019
Test build #110997 has finished for PR 25847 at commit
|
SparkQA
commented
Sep 19, 2019
Test build #111002 has finished for PR 25847 at commit
|
Uh oh!
There was an error while loading. Please reload this page.
| if sys.version >= '3': | ||
| basestring = str | ||
| unicode = str |
There was a problem hiding this comment.
Then I think we don't need the comditionat 603 line
SparkQA
commented
Sep 19, 2019
Test build #111007 has finished for PR 25847 at commit
|
SparkQA
commented
Sep 19, 2019
Test build #111009 has finished for PR 25847 at commit
|
Uh oh!
There was an error while loading. Please reload this page.
viirya
left a comment
There was a problem hiding this comment.
Looks good except for a question.
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Sep 20, 2019
Test build #111077 has finished for PR 25847 at commit
|
HyukjinKwon
commented
Sep 20, 2019
Merged to master. |
What changes were proposed in this pull request?
This PR allows non-ascii string as an exception message in Python 2 by explicitly en/decoding in case of
strin Python 2.Why are the changes needed?
Previously PySpark will hang when the
UnicodeDecodeErroroccurs and the real exception cannot be passed to the JVM side.See the reproducer as below:
Does this PR introduce any user-facing change?
User may not observe hanging for the similar cases.
How was this patch tested?
Added a new test and manually checking.
This pr is based on #18324, credits should also go to @dataknocker.
To make lint-python happy for python3, it also includes a followup fix for #25814