clarete / forbiddenfruit

Patch built-in python objects

Home Page:https://clarete.li/forbiddenfruit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0.1.3 breaks overriding __init_subclass__

Julian opened this issue · comments

Hi.

I have this: https://pypi.org/project/composition/ which works great on 0.1.2,
but 0.1.3 appears to have broken it (highly important production software, so
we had a full blown outage today, millions were lost).

The traceback looks like:

?  venv/bin/python -c 'import composition'                                                                                                                              julian@Air
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/julian/Desktop/venv/lib/python3.7/site-packages/composition.py", line 24, in <module>
    forbiddenfruit.curse(object, "__init_subclass__", dikembe_mutombo)
  File "/Users/julian/Desktop/venv/lib/python3.7/site-packages/forbiddenfruit/__init__.py", line 412, in curse
    _curse_special(klass, attr, value)
  File "/Users/julian/Desktop/venv/lib/python3.7/site-packages/forbiddenfruit/__init__.py", line 327, in _curse_special
    assert isinstance(func, FunctionType)
AssertionError

which I assume fails because classmethods are not FunctionTypes. Not sure
what the purpose of that assertion is at all (rather than just letting whatever
the user passed in through), but my suspicion even if it's there is that it
just means to check the thing is callable.

(Will see about sending a PR in a bit).

yikes. very sorry about the outage.

I can see two things that I really can improve here.

  1. That assert slipped through the cracks during my PR review. Also, we unfortunately didn't have any test cases that depended on anything that wasn't a function (for dunder methods) :/
  2. I could've bumped at least the minor component on the version since the change wasn't exactly trivial.

On the solution side, I think you're right. I think we only need it to be a callable. I'm just running the change on the CI to confirm that the change doesn't make any other version unhappy.

I wasn't sure about keeping the assert at all but I think it'd take a little more investigation to say safely that we won't segfault the entire interpreter (which would be way harder to debug) if we receive something weirder there.

On the release side, I might release 0.2.0 as soon as we fix this issue, so we might save other people the trouble.

My little branch was really just a tiny test. A proper PR would be more than welcome.

Once again, sorry about the mess and thanks for reporting the failure.

Hi @Julian. The CI is happy with the change you suggested:
https://travis-ci.org/clarete/forbiddenfruit/builds/592058249

Let me know if you'll have time to put a PR together or I'll plan to do so at some point.

yikes. very sorry about the outage.

Thank you, your sympathy is much appreciated. I have assured my bitcoin
investors that the outage was a simple result of market correction (that or
Jimmy unplugged the power cable). I think they bought it.

I sent a PR (#35) which yeah is the same fix as your commit, and seems to pass.
Test included there too. Comments welcome of course.

Thanks a lot for the PR! Just merged it and I'll look into releasing it this week <o/

Once again thanks for reporting the bug and sorry it caused you a headache :/