#33331: Improve exception handling with `cursor.close()` after errors
-------------------------------------+-------------------------------------
Reporter: Daniel Hahler | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 3.2
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Daniel Hahler):
Ok, fair enough - it is only fixing a regression on Python 3 then (for
me), that was actually done as a workaround.
I suggest reading the original tickets description maybe then: my
intention was to not mask / "extend" the actual exception with more
information (the (IMHO incorrectly chained) error during cleanup, that is
expected to fail). It is similar to a `file.close()` when it is expected
that it wasn't created or its handler being invalid already.
Replying to
https://github.com/django/django/commit/6b6be692fcd102436c7abef1d7b3fa1d37ad4bdf#r67292630:
> The cleanup part of the chain adds noise to the actual source of the
error, so maybe it can be improved. But that’s an improvement over the
existing situation, not a regression.
Ok, I see. That's what I've meant to do: basically restoring the behavior
with Python 3 (when the workaround for Python 2 was in place), while being
a bit smarter to only ignore/swallow expected errors.
I was not aware that the intention with the Python 2 workaround was to
chain ("add useless noise") always with Python 3.
The question here really is also: if you would know that the connection is
invalid, and that `close()` would throw: would you call it in the first
place?
As for a new PR I'd rather update the existing one, but cannot re-open it
as mentioned there.
--
Ticket URL: <https://code.djangoproject.com/ticket/33331#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.b98be212b2d500ea0a5e8dbc14782482%40djangoproject.com.