fix: Python 3 compatibility and C++ code quality improvements#2643
Merged
bigfooted merged 2 commits intosu2code:developfrom Dec 17, 2025
Merged
Conversation
…rovements Python fixes: - Replace deprecated .iteritems() with .items() in bunch.py, ordered_bunch.py - Replace deprecated .itervalues() with .values() in ordered_dict.py - Replace keys().sort() with sorted(keys()) in bunch.py as dict.keys() returns a view object in Python 3 - Replace unicode type with str in data.py (unicode was merged into str in Python 3) - Replace 'raise StopIteration' with 'return' in switch.py (PEP 479: raising StopIteration inside a generator is deprecated in Python 3.7+ and causes RuntimeError) C++ fixes: - Remove redundant '== true' boolean comparison in CSpeciesFlameletSolver.cpp (line 443) These changes ensure the SU2 Python utilities work correctly with Python 3.x and improve C++ code quality. Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
pcarruscag
approved these changes
Dec 12, 2025
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.
Proposed Changes
This PR fixes Python 2 to Python 3 compatibility issues and improves C++ code quality.
Files Modified:
SU2/util/bunch.py.iteritems()→.items(),keys().sort()→sorted(keys())SU2/util/ordered_bunch.py.iteritems()→.items()SU2/util/ordered_dict.py.itervalues()→.values()SU2/io/data.pyunicode→strSU2/util/switch.pyraise StopIteration→return(PEP 479)src/solvers/CSpeciesFlameletSolver.cpp== trueIssues Fixed
Python 3 Compatibility:
.iteritems()removed in Py3AttributeError.items().itervalues()removed in Py3AttributeError.values()dict.keys().sort()failsAttributeErrorsorted()unicodetype removedNameErrorstrraise StopIterationin generatorsRuntimeError(PEP 479)returnC++ Code Quality:
== truecomparisonRelated Work
This PR extends the Python 3 compatibility work started in PR #2640, addressing remaining issues in utility modules.
PR Checklist