Page MenuHomePhabricator

scripted-diff: test: Use py3.5 bytes::hex() method
ClosedPublic

Authored by Fabien on Mon, Nov 4, 11:29.

Details

Summary

Done by hand due to differences with our codebase.

Partial backport of core PR14954 (commit fa3bf21):
https://github.com/bitcoin/bitcoin/pull/14954/commits/fa6bf21f5ef8b27e8525cabba9738f8e1f246bf5

Original scripted-diff for reference:

-BEGIN VERIFY SCRIPT-
sed -i -e "s/def bytes_to_hex_str/def b_2_x/g" $(git grep -l
bytes_to_hex_str)

export RE_B_0="[^()]*"                          # match no bracket
export RE_B_1="${RE_B_0}\(${RE_B_0}\)${RE_B_0}" # match exactly one ()
export RE_B_2="${RE_B_0}\(${RE_B_1}\)${RE_B_0}" # match wrapped (())

export RE_M="(b2x|bytes_to_hex_str)\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\)"

sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g"      $(git grep -l -E
'(b2x|bytes_to_hex_str)')

sed -i --regexp-extended -e "/  +bytes_to_hex_str( as b2x)?,/d"    $(git
grep -l bytes_to_hex_str)
sed -i --regexp-extended -e "s/ +bytes_to_hex_str( as b2x)?,//g"   $(git
grep -l bytes_to_hex_str)
sed -i --regexp-extended -e "s/, bytes_to_hex_str( as b2x)?//g"    $(git
grep -l bytes_to_hex_str)

export RE_M="(binascii\.)?hexlify\(((${RE_B_0}|${RE_B_1}|${RE_B_2})*)\).decode\(${RE_B_0}\)"

sed -i --regexp-extended -e "s/${RE_M}/\2.hex()/g" $(git grep -l hexlify
-- ':(exclude)share')

sed -i --regexp-extended -e  "/from binascii import hexlify$/d" $(git
grep -l hexlify -- ':(exclude)share')
sed -i --regexp-extended -e "s/(from binascii import) .*hexlify/\1
unhexlify/g" $(git grep -l hexlify -- ':(exclude)share')

sed -i -e 's/ignore-names "/ignore-names "b_2_x,/g'
./test/lint/lint-python-dead-code.sh
-END VERIFY SCRIPT-
Test Plan
./test/functional/test_runner.py --extended

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Fabien created this revision.Mon, Nov 4, 11:29
Herald added a reviewer: Restricted Project. · View Herald TranscriptMon, Nov 4, 11:29
jasonbcox accepted this revision.Mon, Nov 4, 17:47
This revision is now accepted and ready to land.Mon, Nov 4, 17:47
This revision was automatically updated to reflect the committed changes.