viirya 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_r326426609
 
 

 ##########
 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 just copied the change in test_worker.py and run dev/lint-python:
   
   ```
   dev/lint-python 
   starting python compilation test...
   python compilation succeeded.
   
   downloading pycodestyle from 
https://raw.githubusercontent.com/PyCQA/pycodestyle/2.4.0/pycodestyle.py...
   starting pycodestyle test...
   pycodestyle checks passed.
   
   starting flake8 test...
   flake8 checks failed:
   ./python/pyspark/sql/utils.py:31:60: F821 undefined name 'unicode'
           if sys.version_info.major < 3 and isinstance(desc, unicode):
                                                              ^
   1     F821 undefined name 'unicode'
   1
   1
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to