-
Notifications
You must be signed in to change notification settings - Fork 13.3k
python3 compat #25749
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
python3 compat #25749
Conversation
Also rewrite most of the string formatting to be a bit more idiomatic
(rust_highfive has picked a reviewer for you, use r? to override) |
if sys.version_info.major == 2: | ||
_open = lambda f: open(f, 'r') | ||
elif sys.version_info.major == 3: | ||
_open = lambda f: open(f, 'r', encoding="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.
How come this was necessary? Did this run into problems for some files?
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 exploded on some of the innards of Rc
, although I didn't dig into it super far.
I did a little reading, and the gist was that evidently python2 would lossily coerce invalid ascii characters, whereas python3 treats them as a hard error. I can dig up what I was reading if you'd like.
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.
Is there a way to open a file as UTF-8 in python2? All our source files should be valid UTF-8 I believe at least
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.
Added a commit that uses the codecs
module to do it.
Thanks @richo! Unfortunately I don't think we can move completely to accepting python 3 until LLVM's build system supports it, but this certainly can't hurt! |
Yup. It's not even clear to me that we'd want to, but a few projects I work on have been stung repeatedly by Ubuntu's default python switching, and I was waiting on a build so I figured I'd at least get |
this asserts that source is valid utf8 on both python3 and python2
Actually that approach also works on python3. Removed the janky branch. |
⌛ Testing commit 96d7400 with merge 55f48b1... |
💔 Test failed - auto-linux-32-nopt-t |
@bors: retry On Tue, May 26, 2015 at 9:49 PM, bors [email protected] wrote:
|
⌛ Testing commit 96d7400 with merge 5a2c766... |
This is enough to make `make tidy` work if you're using python3 There's definitely more stuff to do, but PR'ing now to avoid bitrot
This is enough to make
make tidy
work if you're using python3There's definitely more stuff to do, but PR'ing now to avoid bitrot