GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-121027: Make the functools.partial object a method descriptor by serhiy-storchaka · Pull Request #121089 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jun 27, 2024 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Co-authored-by: d.grigonis [email protected]

  • Issue: Add __get__ to the partial object #121027

📚 Documentation preview 📚: https://cpython-previews--121089.org.readthedocs.build/

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
serhiy-storchaka requested a review from rhettinger June 27, 2024 11:22
@bedevere-app bedevere-app Bot mentioned this pull request Jun 27, 2024
Add __get__ to the partial object #121027
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Jun 27, 2024
@serhiy-storchaka
serhiy-storchaka force-pushed the partial-get branch from 5ecccee to 693fbc7 Compare June 27, 2024 11:23
@nineteendo

nineteendo commented Jun 27, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This should have been labeled as "DO-NOT-MERGE" until #121086 was merged. There are conflicts anyway now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka d.grigonis
pythongh-121027: Make the functools.partial object a method descriptor
d752505
Co-authored-by: d.grigonis <[email protected]>
@serhiy-storchaka
serhiy-storchaka force-pushed the partial-get branch from 693fbc7 to d752505 Compare June 27, 2024 11:56
serhiy-storchaka
serhiy-storchaka commented Jun 27, 2024
View reviewed changes
Comment thread Doc/whatsnew/3.14.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/functools.py
get = getattr(self.func, "__get__", None)
result = None
if get is not None and not isinstance(self.func, partial):
if get is not None:

@serhiy-storchaka serhiy-storchaka Jun 27, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was needed to avoid emitting a warning for partialmethod(partial(...)), even if the final behavior is not changed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
serhiy-storchaka
serhiy-storchaka commented Jun 27, 2024
View reviewed changes
Comment thread Doc/whatsnew/3.14.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

@serhiy-storchaka
Update Doc/whatsnew/3.14.rst
fab5797
rhettinger
rhettinger approved these changes Jun 30, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Jun 30, 2024
@serhiy-storchaka
serhiy-storchaka merged commit ff5806c into python:main Jul 3, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Jul 3, 2024
@serhiy-storchaka
serhiy-storchaka deleted the partial-get branch July 3, 2024 06:02
@bedevere-bot

bedevere-bot commented Jul 3, 2024

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Ubuntu NoGIL Refleaks 3.x has failed when building commit ff5806c.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1226/builds/2167) and take a look at the build logs.
  4. Check if the failure is related to this commit (ff5806c) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1226/builds/2167

Failed tests:

  • test.test_concurrent_futures.test_thread_pool

Failed subtests:

  • test_free_reference - test.test_concurrent_futures.test_thread_pool.ThreadPoolExecutorTest.test_free_reference

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/test_concurrent_futures/executor.py", line 130, in test_free_reference
    self.assertIsNone(wr())
    ~~~~~~~~~~~~~~~~~^^^^^^
AssertionError: <test.test_concurrent_futures.executor.MyObject object at 0x20002080170> is not None


Traceback (most recent call last):
  File "/home/ubuntu/buildarea/3.x.itamaro-ubuntu-aws.refleak.nogil/build/Lib/test/test_concurrent_futures/executor.py", line 130, in test_free_reference
    self.assertIsNone(wr())
    ~~~~~~~~~~~~~~~~~^^^^^^
AssertionError: <test.test_concurrent_futures.executor.MyObject object at 0x20006090090> is not None
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@serhiy-storchaka d.grigonis @estyxx
pythongh-121027: Make the functools.partial object a method descriptor (
d56f949
pythonGH-121089)

Co-authored-by: d.grigonis <[email protected]>
@JelleZijlstra JelleZijlstra mentioned this pull request Sep 28, 2024
functools: Give up on lazy-importing types #124736
Merged
JelleZijlstra added a commit that referenced this pull request Sep 29, 2024
@JelleZijlstra
functools: Give up on lazy-importing types (#124736)
95581b3
PR #121089 added an eager import for types.MethodType, but
still left the existing hacks for lazily importing from types.

We could also create MethodType internally in functools.py (e.g.,
by using `type(Placeholder.__repr__)`, but it feels not worth it at
this point, so instead I unlazified all the usages of types in the
module.
@hroncok hroncok mentioned this pull request Oct 25, 2024
python 3.14.0a1 - test_partial and test_smart_decorator are failing lark-parser/lark#1480
Closed
@MegaIng

MegaIng commented Oct 25, 2024

Copy link
Copy Markdown

May I ask why this change was considered critical enough to not follow PEP 387?

It is clearly backwards incompatible and is in fact breaking code, see lark-parser/lark#1480 .

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 25, 2024
Using functools.partial to make functions not considered as methods when given as enum values no longer works #125316
Closed
partial now behaves like a method descriptor #125983
Closed
@james-garner-canonical james-garner-canonical mentioned this pull request Jun 22, 2026
ci: test Ops 2.23 with Python 3.14 canonical/operator#2576
Merged
james-garner-canonical added a commit to canonical/operator that referenced this pull request Jun 23, 2026
@james-garner-canonical
ci: test Ops 2.23 with Python 3.14 (#2576)
5698b3f
#2546 is blocked because we don't run the tests on this branch with
Python 3.14, but these are configured as required checks. Since Ops 2.23
only specifies Python `>=3.8`, we'd expect it to run fine with Python
3.14.

In addition to adding 3.14 to the list of versions in CI, we also need
to add it to the list of environments in `tox.ini`, and follow #2091 in
patching some of the tests: we now need to wrap our `functools.partial`
objects in `staticmethod` due to `partial` implementing the decriptor
protocol in Python 3.14
(python/cpython#121027,
python/cpython#121089). However, because we're
on an older `pyright` version in this maintenance branch, this leads to
type checking errors which we ignore (bumping `pyright` resolves this
but introduces 20+ other errors which would add noise to this PR).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rhettinger rhettinger rhettinger approved these changes
+1 more reviewer
@dg-pb dg-pb dg-pb left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@serhiy-storchaka @nineteendo @bedevere-bot @MegaIng @rhettinger @dg-pb
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.