This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author benrg
Recipients benrg, bup, eryksun
Date 2022-02-28.19:59:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646078390.72.0.0100923337547.issue46791@roundup.psfhosted.org>
In-reply-to
Content
The REMOVE_DIR case reduces to

    return RemoveDirectoryW(path->wide) ? 0 : -1;

so I think there's no reason to combine it with the other two.

The REMOVE_BOTH case is

    attrs = GetFileAttributesW(path->wide);

    if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) {
        success = RemoveDirectoryW(path->wide);
    } else {
        success = DeleteFileW(path->wide);
    }

    return success ? 0 : -1;

For REMOVE_BOTH, I don't see the need of calling GetFileAttributes - couldn't you just try DeleteFile, and if that fails, RemoveDirectory?
History
Date User Action Args
2022-02-28 19:59:50benrgsetrecipients: + benrg, eryksun, bup
2022-02-28 19:59:50benrgsetmessageid: <1646078390.72.0.0100923337547.issue46791@roundup.psfhosted.org>
2022-02-28 19:59:50benrglinkissue46791 messages
2022-02-28 19:59:50benrgcreate