def glob_escape(pathname): """ Escape all special characters. """ drive, pathname = os.path.splitdrive(pathname) pathname = _magic_check.sub(r'[\1]', pathname) return drive + pathname