There's no reason to use os.chdir. Explicitly reject non-URL arguments instead of doing something dubious.
I can't think of a valid use-case for this, and I'm not sure what the right thing to do in this situation is.