s4:pyparam: Fix resource leaks on error