def _getfullpathname(space, w_path): """helper for ntpath.abspath """ try: if space.isinstance_w(w_path, space.w_unicode): path = FileEncoder(space, w_path) fullpath = rposix.getfullpathname(path) w_fullpath = space.wrap(fullpath) else: path = space.str0_w(w_path) fullpath = rposix.getfullpathname(path) w_fullpath = space.wrap(fullpath) except OSError, e: raise wrap_oserror2(space, e, w_path)
def _getfullpathname(space, w_path): """helper for ntpath.abspath """ try: if space.isinstance_w(w_path, space.w_unicode): path = FileEncoder(space, w_path) fullpath = rposix.getfullpathname(path) w_fullpath = u2utf8(space, fullpath) else: path = space.bytes0_w(w_path) fullpath = rposix.getfullpathname(path) w_fullpath = space.newbytes(fullpath) except OSError as e: raise wrap_oserror2(space, e, w_path) else: return w_fullpath
def _nt_rabspath(path): try: if path == '': path = os.getcwd() return rposix.getfullpathname(path) except OSError: return path
def test__getfullpathname(self): posix = __import__(os.name) sysdrv = os.getenv('SystemDrive', 'C:') stuff = sysdrv + 'stuff' data = rposix.getfullpathname(stuff) assert data == posix._getfullpathname(stuff) # the most intriguing failure of ntpath.py should not repeat, here: assert not data.endswith(stuff)
def test__getfullpathname_long(self): stuff = "C:" + "\\abcd" * 100 py.test.raises(WindowsError, rposix.getfullpathname, stuff) ustuff = u"C:" + u"\\abcd" * 100 res = rposix.getfullpathname(ustuff) assert res == ustuff