Skip to content

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

Merged
merged 7 commits into from
Jun 5, 2018

Conversation

cmonr
Copy link
Contributor

@cmonr cmonr commented Jun 3, 2018

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

[x] Fix
[ ] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

theotherjimmy
theotherjimmy previously approved these changes Jun 4, 2018
@cmonr
Copy link
Contributor Author

cmonr commented Jun 4, 2018

/morph build

cmonr and others added 6 commits June 4, 2018 09:21
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.
@cmonr
Copy link
Contributor Author

cmonr commented Jun 4, 2018

/morph build

theotherjimmy
theotherjimmy previously approved these changes Jun 4, 2018
@@ -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("."))
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

@cmonr cmonr Jun 4, 2018

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.

Copy link
Contributor

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?

Copy link
Contributor Author

@cmonr cmonr Jun 4, 2018

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.

Copy link
Contributor

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.

@mbed-ci
Copy link

mbed-ci commented Jun 4, 2018

Build : SUCCESS

Build number : 2232
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7092/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

bridadan
bridadan previously approved these changes Jun 4, 2018
@cmonr
Copy link
Contributor Author

cmonr commented Jun 4, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Jun 4, 2018

@cmonr
Copy link
Contributor Author

cmonr commented Jun 4, 2018

^^^ Ignore that. It's from the first build which was stopped due to the update.

@mbed-ci
Copy link

mbed-ci commented Jun 4, 2018

Build : SUCCESS

Build number : 2236
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7092/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jun 4, 2018

@cmonr cmonr force-pushed the py3-in-windows branch 2 times, most recently from 6b38f33 to f689ace Compare June 4, 2018 22:36
@cmonr
Copy link
Contributor Author

cmonr commented Jun 4, 2018

Grumblegrumblegrumble......

Accidentally pushed a commit to this branch. Restarting CI after restoring the branch to it's approved commit history.

/morph build

@cmonr
Copy link
Contributor Author

cmonr commented Jun 4, 2018

@bridadan @theotherjimmy Can I get one of y'all to approve?

@cmonr cmonr added the risk: G label Jun 4, 2018
@mbed-ci
Copy link

mbed-ci commented Jun 4, 2018

Build : SUCCESS

Build number : 2238
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7092/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Jun 5, 2018

@mbed-ci
Copy link

mbed-ci commented Jun 5, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants