Make build.py compatible with Python 2 and 3#2123
Merged
rachel-fenichel merged 1 commit intoRaspberryPiFoundation:developfrom Nov 17, 2018
Merged
Make build.py compatible with Python 2 and 3#2123rachel-fenichel merged 1 commit intoRaspberryPiFoundation:developfrom
rachel-fenichel merged 1 commit intoRaspberryPiFoundation:developfrom
Conversation
Following changes are made with minimal touches; - version dependent module imports - codecs.open instead of open (for encoding errors) - string_is_ascii modified for better compatibility - In create_messages.py, synonym_defs are sorted as well to increase testability, as Python 3 does not guarantee key order. Note that this will cause previously generated files to have different orders from the files generated without this patch. - small changes; paranthesis around "print"s, has_key -> in, "except x, y" -> "except x as y", sorted -> sort Other files need similar small changes but are not touched as they are not referenced from build.py Fixes RaspberryPiFoundation#2112
rachel-fenichel
approved these changes
Nov 17, 2018
Collaborator
|
Thank you! And feel free to make followup PRs to change any other python files that we have that only run in Python 2. |
Contributor
Author
|
Thank you too, I will take a look at them as well |
This was referenced Dec 14, 2018
Merged
tansly
added a commit
to tansly/scratch-blocks
that referenced
this pull request
Jul 12, 2019
delasare
pushed a commit
to scratchfoundation/scratch-blocks
that referenced
this pull request
Oct 25, 2023
Port of RaspberryPiFoundation/blockly#2123 (by @gomercin) Fix issues related to Python 3 compatibility Port of RaspberryPiFoundation/blockly#2125 (by @gomercin) Fix compatibility problems with Python 3's reduce(), filter() et al. Fix Python 3 compatibility problems related to str encodings Remove obsolete UnicodeEncodeError handling
delasare
pushed a commit
to scratchfoundation/scratch-blocks
that referenced
this pull request
Oct 25, 2023
Port of RaspberryPiFoundation/blockly#2123 (by @gomercin) Fix issues related to Python 3 compatibility Port of RaspberryPiFoundation/blockly#2125 (by @gomercin) Fix compatibility problems with Python 3's reduce(), filter() et al. Fix Python 3 compatibility problems related to str encodings Remove obsolete UnicodeEncodeError handling
DBDev-IT
pushed a commit
to DashBlocks/scratch-blocks
that referenced
this pull request
Sep 2, 2025
Port of RaspberryPiFoundation/blockly#2123 (by @gomercin) Fix issues related to Python 3 compatibility Port of RaspberryPiFoundation/blockly#2125 (by @gomercin) Fix compatibility problems with Python 3's reduce(), filter() et al. Fix Python 3 compatibility problems related to str encodings Remove obsolete UnicodeEncodeError handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The basics
The details
Following changes are made with minimal touches in the rest;
testability, as Python 3 does not guarantee key order.
Note that this will cause previously generated files to have different
orders from the files generated without this patch.
"except x, y" -> "except x as y", sorted -> sort
Resolves
#2112
Proposed Changes
Reason for Changes
Enabling the upgrade to Python3.x
Test Coverage
Tested on:
Tested on Windows by comparing generated files using:
There is a change of order due to sorting synonym_defs but there seems to be no easy
solution to keep the order from the original files.
Additional Information
Other files need similar small changes but are not touched as they are not
referenced from build.py