Delete components script crashes
Based on your script you appear to be using Blender 2.80. The following may help to address some issues. Blender 2.80 allows for multiple objects to be in edit mode at the same time which is not strictly addressed in the below but the script only acts on the active object in the event multiple objects are selected in edit mode. previously your script could break if run in object mode causing obj = bpy.context.edit_object to be None type and me = obj.data to fail check was added prior to function call.

import bpy
import bmesh


def delete_faces():
    obj = bpy.context.active_object
    me = obj.data
    bm = bmesh.from_edit_mesh(me)
    sel_faces = [s for s in bm.faces if s.select]

    sel_mode = bpy.context.tool_settings.mesh_select_mode[:] # define active selection modes

    if sel_mode[2] == True:  # if polygon selection mode is on
#        bmesh.ops.delete(bm, geom=sel_faces, context=5)  # bl 2.79
        bmesh.ops.delete(bm, geom=sel_faces, context='FACES')  # bl 2.80
        # deselecting edges is not needed use FACES_ONLY if that is the desired effect
        # ('VERTS', 'EDGES', 'FACES_ONLY', 'EDGES_FACES', 'FACES', 'FACES_KEEP_BOUNDARY', 'TAGGED_ONLY')
        bmesh.update_edit_mesh(me, True, True)

if bpy.context.mode == 'EDIT_MESH':  # ensures both edit mode and mesh type before call
    delete_faces()