I don't know the `query` structure, but don't you mean

    query['k'] = stringify_query(v)

?