`os.sep` is not callable. Add missing imports. Fix except `OSError` assignment.
Fix undefined variable error
Merge pull request #6726 from s0undt3ch/develop

Jenkins pylint reported fixes.