Title: Bit cannot round-trip accepted empty values through text · Issue #165 · pgvector/pgvector-python · GitHub
Open Graph Title: Bit cannot round-trip accepted empty values through text · Issue #165 · pgvector/pgvector-python
X Title: Bit cannot round-trip accepted empty values through text · Issue #165 · pgvector/pgvector-python
Description: Bit accepts a zero-length value from bytes or binary data, but cannot reconstruct that value from its own to_text() output. Direct construction from an empty string or list fails the same way. Reproduced on current master at 8cef6e4e867b...
Open Graph Description: Bit accepts a zero-length value from bytes or binary data, but cannot reconstruct that value from its own to_text() output. Direct construction from an empty string or list fails the same way. Repr...
X Description: Bit accepts a zero-length value from bytes or binary data, but cannot reconstruct that value from its own to_text() output. Direct construction from an empty string or list fails the same way. Repr...
Opengraph URL: https://github.com/pgvector/pgvector-python/issues/165
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bit cannot round-trip accepted empty values through text","articleBody":"`Bit` accepts a zero-length value from bytes or binary data, but cannot reconstruct that value from its own `to_text()` output. Direct construction from an empty string or list fails the same way.\n\nReproduced on current `master` at `8cef6e4e867b8d07971da1a3d6170fb6e75e3c40` (package version 0.5.1), with Python 3.13.16:\n\n```python\nfrom struct import pack\nfrom pgvector import Bit\n\nbit = Bit(b\"\")\nassert bit.to_list() == []\nassert bit.to_text() == \"\"\nassert bit.to_binary() == pack(\">i\", 0)\nassert Bit.from_binary(bit.to_binary()) == bit\n\nBit.from_text(bit.to_text())\n# ValueError: invalid literal for int() with base 2: ''\n\n# These also raise the same ValueError:\n# Bit(\"\")\n# Bit([])\n```\n\nThe shared string/list constructor reaches `int(value, 2)` with `value == \"\"`. This makes text round trips inconsistent with the already accepted empty bytes/binary representation. I would expect the empty text/list inputs to preserve that same zero-length value, rather than represent a one-bit zero or raise an integer-parsing error.\n\nNonempty controls at lengths 1, 7, 8 and 9 preserve their exact text and binary representations. `Bit(b\"\\x00\")` remains eight zero bits, distinct from the empty value, and invalid strings such as `\"0b1\"`, `\"1_0\"` and `\"201\"` are still rejected. This is separate from the invalid-string validation fixed in #161 and the SQLAlchemy input adaptation proposed in #137.\n\nThis report concerns the public `Bit` conversion API only. The reproduction and controls were executed directly against the cited source using the Python standard library; no NumPy or PostgreSQL round trip is claimed. The repository pytest suite could not start because pytest was unavailable, and dependency restoration failed over verified HTTPS, so I am not submitting a code fix as validated.\n\nPrepared with AI assistance; no human review is claimed.","author":{"url":"https://github.com/j45856021-dev","@type":"Person","name":"j45856021-dev"},"datePublished":"2026-10-14T09:03:00Z","url":"https://github.com/pgvector/pgvector-python/issues/165"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:aee50958-034e-f508-72d0-b432b32ea659 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E45C:729DB:B5A9A0:EE4A44:6AFE8816 |
| html-safe-nonce | dfd65f6a3a5a736415a11e230a0ec4900da99ab0ee17514319f06bedf1eebefb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDVDOjcyOURCOkI1QTlBMDpFRTRBNDQ6NkFGRTg4MTYiLCJ2aXNpdG9yX2lkIjoiODU5OTI2MjgxNjA4NTM3OTA5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | deb9997a72666755c6b54e1a1f6bfc3d7db9e7c8c19932f9fb5a7aaf005c994c |
| hovercard-subject-tag | issue:5844978328 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pgvector/pgvector-python/165/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a68aead321ce369a980cbdfcbff202ecbed7da052c94c78cb25c8da5c36510d7/pgvector/pgvector-python/issues/165 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a68aead321ce369a980cbdfcbff202ecbed7da052c94c78cb25c8da5c36510d7/pgvector/pgvector-python/issues/165 |
| og:image:alt | Bit accepts a zero-length value from bytes or binary data, but cannot reconstruct that value from its own to_text() output. Direct construction from an empty string or list fails the same way. Repr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | j45856021-dev |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| go-import | github.com/pgvector/pgvector-python git https://github.com/pgvector/pgvector-python.git |
| octolytics-dimension-user_id | 98363230 |
| octolytics-dimension-user_login | pgvector |
| octolytics-dimension-repository_id | 376300726 |
| octolytics-dimension-repository_nwo | pgvector/pgvector-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 376300726 |
| octolytics-dimension-repository_network_root_nwo | pgvector/pgvector-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width