Skip to content

sqlite3.Blob indexing is not conformant with existing norms #92019

@erlend-aasland

Description

@erlend-aasland

Yesterday, @JelleZijlstra enlightened me that sqlite3.Blob indexing operate with bytes objects of length 1. This is a deviation from how bytes, bytearray, and memoryview work:

>>> bytes(b"0")[0]
48
>>> bytearray(b"0")[0]
48
>>> memoryview(b"0")[0]
48
>>> b = bytearray(b"0")
>>> b[0] = 1
>>> b[0] = b"1"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'bytes' object cannot be interpreted as an integer
>>> m = memoryview(b)
>>> m[0] = 1
>>> m[0] = b"1"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: memoryview: invalid type for format 'B'
>>> 

Suggesting to align sqlite3.Blob indexing behaviour so it expects ints and returns ints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy