Skip to content

executemany crashes with empty input #179

@dvarrazzo

Description

@dvarrazzo

Regression in 3.0.6

    def test_executemany_no_data(conn, execmany):
        cur = conn.cursor()
>       cur.executemany("insert into execmany(num, data) values (%s, %s)", [])

tests/test_cursor.py:272: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
psycopg/psycopg/cursor.py:569: in executemany
    self._conn.wait(self._executemany_gen(query, params_seq))
psycopg/psycopg/connection.py:773: in wait
    return waiting.wait(gen, self.pgconn.socket, timeout=timeout)
psycopg/psycopg/waiting.py:243: in wait_epoll
    s = gen.send(ready)
psycopg/psycopg/cursor.py:225: in _executemany_gen
    self._set_result(0)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <psycopg.Cursor [no result] [INTRANS] (port=54314 user=piro database=psycopg3_test) at 0x7feca6b5cd50>, i = 0, format = None

    def _set_result(self, i: int, format: Optional[Format] = None) -> None:
        """
        Select one of the results in the cursor as the active one.
        """
        self._iresult = i
>       res = self.pgresult = self._results[i]
E       IndexError: list index out of range

psycopg/psycopg/cursor.py:410: IndexError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions