Add valid_uri
Fix error in atexit._run_exitfuncs