Coder Social home page Coder Social logo

Comments (9)

alendit avatar alendit commented on June 1, 2024 2

Hi, I assume it applies to all "dunders"? I.e. I tried to patch __matmul__ on FunctionType to implement function chaining. And although f.__matmul__(g) does the right think, f @ g doesn't seem to pick up the existence of the overwritten implementation.

Of course, f.chain(g) would do, too, but the ability to override the operator behaviour would add a wholly another level of the black magic and let me maniacally laugh at the code reviewer's tears, so it would be incredibly useful, as you might imagine.

from forbiddenfruit.

phy1729 avatar phy1729 commented on June 1, 2024 1

I happen to be working in the same area. Looking to add __next__ which is proving troublesome because it can raise an exception. But I've added __repr__ and __hash__ on phy1729/complete-PyTypeObject

from forbiddenfruit.

soamicharan avatar soamicharan commented on June 1, 2024 1

please also add __getattr__ for patching

from forbiddenfruit.

clarete avatar clarete commented on June 1, 2024

Hello, sorry for the late response. forbiddenfruit is a really [lame] simple hack that exposes the __dict__ attribute of a python class. Magic methods and special protocols are resolved separately. forbiddenfruit would have to special case these methods and overwrite the right properties in the PyObject struct to allow patching these special guys.

It's possible but might take some digging to find out what to overwrite.

from forbiddenfruit.

alexchandel avatar alexchandel commented on June 1, 2024

This is resolved for methods defined in ff's PyTypeObject._fields_ or one of its method suites (e.g. PyNumberMethods) and added to override_dict. __repr__, __hash__, __call__, __iter__, and __next__ are still missing.

from forbiddenfruit.

pschanely avatar pschanely commented on June 1, 2024

Just a quick +1 for getting __repr__ working; it would enable symbolic reasoning about repr strings in CrossHair.

from forbiddenfruit.

RadiantUwU avatar RadiantUwU commented on June 1, 2024

__hash__ also doesnt work

from forbiddenfruit.

RadiantUwU avatar RadiantUwU commented on June 1, 2024

Right now, im trying to patch hash on the forbiddenfruit module

from forbiddenfruit.

MrFizzyBubbs avatar MrFizzyBubbs commented on June 1, 2024

+1 for __call__

from forbiddenfruit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.