Skip to content

asyncpg/protocol/record/recordobj.c:562: bad argument to internal function when using custom Record class #676

Closed
@yohanboniface

Description

@yohanboniface
  • asyncpg version: latest git 3d0e23f
  • PostgreSQL version: 13.1
  • Python version: 3.9
  • Platform: linux
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes, but from local git checkout
  • If you built asyncpg locally, which version of Cython did you use?: asyncpg/.eggs/Cython-0.29.21
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : yes

How to reproduce

import asyncio
import asyncpg
from datetime import date
import uvloop

uvloop.install()


class MyRecord(asyncpg.Record):
    pass


async def main():
    conn = await asyncpg.connect("postgresql://postgres@localhost/test")
    await conn.execute(
        "CREATE TABLE IF NOT EXISTS users(id serial PRIMARY KEY, name text, dob date)"
    )

    await conn.execute(
        "INSERT INTO users(name, dob) VALUES($1, $2)", "Bob", date.today()
    )

    row = await conn.fetchrow(
        "SELECT * FROM users WHERE name = $1", "Bob", record_class=MyRecord
    )
    # Will raise asyncpg/protocol/record/recordobj.c:562: bad argument to internal function
    print(row.items())

    # Close the connection.
    await conn.close()


asyncio.get_event_loop().run_until_complete(main())

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