@classdef.singleton_method("chdir", path="path")
    def method_chdir(self, space, path=None, block=None):
        if path is None:
            path = os.environ["HOME"]
        current_dir = os.getcwd()
        try:
            os.chdir(path)
        except __HOLE__ as e:
            raise error_for_oserror(space, e)
        if block is not None:
            try:
                return space.invoke_block(block, [space.newstr_fromstr(path)])
            finally:
                try:
                    os.chdir(current_dir)
                except OSError as e:
                    raise error_for_oserror(space, e)
        else:
            return space.newint(0)
dataset/ETHPy150Open topazproject/topaz/topaz/objects/dirobject.py/W_DirObject.method_chdir