How to get around bpy.ops.object.material_slot_assign ()? Faced with a problem that causes crash Blender 2.80. 
For automation I created a script from a sequence of actions which works great if I run it in the blender console window, or if i Run Script in a text editor. 

But when I run this script through the command line without the graphical shell of the blender - he crashed.



Еhe exception method was used to find the reason. 
This is the command bpy.ops.object.material_slot_assign ()  

She is responsible for applying the material to the vertices in Edit Mode.  

import bpy 

bpy.ops.object.editmode_toggle()    
bpy.ops.mesh.select_all(action='SELECT')    
bpy.context.object.active_material_index = 1    
bpy.ops.object.material_slot_assign() 


If I exclude bpy.ops.object.material_slot_assign (), the script succeeds, except that the materials are not used. 

Who knows how to get around this command?
A little later, I reported to the developers and they fixed this error. T70714 This question has ceased to be relevant.