human
Solve the following python programming problem given the following code:
def enable_automatic_symbols(app) : 
    'Allow IPython to automatially create symbols (``isympy -a``). ' 
    import re 
    re_nameerror = re.compile ("name '(?P<symbol>[A-Za-z_][A-Za-z0-9_]*)' is not defined") 
    def _handler(self, etype, value, tb, tb_offset = None) : 
        'Handle :exc:`NameError` exception and allow injection of missing symbols. ' 
        if ((etype is NameError) and tb.tb_next and (not tb.tb_next.tb_next)) : 
            match = re_nameerror.match (str (value)) 
            if (match is not None) : 
                self.run_cell (("%(symbol)s = Symbol('%(symbol)s')" % { 
                    'symbol' : match.group ('symbol'), 
}), store_history = False) 
                try : 
                    code = self.user_ns ['In'] [(- 1)] 
except (KeyError, IndexError) : 
                    pass 
else : 
                    self.run_cell (code, store_history = False) 
                    return None 
finally : 
                    self.run_cell (('del %s' % match.group ('symbol')), store_history = False) 
stb = self.InteractiveTB.structured_traceback (etype, value, tb, tb_offset = tb_offset) 
        self._showtraceback (etype, value, stb) 
if hasattr (_handler, 'shell') : 
        app.shell.set_custom_exc ((NameError,), _handler) 
else : 
        app.set_custom_exc ((NameError,), _handler) 

    
    

    Fix the buggy line: if hasattr (_handler, 'shell') :
assistant
#Here is Python program to fix the buggy line: if hasattr (_handler, 'shell') :
.

if hasattr (app, 'shell') :