Title: Changed behavior of
Open Graph Title: Changed behavior of
X Title: Changed behavior of
Description: Bug report Bug description: There is a change in behavior in Python 3.11 that does not seem to be described in the "what's new" document. In the following code: class A: def meth(self): print(self) class B: pass a = A() b = B() b.meth = ...
Open Graph Description: Bug report Bug description: There is a change in behavior in Python 3.11 that does not seem to be described in the "what's new" document. In the following code: class A: def meth(self): print(self)...
X Description: Bug report Bug description: There is a change in behavior in Python 3.11 that does not seem to be described in the "what's new" document. In the following code: class A: def meth(self...
Opengraph URL: https://github.com/python/cpython/issues/113157
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Changed behavior of \u003cinstancemethod\u003e.__get__ in Python 3.11","articleBody":"# Bug report\n\n### Bug description:\n\nThere is a change in behavior in Python 3.11 that does not seem to be described in the [\"what's new\" document](https://docs.python.org/3.11/whatsnew/3.11.html).\n\nIn the following code:\n\n```python\nclass A:\n def meth(self):\n print(self)\n\nclass B:\n pass\n\na = A()\nb = B()\nb.meth = a.meth.__get__(b, B)\nb.meth()\n```\n\nThe `b.meth()` call receives `a` as the `self` argument up to Python 3.10, but `b` in 3.11 and 3.12.\n\nThis pattern is [used by the Pyramid framework](https://github.com/Pylons/pyramid/blob/3739a7790ba92c34098df3d804f27a1d8429f9fe/src/pyramid/request.py#L317). The change breaks Pyramid applications that use `add_request_method(someobject.somemethod, \"name\")`.\n\nI have to admit that I do not understand the descriptor protocol (or the documentation of `__get__`) well enough to say whether this is a legitimate use case, but it does exist in the wild.\n\n### CPython versions tested on:\n\n3.9, 3.10, 3.11, 3.12\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-113233\n* gh-115492\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/mschmitzer","@type":"Person","name":"mschmitzer"},"datePublished":"2023-12-15T08:54:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/113157/cpython/issues/113157"}
| 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:5f183d28-87b8-cabf-65d7-3f655bcee44b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98DE:DAC1:289E33:36D70B:6A60283E |
| html-safe-nonce | faaeb67405daccab50b255ce40117e5c856af90fb878fdc5b0ac241d95255ea6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OERFOkRBQzE6Mjg5RTMzOjM2RDcwQjo2QTYwMjgzRSIsInZpc2l0b3JfaWQiOiI4Mjc1MjY0MTc1NjIwNDk5NTE4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2241173f7b57a1c1585e52ab043f576677d3158e9229b76209e5372b4b5c0820 |
| hovercard-subject-tag | issue:2043202297 |
| 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/python/cpython/113157/issue_layout |
| twitter:image | https://opengraph.githubassets.com/01e66f32ab74819e6f8eda09a61b62031fa705ec8081d5daa865131bb3f6a73e/python/cpython/issues/113157 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/01e66f32ab74819e6f8eda09a61b62031fa705ec8081d5daa865131bb3f6a73e/python/cpython/issues/113157 |
| og:image:alt | Bug report Bug description: There is a change in behavior in Python 3.11 that does not seem to be described in the "what's new" document. In the following code: class A: def meth(self): print(self)... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mschmitzer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60da8c2a42fa2bbf5f7567474990ec467836a84444262a58e200fa91b7f3d2d0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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 | 9824515e740d83d5eb82168a089b806ab0fe04a1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width