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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tools/build_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,7 @@ def merge_region_list(region_list, destination, notify, padding=b'\xFF'):
makedirs(dirname(destination))
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("."))

def scan_resources(src_paths, toolchain, dependencies_paths=None,
inc_dirs=None, base_path=None, collect_ignores=False):
Expand Down
2 changes: 1 addition & 1 deletion tools/memap.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def parse_mapfile(self, mapfile):

class _GccParser(_Parser):
RE_OBJECT_FILE = re.compile(r'^(.+\/.+\.o)$')
RE_LIBRARY_OBJECT = re.compile(r'^.+' + sep + r'lib((.+\.a)\((.+\.o)\))$')
RE_LIBRARY_OBJECT = re.compile(r'^.+' + r''.format(sep) + r'lib((.+\.a)\((.+\.o)\))$')
RE_STD_SECTION = re.compile(r'^\s+.*0x(\w{8,16})\s+0x(\w+)\s(.+)$')
RE_FILL_SECTION = re.compile(r'^\s*\*fill\*\s+0x(\w{8,16})\s+0x(\w+).*$')

Expand Down
1 change: 1 addition & 0 deletions tools/notifier/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.


import re
import sys
Expand Down
9 changes: 4 additions & 5 deletions tools/test/examples/examples_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import sys
import subprocess
from shutil import rmtree
from sets import Set

ROOT = abspath(dirname(dirname(dirname(dirname(__file__)))))
sys.path.insert(0, ROOT)
Expand Down Expand Up @@ -254,11 +253,11 @@ def export_repos(config, ides, targets, examples):
ides - List of IDES to export to
"""
results = {}
valid_examples = Set(examples)
valid_examples = set(examples)
print("\nExporting example repos....\n")
for example in config['examples']:
example_names = [basename(x['repo']) for x in get_repo_list(example)]
common_examples = valid_examples.intersection(Set(example_names))
common_examples = valid_examples.intersection(set(example_names))
if not common_examples:
continue
export_failures = []
Expand Down Expand Up @@ -337,11 +336,11 @@ def compile_repos(config, toolchains, targets, profile, examples):

"""
results = {}
valid_examples = Set(examples)
valid_examples = set(examples)
print("\nCompiling example repos....\n")
for example in config['examples']:
example_names = [basename(x['repo']) for x in get_repo_list(example)]
common_examples = valid_examples.intersection(Set(example_names))
common_examples = valid_examples.intersection(set(example_names))
if not common_examples:
continue
failures = []
Expand Down
2 changes: 0 additions & 2 deletions tools/test/memap/parse_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ def test_parse_gcc():
parsed_data_os_agnostic[k.replace('/', sep)] = PARSED_GCC_DATA[k]

assert memap.modules == parsed_data_os_agnostic
memap.parse(join(dirname(__file__), "gcc.map"), "GCC_CR")
assert memap.modules == parsed_data_os_agnostic


def test_add_empty_module():
Expand Down
4 changes: 1 addition & 3 deletions tools/toolchains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
CPU_COUNT_MIN = 1
CPU_COEF = 1

class LazyDict(dict):
class LazyDict(object):
def __init__(self):
self.eager = {}
self.lazy = {}
Expand Down Expand Up @@ -252,8 +252,6 @@ def _collect_duplicates(self, dupe_dict, dupe_headers):
headername = basename(filename)
dupe_headers.setdefault(headername, set())
dupe_headers[headername] |= set([headername])
for res in self.features.values():
res._collect_duplicates(dupe_dict, dupe_headers)
return dupe_dict, dupe_headers

def detect_duplicates(self, toolchain):
Expand Down