Skip to content

Conversation

ken2812221
Copy link
Contributor

base58.py can executed by python3

@Empact
Copy link
Contributor

Empact commented Apr 13, 2018

Good candidate for a lint?

@maflcko
Copy link
Member

maflcko commented Apr 13, 2018

To the best of my knowledge, the script is outdated and won't produce test vectors in the current format. Since you are touching this file, might as well fix this in one go?

@maflcko
Copy link
Member

maflcko commented Apr 13, 2018

Also the readme should be updated to reflect the new names, i.e. "src/test/data/key_io_valid.json" and "src/test/data/key_io_invalid.json"

@practicalswift
Copy link
Contributor

@Empact The linter you're thinking about would check that all *.py files start with #!/usr/bin/env python3? Anything more?

@ken2812221
Copy link
Contributor Author

@MarcoFalke since we don't generate testdata dynamically, should we delete this testgen directory?

@ken2812221
Copy link
Contributor Author

I don't know how to deal with contrib/devtools/test-security-check.py, it seems outdated, and not python3 code

@jnewbery
Copy link
Contributor

Concept ACK adding the linter, however it should only return an error if there's a python or python2 shebang. It's fine to have no shebang if the module is not intended to be run as a standalone executable.

I don't think we should add shebangs to modules which aren't intended to be run as standalone executables.

test-security-check.py was overlooked in #11881. You can convert it to Python3 with the following commit: jnewbery@35cb5da

@practicalswift
Copy link
Contributor

practicalswift commented Apr 13, 2018

@ken2812221 What about this linter?

#!/bin/bash

EXIT_CODE=0
for PYTHON_FILE in $(git ls-files -- "*.py"); do
    if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" &&
          $(head -n 1 "${PYTHON_FILE}") != "#!/usr/bin/env python3" ]]; then
        echo "Missing shebang \"#!/usr/bin/env python3\" in ${PYTHON_FILE}"
        EXIT_CODE=1
    fi
done
exit ${EXIT_CODE}

@ken2812221
Copy link
Contributor Author

@practicalswift Seems your lint is flexible

@ken2812221
Copy link
Contributor Author

@jnewbery thanks

@practicalswift
Copy link
Contributor

utACK 294e59675bf326eb0e81a6685410f25df5619be4

@@ -1,3 +1,4 @@
#!/usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't think base58.py requires a shebang. It's not executable:

→ ls -l contrib/testgen/base58.py
-rw-rw-r-- 1 ubuntu ubuntu 3092 Apr 13 14:37 contrib/testgen/base58.py

for PYTHON_FILE in $(git ls-files -- "*.py"); do
if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" &&
$(head -n 1 "${PYTHON_FILE}") != "#!/usr/bin/env python3" ]]; then
echo "Missing shebang \"#!/usr/bin/env python3\" in ${PYTHON_FILE}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment could be clearer. Something like "Shebang must use python3 (not python or python2)"

@ken2812221 ken2812221 changed the title trivial: Use python3 explicitly Add python3 script shebang lint Apr 13, 2018
@practicalswift
Copy link
Contributor

practicalswift commented Apr 14, 2018

utACK 2bff472

@Empact
Copy link
Contributor

Empact commented Apr 15, 2018

utACK 2bff472

@jnewbery
Copy link
Contributor

utACK 2bff472

@maflcko maflcko merged commit 2bff472 into bitcoin:master Apr 16, 2018
maflcko pushed a commit that referenced this pull request Apr 16, 2018
2bff472 [contrib] convert test-security-check to python3 (John Newbery)
958bf40 add lint tool to check python3 shebang (practicalswift)

Pull request description:

  base58.py can executed by python3

Tree-SHA512: 30511204feefd4ccd5b4bf698fb88e516633e692dc95d31fe957b1c0c4879de25906355b28a5a0522171887315c8464a611e601ff00540db172d5bd463ee13d9
@ken2812221 ken2812221 deleted the explicit_python3 branch April 17, 2018 09:29
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 17, 2020
2bff472 [contrib] convert test-security-check to python3 (John Newbery)
958bf40 add lint tool to check python3 shebang (practicalswift)

Pull request description:

  base58.py can executed by python3

Tree-SHA512: 30511204feefd4ccd5b4bf698fb88e516633e692dc95d31fe957b1c0c4879de25906355b28a5a0522171887315c8464a611e601ff00540db172d5bd463ee13d9
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 27, 2020
2bff472 [contrib] convert test-security-check to python3 (John Newbery)
958bf40 add lint tool to check python3 shebang (practicalswift)

Pull request description:

  base58.py can executed by python3

Tree-SHA512: 30511204feefd4ccd5b4bf698fb88e516633e692dc95d31fe957b1c0c4879de25906355b28a5a0522171887315c8464a611e601ff00540db172d5bd463ee13d9
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants