<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tempdir():
 """Creates a temporary directory"""

    directory_path = tempfile.mkdtemp()

    def clean_up():  # pylint: disable=missing-docstring
        shutil.rmtree(directory_path, onerror=on_error)

    with cd(directory_path, clean_up):
        yield directory_path