code: def rmtree(path, ignore_errors=False, onerror=None):
      
      if ignore_errors:
          def onerror(*args):
              pass
      elif onerror is None:
          def onerror(*args):
              raise
      for root, dirs, unused_files in os.walk(path):
          for directory in dirs:
              try:
                  abs_directory = os.path.join(root, directory)
                  os.chmod(abs_directory, stat.S_IRWXU)
              except EnvironmentError as e:
                  onerror(os.chmod, abs_directory, e)
      shutil.rmtree(path, ignore_errors=ignore_errors, onerror=onerror)
docs: Same as shutil.rmtree, but supports directories without write or execute permissions.