Opened 4 years ago

Closed 4 years ago

#32705 closed Cleanup/optimization (fixed)

Database cache.delete uses cursor after it is closed

Reported by: ecogels Owned by: ecogels
Component: Core (Cache system) Version: 3.2
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by ecogels)

The return bool(cursor.rowcount) is outside of the with block, so the cursor will have been closed at that point.

From the DB API 2.0 spec: "The cursor will be unusable from this point forward" https://www.python.org/dev/peps/pep-0249/#Cursor.close

As the main backend drivers don't mind it I suppose that is is open to interpretation.

PR https://github.com/django/django/pull/14341

Change History (4)

comment:1 by Simon Charette, 4 years ago

Triage Stage: UnreviewedAccepted

comment:2 by ecogels, 4 years ago

Description: modified (diff)

comment:3 by Mariusz Felisiak, 4 years ago

Owner: changed from nobody to ecogels
Status: newassigned
Triage Stage: AcceptedReady for checkin

comment:4 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In a0a5e0f4:

Fixed #32705 -- Prevented database cache backend from checking .rowcount on closed cursor.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@…>

Note: See TracTickets for help on using tickets.
Back to Top