Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-121027: Make the functools.partial object a method descriptor #121089

Merged
merged 2 commits into from
Jul 3, 2024

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jun 27, 2024

@nineteendo
Copy link
Contributor

nineteendo commented Jun 27, 2024

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

Doc/whatsnew/3.14.rst Outdated Show resolved Hide resolved
@@ -402,7 +398,7 @@ def _method(cls_or_self, /, *args, **keywords):
def __get__(self, obj, cls=None):
get = getattr(self.func, "__get__", None)
result = None
if get is not None and not isinstance(self.func, partial):
if get is not None:
Copy link
Member Author

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.

@serhiy-storchaka serhiy-storchaka merged commit ff5806c into python:main Jul 3, 2024
38 checks passed
@serhiy-storchaka serhiy-storchaka deleted the partial-get branch July 3, 2024 06:02
@bedevere-bot
Copy link

⚠️⚠️⚠️ 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

noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
JelleZijlstra added a commit that referenced this pull request Sep 29, 2024
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.
@MegaIng
Copy link

MegaIng commented Oct 25, 2024

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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants