diff options
author | Steve Dower <steve.dower@microsoft.com> | 2017-02-04 14:55:16 -0800 |
---|---|---|
committer | Steve Dower <steve.dower@microsoft.com> | 2017-02-04 14:55:16 -0800 |
commit | b53654b6dbfce8318a7d4d1cdaddca7a7fec194b (patch) | |
tree | 204df61b2fb23424603db767732db35a687529c6 /Modules/_blake2/blake2b2s.py | |
parent | e1ac7d87afad9c07ec25e5705bb135b71347b581 (diff) | |
parent | 2296b978597ce62ec2185b78a43811610af2c0ea (diff) | |
download | cpython-b53654b6dbfce8318a7d4d1cdaddca7a7fec194b.tar.gz |
Issue #29416: Prevent infinite loop in pathlib.Path.mkdir
Diffstat (limited to 'Modules/_blake2/blake2b2s.py')
-rwxr-xr-x | Modules/_blake2/blake2b2s.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Modules/_blake2/blake2b2s.py b/Modules/_blake2/blake2b2s.py new file mode 100755 index 0000000000..01cf26521b --- /dev/null +++ b/Modules/_blake2/blake2b2s.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 + +import os +import re + +HERE = os.path.dirname(os.path.abspath(__file__)) +BLAKE2 = os.path.join(HERE, 'impl') + +PUBLIC_SEARCH = re.compile(r'\ int (blake2[bs]p?[a-z_]*)\(') + + +def getfiles(): + for name in os.listdir(BLAKE2): + name = os.path.join(BLAKE2, name) + if os.path.isfile(name): + yield name + + +def find_public(): + public_funcs = set() + for name in getfiles(): + with open(name) as f: + for line in f: + # find public functions + mo = PUBLIC_SEARCH.search(line) + if mo: + public_funcs.add(mo.group(1)) + + for f in sorted(public_funcs): + print('#define {0:<18} PyBlake2_{0}'.format(f)) + + return public_funcs + + +def main(): + lines = [] + with open(os.path.join(HERE, 'blake2b_impl.c')) as f: + for line in f: + line = line.replace('blake2b', 'blake2s') + line = line.replace('BLAKE2b', 'BLAKE2s') + line = line.replace('BLAKE2B', 'BLAKE2S') + lines.append(line) + with open(os.path.join(HERE, 'blake2s_impl.c'), 'w') as f: + f.write(''.join(lines)) + # find_public() + + +if __name__ == '__main__': + main() |