advancedxy commented on a change in pull request #25847: [SPARK-21045][PYTHON] 
Allow non-ascii string as an exception message from python execution in Python 2
URL: https://github.com/apache/spark/pull/25847#discussion_r326425005
 
 

 ##########
 File path: python/pyspark/tests/test_worker.py
 ##########
 @@ -150,6 +151,20 @@ def test_with_different_versions_of_python(self):
         finally:
             self.sc.pythonVer = version
 
+    def test_python_exception_non_hanging(self):
+        # SPARK-21045: exceptions with no ascii encoding shall not hanging 
PySpark.
+        try:
+            def f():
+                raise Exception("exception with 中 and \xd6\xd0")
+
+            self.sc.parallelize([1]).map(lambda x: f()).count()
+        except Py4JJavaError as e:
+            if sys.version_info.major < 3:
+                # we have to use unicode here to avoid UnicodeDecodeError
+                self.assertRegexpMatches(unicode(e).encode("utf-8"), 
"exception with 中")
 
 Review comment:
   I ran dev/lint-python on my local machine, check passes, flake8 doesn't 
complain this one.  Not sure how it works. 
   
   Let me push a new one for add `unicode = str` in test_worker.py?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to