-
Notifications
You must be signed in to change notification settings - Fork 3k
Additional fixes for running Python 3 in Windows #7092
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
Conversation
/morph build |
Had to remove part of test that was incompatible with Py3 on Windows.
… iteration over values. Py3 no longer supports dictionaries that self-modify their item lists during iteration.
Py3 open(...) returns a BufferedReader instead of a file.
/morph build |
tools/build_api.py
Outdated
@@ -459,7 +459,7 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'): | |||
notify.info("Space used after regions merged: 0x%x" % | |||
(merged.maxaddr() - merged.minaddr() + 1)) | |||
with open(destination, "wb+") as output: | |||
merged.tofile(output, format=format.strip(".")) | |||
merged.tofile(destination, format=format.strip(".")) |
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 block doesn't make much sense. Did you mean to remove the open()
call above? Currently, output
isn't being used.
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.
Haha, you're right. I'm thinking that thewith open...
could even be removed completely.
The tofile
api happens to support passing the file path. The difficulty with this port was that In Py3, open
returns a BufferedStream instead of a file, and I didn't have much luck finding something that worked in both versions.
API Ref: https://media.readthedocs.org/pdf/python-intelhex/latest/python-intelhex.pdf
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.
Ok no worries, sounds like removing the with open...
statement is what you're after then.
@@ -14,6 +14,7 @@ | |||
# limitations under the License. | |||
|
|||
from __future__ import print_function, division, absolute_import | |||
from past.builtins import basestring |
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.
Doesn't look like this import is used anywhere
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's not intuitive at all, but including basestring in this way affects how string concatenation occurs in line 77. Without it, Py3 defaults to treating strings as bytes, which breaks the concatenation.
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.
Ah I see, thanks for clarifying. I just checked the cheatsheet and I see what you're talking about: http://python-future.org/compatible_idioms.html#basestring
If you end up pushing more commits to this, do you think you could add a comment pointing that reference so others know why its there?
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.
Ah, yeah. Will do. There's been so much back and forth between testing across two separate OSs that I let commit quality suffer.
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.
Oh no its no big deal, its honestly fine how it is. Just trying to make it easier for future maintenance.
Build : SUCCESSBuild number : 2232 Triggering tests/morph test |
/morph build |
Test : FAILUREBuild number : 2024 |
^^^ Ignore that. It's from the first build which was stopped due to the update. |
Build : SUCCESSBuild number : 2236 Triggering tests/morph test |
Test : SUCCESSBuild number : 2025 |
6b38f33
to
f689ace
Compare
Grumblegrumblegrumble...... Accidentally pushed a commit to this branch. Restarting CI after restoring the branch to it's approved commit history. /morph build |
@bridadan @theotherjimmy Can I get one of y'all to approve? |
Build : SUCCESSBuild number : 2238 Triggering tests/morph test |
Test : SUCCESSBuild number : 2027 |
Exporter Build : SUCCESSBuild number : 1862 |
Description
An additional set of small fixes for running Mbed OS and Mbed CLI functions within Windows.
Once #7078 is merged, this will be rebased to remove duplicate commits.
Pull request type