-
Notifications
You must be signed in to change notification settings - Fork 164
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
Improve Windows compatibility #134
Conversation
Required for windows since there the default encoding is cp1252, which causes #121
improves compatibility with windows, which can not delete open 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.
Thank you!
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.
Replace open
with codecs.open
for Python 2.7 compatibility
Did not know python 2 does not have the encoding parameter 😄 |
Well looks like I have to actually install Python 2.7 again and really test this 🙃 |
Hmm I am out of ideas (and time) how to solve this correctly. When executing the go example with Python 2.7 and
and with
The content = self.serialize()
if sys.version_info.major == 2:
content = content.decode("utf-8")
self.output_file.write(content) So which version do you prefer? Using |
I will close this because I do not intend to spend time on fixing python2 support. |
Hi,
this improves the Windows compatibility of PeachPy.
In particular, it fixes #121. The problem was under Windows the default encoding for
open()
iscp1252
instead ofutf-8
. So by always usingutf-8
for theTextWriter
it is now possible to generate Go asm under Windows.The second commit deals with the problems described in PR #43. Under Windows it is not possible to unlink an open file. With this the writers close the file before attempting to unlink it. Just like @bawr described in his last comment but apparently never did.
Closes #121, closes #43