Get around highlighted/selected objects with no active?

Here’s what I mean:


Objects are “selected” but with no current active. Any way of getting around this with python?

Attachments


Check if active object == None, if it is, set first object of selected objects active.