I have a script that tries to derive several blend files from the same source file. However after a while I realised that the delete() operator apparently doesn't work after reverting the file. I could nail it down to this, that can be run with the default startup scene.
import bpy
# if this line is removed, delete() behaves as expected.
bpy.ops.wm.revert_mainfile()
bpy.context.scene.objects['Cube'].select=True
bpy.ops.object.delete()
Expected result: Cube should be deleted.
Actual result: Cube is selected, but not deleted
Feature? Bug? Something I don't understand about how scripts operate when loading/reverting files?
This can be tested by copying the script in a text window and hitting 'Run Script'
EDIT: It's been suggested that I should refresh the UI to see the result. This is irrelevant to the problem. (As I did) you can confirm that nothing was deleted programmatically.