René's URL Explorer Experiment


Title: Bit() accepts strings Postgres rejects and silently changes the bits · Issue #161 · pgvector/pgvector-python · GitHub

Open Graph Title: Bit() accepts strings Postgres rejects and silently changes the bits · Issue #161 · pgvector/pgvector-python

X Title: Bit() accepts strings Postgres rejects and silently changes the bits · Issue #161 · pgvector/pgvector-python

Description: Bit() builds its bits with int(value, 2) at pgvector/bit.py:36, and takes _length from the raw string before that. Python's int accepts underscores, a sign, surrounding whitespace and a 0b prefix, so four strings Postgres rejects come ba...

Open Graph Description: Bit() builds its bits with int(value, 2) at pgvector/bit.py:36, and takes _length from the raw string before that. Python's int accepts underscores, a sign, surrounding whitespace and a 0b prefix, ...

X Description: Bit() builds its bits with int(value, 2) at pgvector/bit.py:36, and takes _length from the raw string before that. Python's int accepts underscores, a sign, surrounding whitespace and a 0b pref...

Opengraph URL: https://github.com/pgvector/pgvector-python/issues/161

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bit() accepts strings Postgres rejects and silently changes the bits","articleBody":"`Bit()` builds its bits with `int(value, 2)` at `pgvector/bit.py:36`, and takes `_length` from the raw string before that. Python's `int` accepts underscores, a sign, surrounding whitespace and a `0b` prefix, so four strings Postgres rejects come back as a `Bit` holding different bits and a different length.\n\n```\n$ PYTHONPATH=/var/tmp/p11L1/pgv python pgv_bit_probe.py      # master fd74f78, Python 3.12.3\npgvector: /var/tmp/p11L1/pgv/pgvector/bit.py\nBit('1010'      ) -> to_text()='1010'       len=4\nBit('1010_1010' ) -> to_text()='010101010'  len=9\nBit('+1010'     ) -> to_text()='01010'      len=5\nBit(' 1010'     ) -> to_text()='01010'      len=5\nBit('1010\\n'    ) -> ValueError: expected bit string\nBit('-1010'     ) -> OverflowError: can't convert negative int to unsigned\nBit('0b1010'    ) -> to_text()='001010'     len=6\n```\n\nPostgres rejects all four literals, but the client never sends them. What it sends in their place is a valid bit string, and the column takes it. pgvector 0.8.7 on PostgreSQL 17.11, `docker.io/pgvector/pgvector:pg17`:\n\n```\npostgres=# SELECT '1010_1010'::bit(9);\nERROR:  \"_\" is not a valid binary digit\npostgres=# SELECT '0b1010'::bit(6);\nERROR:  \"b\" is not a valid binary digit\npostgres=# SELECT '01010'::bit(5);      -- what Bit('+1010') sends instead\n 01010\n```\n\n`'-1010'` raises `OverflowError` where the `except ValueError` at `bit.py:37-38` was meant to turn it into `expected bit string`.\n\nA `re.fullmatch('[01]*', value)` before the padding rejects all five and times the same as the `int()` it guards. The obvious `set(value) \u003c= {'0', '1'}` is 4.6x, which is worth avoiding on a constructor you already tuned in `2ae28ba`:\n\n```\n$ python3 -m timeit -s \"import re; s='01'*32000\" \"\u003cexpr>\"   # Python 3.12.3, best of 5\nint(s, 2)                   98.4 usec\nre.fullmatch('[01]*', s)    92.9 usec\nset(s) \u003c= {'0','1'}          451 usec\n```\n\n@ankane would you take a pull request for that, with cases in `tests/test_bit.py` next to `test_str`, or do you read the permissive parsing here as deliberate?\n","author":{"url":"https://github.com/chrikrah","@type":"Person","name":"chrikrah"},"datePublished":"2026-10-04T05:02:20Z","url":"https://github.com/pgvector/pgvector-python/issues/161"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:03d16ac3-2c20-b89a-4900-e29d0012ecb3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE4A2:3C86C1:C4D5AB:102251B:6AFE8A68
html-safe-noncedba61e84c5bc08a7a80bfd6cc3a4de3c7f21682d4e6915ff8e6af6707fff30f9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEEyOjNDODZDMTpDNEQ1QUI6MTAyMjUxQjo2QUZFOEE2OCIsInZpc2l0b3JfaWQiOiI4NjEyMTY2MzYyNDI2NDExNjI0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac883fc3c707ed05956a1acd90b992eb1d8ff7bba3cb404506c5c323ab630a008b
hovercard-subject-tagissue:5696406139
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pgvector/pgvector-python/161/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3285442c5f76957e1238c7655381c03efdd8f409609c5668bd471fb62d776bc3/pgvector/pgvector-python/issues/161
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3285442c5f76957e1238c7655381c03efdd8f409609c5668bd471fb62d776bc3/pgvector/pgvector-python/issues/161
og:image:altBit() builds its bits with int(value, 2) at pgvector/bit.py:36, and takes _length from the raw string before that. Python's int accepts underscores, a sign, surrounding whitespace and a 0b prefix, ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamechrikrah
hostnamegithub.com
expected-hostnamegithub.com
Noneb3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86
turbo-cache-controlno-preview
go-importgithub.com/pgvector/pgvector-python git https://github.com/pgvector/pgvector-python.git
octolytics-dimension-user_id98363230
octolytics-dimension-user_loginpgvector
octolytics-dimension-repository_id376300726
octolytics-dimension-repository_nwopgvector/pgvector-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id376300726
octolytics-dimension-repository_network_root_nwopgvector/pgvector-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4a10310af51a1bfffbedc4fd81cb582acf0cb0ff
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/pgvector/pgvector-python/issues/161#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpgvector%2Fpgvector-python%2Fissues%2F161
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpgvector%2Fpgvector-python%2Fissues%2F161
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=pgvector%2Fpgvector-python
Reloadhttps://github.com/pgvector/pgvector-python/issues/161
Reloadhttps://github.com/pgvector/pgvector-python/issues/161
Reloadhttps://github.com/pgvector/pgvector-python/issues/161
pgvectorhttps://github.com/pgvector
pgvector-pythonhttps://github.com/pgvector/pgvector-python
Codehttps://github.com/pgvector/pgvector-python
Issues2 (2)https://github.com/pgvector/pgvector-python/issues
Pull requests8 (8)https://github.com/pgvector/pgvector-python/pulls
Actionshttps://github.com/pgvector/pgvector-python/actions
Security and qualityhttps://github.com/pgvector/pgvector-python/security
Insightshttps://github.com/pgvector/pgvector-python/insights
https://github.com/pgvector/pgvector-python
New issuehttps://github.com/login?return_to=https://github.com/pgvector/pgvector-python/issues/161
New issuehttps://github.com/login?return_to=https://github.com/pgvector/pgvector-python/issues/161
Bit() accepts strings Postgres rejects and silently changes the bitshttps://github.com/pgvector/pgvector-python/issues/161#top
https://github.com/chrikrah
chrikrahhttps://github.com/chrikrah
on Oct 4, 2026https://github.com/pgvector/pgvector-python/issues/161#issue-5696406139
@ankanehttps://github.com/ankane
ankanehttps://github.com/ankane
completedhttps://github.com/pgvector/pgvector-python/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
474522bhttps://github.com/pgvector/pgvector-python/commit/474522bafad1385c4bdda439700f39226b309ec0
on Oct 4, 2026https://github.com/pgvector/pgvector-python/issues/161#event-32458334695
https://github.com/ankane
ankanehttps://github.com/ankane
on Oct 4, 2026https://github.com/pgvector/pgvector-python/issues/161#issuecomment-5983637112
@chrikrahhttps://github.com/chrikrah
Sign up for freehttps://github.com/signup?return_to=https://github.com/pgvector/pgvector-python/issues/161
Sign in to commenthttps://github.com/login?return_to=https://github.com/pgvector/pgvector-python/issues/161
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.