cext: fix potential memory leaks of list items appended with PyList_Append
Also reduce the duplication in the tricky code that uses PyList_Append by
extracting it into a function `pylist_append_owned`.
#!/usr/bin/env python3
#
# A tool to help producing large and poorly compressible files
#
# Usage:
# $TESTDIR/seq.py 1000 | $TESTDIR/sha256line.py > my-file.txt
import hashlib
import sys
for line in sys.stdin:
print(hashlib.sha256(line.encode('utf8')).hexdigest())