human
Solve the following python programming problem given the following code:
def _encode_entity(text, pattern = _escape) : 
    def escape_entities(m, map = _escape_map) : 
        out = [] 
        append = out.append 
        for char in m.group () : 
            text = map.get (char) 
            if (text is None) : 
                text = ('&#%d;' % ord (char)) 
append (text) 
return string.join (out, '') 
try : 
        return _encode (pattern.sub (escape_entities, pattern), 'ascii') 
except TypeError : 
        _raise_serialization_error (text) 

    
    

    Fix the buggy line: return _encode (pattern.sub (escape_entities, pattern), 'ascii')
assistant
#Here is Python program to fix the buggy line: return _encode (pattern.

return _encode (pattern.sub (escape_entities, text), 'ascii')