René's URL Explorer Experiment


Title: create_datagram_endpoint() no longer compatible with CAN bus raw sockets · Issue #114887 · python/cpython · GitHub

Open Graph Title: create_datagram_endpoint() no longer compatible with CAN bus raw sockets · Issue #114887 · python/cpython

X Title: create_datagram_endpoint() no longer compatible with CAN bus raw sockets · Issue #114887 · python/cpython

Description: Bug report Bug description: Problem description We are using create_datagram_endpoint() to set up an asyncio-managed connection to a native hardware CAN bus interface at can0 under debian linux. We are using the sock named argument to pa...

Open Graph Description: Bug report Bug description: Problem description We are using create_datagram_endpoint() to set up an asyncio-managed connection to a native hardware CAN bus interface at can0 under debian linux. We...

X Description: Bug report Bug description: Problem description We are using create_datagram_endpoint() to set up an asyncio-managed connection to a native hardware CAN bus interface at can0 under debian linux. We...

Opengraph URL: https://github.com/python/cpython/issues/114887

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"create_datagram_endpoint() no longer compatible with CAN bus raw sockets ","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\n# Problem description\r\n\r\nWe are using `create_datagram_endpoint()` to set up an asyncio-managed connection to a native hardware CAN bus interface at `can0` under debian linux. We are using the `sock` named argument to pass in a pre-built raw socket to the FD.\r\n\r\nThis works in Python 3.5.3 but broke following a migration to 3.11.4. We found that the datagram endpoint would fail to be brought up, and the `connection_made(transport)` method on the `protocol_factory` would never be called. When I rejigged our code to await the coroutine I got:\r\n\r\n```\r\n    ValueError: A UDP Socket was expected, got \u003csocket.socket fd=7, family=29, type=3, proto=1, laddr=('can0',)\r\n```\r\n\r\nI believe this has gone unnoticed due to hardware CAN bus interfaces being rare.\r\n\r\n# Relevant history\r\n\r\nhttps://github.com/python/cpython/pull/4231\r\nhttps://github.com/python/cpython/pull/4898\r\nhttps://github.com/python/cpython/pull/4922\r\n\r\nDiscussion of underlying issues: https://bugs.python.org/issue32331\r\n\r\n# Core issue\r\n\r\nA socket connected to a CAN bus has `sock.type` `socket.SOCK_RAW`, I.E. `0b11`. This fails the comparison to `socket.SOCK_DGRAM` (`0b01`) so `create_datagram_endpoint()` raises an exception because the socket's type fails the \"is a datagram\" check, even though it is. In 3.5.3 the check was:\r\n\r\n```python\r\n    (sock.type \u0026 socket.SOCK_DGRAM) == socket.SOCK_DGRAM\r\n```\r\nThis worked because it was treating SOCK_DGRAM as a bitwise mask, which it kinda is, but kinda isn't.\r\n\r\nx86_64-linux-gnu/bits/socket_type.h:\r\n```c\r\n    ...\r\n    /* Types of sockets.  */\r\n    enum __socket_type\r\n    {\r\n    SOCK_STREAM = 1,\t\t/* Sequenced, reliable, connection-based\r\n                    byte streams.  */\r\n    #define SOCK_STREAM SOCK_STREAM\r\n    SOCK_DGRAM = 2,\t\t/* Connectionless, unreliable datagrams\r\n                    of fixed maximum length.  */\r\n    #define SOCK_DGRAM SOCK_DGRAM\r\n    SOCK_RAW = 3,\t\t\t/* Raw protocol interface.  */\r\n    #define SOCK_RAW SOCK_RAW\r\n    SOCK_RDM = 4,\t\t\t/* Reliably-delivered messages.  */\r\n    ...\r\n```\r\n\r\nI am torn on the best way to approach a fix here. I have written a PR that replaces\r\n\r\n```python\r\n    if sock.type != socket.SOCK_DGRAM:\r\n```\r\n\r\ncomparisons with\r\n\r\n```python\r\n    if not sock.type \u0026 socket.SOCK_DGRAM:\r\n```\r\nhowever this perpetuates the enum-vs-bitmask confusion. A more constrained change might be to change\r\n\r\n```python\r\n    if sock.type != socket.SOCK_DGRAM:\r\n```\r\n\r\nto\r\n\r\n```python\r\n    if not (sock.type == socket.SOCK_DGRAM || sock.type == socket.SOCK_RAW):\r\n```\r\n\r\nbut that may not catch every instance of the problem. I'd appreciate some guidance on this.\r\n\r\nCheers,\r\nTravis.\r\n\r\n### CPython versions tested on:\r\n\r\n3.11\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\r\n\r\n\u003c!-- gh-linked-prs --\u003e\r\n### Linked PRs\r\n* gh-114888\r\n* gh-114893\n* gh-114977\n* gh-114978\n* gh-114979\n* gh-114980\n\u003c!-- /gh-linked-prs --\u003e\r\n","author":{"url":"https://github.com/tjhowse","@type":"Person","name":"tjhowse"},"datePublished":"2024-02-02T04:02:19.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/114887/cpython/issues/114887"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:35457304-dd59-cb07-6dc6-dfd1ee07481e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE58E:3046CB:1691572:20FC181:6A4E521F
html-safe-nonce25bd5ad2dc6f1aab02578bd26ed76da70622ed86d24e05e8a38919bc5ee73778
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNThFOjMwNDZDQjoxNjkxNTcyOjIwRkMxODE6NkE0RTUyMUYiLCJ2aXNpdG9yX2lkIjoiOTQyMTczMzA2NjI2MTM0NTU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac359acdf3975bb5ef5df02452965b56d1df72be06ba1579b3e86a0be0130e45a8
hovercard-subject-tagissue:2114002039
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/python/cpython/114887/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d2cf8f6b16e0ab3bfb71aac3d5ee32803345661483a2aedb1232b3f2921ad7c3/python/cpython/issues/114887
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d2cf8f6b16e0ab3bfb71aac3d5ee32803345661483a2aedb1232b3f2921ad7c3/python/cpython/issues/114887
og:image:altBug report Bug description: Problem description We are using create_datagram_endpoint() to set up an asyncio-managed connection to a native hardware CAN bus interface at can0 under debian linux. We...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernametjhowse
hostnamegithub.com
expected-hostnamegithub.com
None030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
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
releasef344f1eab54fc7dfc02d0d018cda7e158c3db65c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/114887#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F114887
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F114887
Sign up https://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=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/114887
Reloadhttps://github.com/python/cpython/issues/114887
Reloadhttps://github.com/python/cpython/issues/114887
Please reload this pagehttps://github.com/python/cpython/issues/114887
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/114887
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 34.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.6k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
create_datagram_endpoint() no longer compatible with CAN bus raw sockets https://github.com/python/cpython/issues/114887#top
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
3.13bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/tjhowse
tjhowsehttps://github.com/tjhowse
on Feb 2, 2024https://github.com/python/cpython/issues/114887#issue-2114002039
#4231https://github.com/python/cpython/pull/4231
#4898https://github.com/python/cpython/pull/4898
#4922https://github.com/python/cpython/pull/4922
https://bugs.python.org/issue32331https://bugs.python.org/issue32331
gh-114887: Perform bitwise comparisons with SOCK_DGRAM and SOCK_STEAM #114888https://github.com/python/cpython/pull/114888
gh-114887 Reject only sockets of type SOCK_STREAM in create_datagram_endpoint(), improve exception message. #114893https://github.com/python/cpython/pull/114893
gh-114887 Reject only sockets of type SOCK_STREAM in create_datagram_endpoint(), improve exception message. #114977https://github.com/python/cpython/pull/114977
gh-114887 Reject only sockets of type SOCK_STREAM in create_datagram_endpoint(), improve exception message. #114978https://github.com/python/cpython/pull/114978
[3.11] gh-114887 Reject only sockets of type SOCK_STREAM in create_da… #114979https://github.com/python/cpython/pull/114979
[3.12] gh-114887 Reject only sockets of type SOCK_STREAM in create_da… #114980https://github.com/python/cpython/pull/114980
3.11only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.11%22
3.12only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.12%22
3.13bugs and security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%223.13%22
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
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.