generator: Remove dead code sha256_test.py#1081
Merged
tridge merged 1 commit intoArduPilot:masterfrom Jul 11, 2025
Merged
Conversation
3845304 to
8eb57d7
Compare
Fixes: ArduPilot#1062 * ArduPilot#1062 This file defines no classes or functions. It can only be run on the command line, but it will always fail on Python 3. Given that it is only a command-line tool and has not been used on Python 3, let's remove it as dead code. --- A TypeError will be raised if this script is run on Python 3 in its current form: ```python >>> import hashlib >>> hashlib.new('sha256').update(b'bytes') # OK >>> hashlib.new('sha256').update('str'). # Fails! Traceback (most recent call last): File "<python-input-1>", line 1, in <module> hashlib.new('sha256').update('str') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^ TypeError: Strings must be encoded before hashing >>> hashlib.new('sha256').update('str'.encode('utf-8')) # OK ``` The problem is that `sys.argv` is a list of `str`, but `hashlib.new('sha256').update()` requires `bytes`, not `str` in Python 3. This is not a problem in Py2 (`bytes == str` is True), but is a problem in Py3 (`bytes == str` is False).
8eb57d7 to
9a3abbc
Compare
This was referenced Jul 6, 2025
tridge
approved these changes
Jul 11, 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.
Fixes: #1062
This file defines no classes or functions. It can only be run on the command line, but it will always fail on Python 3.
Given that it is only a command-line tool and has not been used on Python 3, let's remove it as dead code.
A TypeError will be raised if this script is run on Python 3 in its current form:
The problem is that
sys.argvis a list ofstr, buthashlib.new('sha256').update()requiresbytes, notstrin Python 3.This is not a problem in Py2 (
bytes == stris True), but is a problem in Py3 (bytes == stris False).