getpatch: update code with bsd-like errors code, % -> format(), pep8 fixes