Port `event_rpcgen.py` and `test/check-dumpevents.py` to Python 3. These scripts remain compatible with Python 2.