You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by HyukjinKwon <gi...@git.apache.org> on 2017/06/13 22:45:22 UTC
[GitHub] spark pull request #17267: [SPARK-19926][PYSPARK] Make pyspark exception mor...
Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/17267#discussion_r121815790
--- Diff: python/pyspark/sql/utils.py ---
@@ -24,7 +28,11 @@ def __init__(self, desc, stackTrace):
self.stackTrace = stackTrace
def __str__(self):
- return repr(self.desc)
+ desc = self.desc
+ if isinstance(desc, unicode):
+ return str(desc.encode('utf-8'))
--- End diff --
@ueshin, you are right and I misread the codes. We need to
- unicode in Python 2 => `u.encode("utf-8")`.
- others in Python 2 => return `str(s)`.
- others in Python 3 => return `str(s)`.
Root cause for https://github.com/apache/spark/pull/17267#issuecomment-308231375 looks because `encode` on string (also same as unicode in Python 2) in Python 3 produces 8-bit bytes, `b"..."`, (also same as normal string, `"..."` and `b"..."`, where `b` is ignored, in Python 2). And `str` function works differently as below:
Python 2
```python
>>> str(b"aa")
'aa'
>>> b"aa"
'aa'
```
Python 3
```python
>>> str(b"aa")
"b'aa'"
>>> "aa"
'aa'
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org