Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

cursor is not compatible with the with statement

#102

Submitted by: Valentin Lorentz

Hi,

The following line: (Python 2.7)

with connection.cursor() as cur:

raises this:

AttributeError: __exit__

Regards,
Valentin Lorentz

Reported by Psycopg website · February 22nd, 2012 @ 07:07 PM

State: resolved
Milestone: 2.5
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo

    Nobody has ever said it was.

    February 22nd, 2012 @ 10:33 PM

  2. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from new to hold

    Ticket put on hold: I don't want to add with support until the DB-SIG decides what should be its semantic. I'm not so worried about the cursor: more about the connection as there could be several ways to exit it. Notice though that cursors (the regular ones, not named ones) don't really hold any resource except the memory they have allocated, so using them into a with context doesn't really protect anything.

    February 22nd, 2012 @ 11:06 PM

  3. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from hold to open
    • Milestone set to 2.5
    • Milestone order changed from 90 to 0

    To be implemented as specified by the new DB-API extension

    December 3rd, 2012 @ 12:32 AM

  4. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from open to resolved

    implemented in devel, to be released in 2.5

    December 4th, 2012 @ 12:40 AM