-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AIRFLOW-3439] Decode logs with 'utf-8' #4474
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code change is not changing anything actually. Please refer to my line comment.
Please correct me if I'm wrong.
@@ -129,7 +129,7 @@ def gcs_read(self, remote_log_location): | |||
:type remote_log_location: str (path) | |||
""" | |||
bkt, blob = self.parse_gcs_url(remote_log_location) | |||
return self.hook.download(bkt, blob).decode() | |||
return self.hook.download(bkt, blob).decode('utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default encoding of .decode()
is already "utf-8". Please refer to https://docs.python.org/3/library/stdtypes.html#bytes.decode
So .decode('utf-8')
is no difference from .decode()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So .decode('utf-8') is no difference from .decode().
I have a different opinion. Airflow support Python 2.7, 3.6=> (Source)
In documentation for Python 2.7, you can read a fragment:
Python’s default encoding is the ‘ascii’ encoding.
(Source)
It is also worth quoting another fragment
str.decode([encoding[, errors]])
Decodes the string using the codec registered for encoding. encoding defaults to the default string encoding.
(Source)
Taking into account the quotations above, the change proposed here changes the behavior of the program.
I hope that the explanations are sufficient and clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, I get encoding error with python 2.7, forgot to mention that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm |
(cherry picked from commit 011c85a)
(cherry picked from commit 011c85a)
(cherry picked from commit 011c85a)
This actually introduces a bug when using the
|
Make sure you have checked all steps below.
Jira
Description
Tests
Commits
Documentation
Code Quality
flake8