Tags: pixelb/ps_mem
Tags
support non latin1 command names in python3
Replace md5 checksums with build-in hash()
which avoids the encoding issue entirely,
and whose collision rate should be fine
for this application.
Test Setup:
$ cp /bin/sleep slé😃p
$ ./slé😃p inf &
Before:
# python2 ./ps_mem.py | grep --only sl.*$
slé😃p
# python3 ./ps_mem.py | grep --only sl.*$
digester.update(bytes(line,'latin1'))
UnicodeEncodeError: 'latin-1' codec can't encode character '\U0001f603'
# LC_ALL=C python2 ./ps_mem.py | grep --only sl.*$
slé😃p
# LC_ALL=C python3 ./ps_mem.py | grep --only sl.*$
slp
After:
# python2 ./ps_mem.py | grep --only sl.*$
slé😃p
# python3 ./ps_mem.py | grep --only sl.*$
slé😃p
# LC_ALL=C python2 ./ps_mem.py | grep --only sl.*$
slé😃p
# LC_ALL=C python3 ./ps_mem.py | grep --only sl.*$
slp