Skip to content

Conversation

@OPpuolitaival
Copy link
Contributor

Description

Fix USB related host_test python scripts to work on python 3 also

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@jussisip could you test this?

Release Notes

@jamesbeyond
Copy link
Contributor

@fkjagodzinski could you have a look?

Copy link
Member

@fkjagodzinski fkjagodzinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OPpuolitaival did you have any problems with these lines? I run usb tests on latest master d0b5ba6 with Python3 and these did not cause problems. I had to update other lines though -- fkjagodzinski@96581ff. Feel free to cherry-pick this patch here.

try:
ret = get_descriptor(dev, (DESC_TYPE_DEVICE << 8) | (0 << 0), 0, DEVICE_DESC_SIZE)
dev_desc = dict(zip(device_descriptor_keys, device_descriptor_parser.unpack(ret)))
dev_desc = dict(list(zip(device_descriptor_keys, device_descriptor_parser.unpack(ret))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to make a list here. dict() can handle generators just fine.

mbed_serial.reset_output_buffer()
mbed_serial.dtr = True
for byteval in itertools.chain(reversed(range(0x100)), range(0x100)):
for byteval in itertools.chain(reversed(list(range(0x100))), list(range(0x100))):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add list() here.

@kotkcy
Copy link
Contributor

kotkcy commented Sep 20, 2019

I tried to verify these changes on MAC - usb tests still FAILED...

@kotkcy
Copy link
Contributor

kotkcy commented Sep 20, 2019

On Windows I saw the same errors...

@OPpuolitaival
Copy link
Contributor Author

I did use 2to3 for these changes.. that normally find out problems quite well

@fkjagodzinski
Copy link
Member

I did use 2to3 for these changes.. that normally find out problems quite well

Yeah, the changes seem reasonable in general as they cover tha API changes (generators returned instead of objects). In this particular case these changes are unnecessary.

@OPpuolitaival
Copy link
Contributor Author

Cannot test with Mac. I ask my colleague to test this on Windows

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants