Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix issue with unicode arguments to __main__
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
- Loading branch information
a73ed63
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 creates a problem with Python 3:
'a' == b'a'
under Python 2, while'a' != b'a'
under Python 3. Now under Python 3,repr(arg[:7])
is'--conf='
for me, whence the two strings are never equal and I getERROR: Nikola: Unknown command --conf=xxx
.a73ed63
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.
(Replacing
b'--conf='
with'--conf='
helps, or replacingarg[:7]
byarg[:7].encode('utf-8')
.)a73ed63
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.
would you mind figuring a solution that works with both Pythons and making a PR?
a73ed63
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.
What was the motivation to change
'--conf='
tob'--conf='
in the first place? I think before this change it was working fine.a73ed63
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.
it wasn’t, we were getting “cannot coerce to Unicode” errors if there were Unicode arguments (which can happen with
nikola new_post -t
, for instance)a73ed63
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.
Then adding
.encode('utf-8')
toarg
is probably the best fix. From what I understand, this works fine under Python 2 and Python 3, and shouldn't exhibit the "cannot coerce to Unicode" errors. What do you think?This also affects some more settings parsing in main.py, I think.
a73ed63
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.
I don’t have time to look into this further, I’ll try to come up with a solution tomorrow. And yes, we would need to fix every argument check in the file.
a73ed63
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.
Did you had a chance to look at it?
a73ed63
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.
didn’t have time; see #1738