Fix memory errors in retaining Python objects.
Added line numbers