fix up cp ... exception handle in py
a bit of refactor
check for None in session