Giter VIP home page Giter VIP logo

Comments (10)

mattip avatar mattip commented on August 21, 2024

It looks like the failure is around properly adding the __module__ attribute to callable2. How is that created?

from overrides.

mattip avatar mattip commented on August 21, 2024

Tracked in https://foss.heptapod.net/pypy/pypy/-/issues/4029

from overrides.

cfbolz avatar cfbolz commented on August 21, 2024

It seems to be int.bit_length.__module__, which does not exist in cpython, but is None in pypy. I suppose it's the usual problem with method_descriptor on CPython, which would mean this affects the methods of all builtin types. Method descriptors don't exist in pypy, instead we have regular function objects, but with __module__ set to None.

from overrides.

cfbolz avatar cfbolz commented on August 21, 2024

right, overrides would produce a similar exception on CPython if you make a slightly weird method where you del the __module__ attribute, like this:

class ASuper:
    def some_method(self):
        return 1
    del some_method.__module__
class ASub(ASuper):
    @override
    def some_method(self):
        return 2

yields:

tests/test_overrides.py:97: in <module>
    class ASub(ASuper):
tests/test_overrides.py:98: in ASub
    @override
overrides/overrides.py:143: in override
    return _overrides(method, check_signature, check_at_runtime)
overrides/overrides.py:170: in _overrides
    _validate_method(method, super_class, check_signature)
overrides/overrides.py:189: in _validate_method
    ensure_signature_is_compatible(super_method, method, is_static)
overrides/signature.py:99: in ensure_signature_is_compatible
    same_main_module = _is_same_module(sub_callable, super_callable)
overrides/signature.py:61: in _is_same_module
    mod2 = mod2.split(".")[0]
E   AttributeError: 'NoneType' object has no attribute 'split'

from overrides.

mattip avatar mattip commented on August 21, 2024

Method descriptors don't exist in pypy, instead we have regular function objects, but with __module__ set to None

Could we remove the __module__ attribute from methods on builtins?

from overrides.

mattip avatar mattip commented on August 21, 2024

So I guess the fix here is to check for None as well as AttributeError

from overrides.

cfbolz avatar cfbolz commented on August 21, 2024

yeah, pypy could try to make sure that the methods of builtins raise an error when reading __module__ instead of returning None. I can give that a try

from overrides.

cfbolz avatar cfbolz commented on August 21, 2024

that said, the __module__ attribute of builtin functions (eg abs) is "builtin" in both pypy and cpython, maybe we should simply adopt that for builtin methods too? Anyone have an opinion on either of these options?

from overrides.

mgorny avatar mgorny commented on August 21, 2024

I don't know whether it's worth changing this in PyPy — either way, I'll try making a PR to support both missing and None attribute, if only to support prior PyPy versions.

from overrides.

mkorpela avatar mkorpela commented on August 21, 2024

Thank you all for informing, debugging and solving the issue!

from overrides.

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.