HyukjinKwon 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_r326441374
 
 

 ##########
 File path: python/pyspark/worker.py
 ##########
 @@ -598,8 +599,18 @@ def process():
             process()
     except Exception:
         try:
+            exc_info = traceback.format_exc()
+            if sys.version_info.major < 3:
+                if isinstance(exc_info, unicode):
+                    exc_info = exc_info.encode("utf-8")
+                else:
 
 Review comment:
   I mean:
   
   ```python
   if isinstance(exc_info, bytes):
       exc_info = exc_info.decode("utf-8", "replace").encode("utf-8")
   else:
       exc_info = exc_info.encode("utf-8")
   ```
   
   `str` in Python 2 is same as `bytes`:
   
   ```python
   >>> str == bytes
   True
   
   >>> isinstance("a", bytes)
   True
   ```

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