Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

Some methods should left undefined on Object #582

Open
cflee opened this issue May 26, 2017 · 0 comments
Open

Some methods should left undefined on Object #582

cflee opened this issue May 26, 2017 · 0 comments

Comments

@cflee
Copy link
Member

cflee commented May 26, 2017

Per Python docs 3.3.7 on the data model, for numeric types, "Methods corresponding to operations that are not supported by the particular kind of number implemented (e.g., bitwise operations for non-integral numbers) should be left undefined."

For illustration, we consider the Float type which doesn't support bitwise operations like <<. Given this test code:

self.assertCodeExecution("""
    x = 0.0
    try:
        y = x.__lshift__
    except Exception as err:
        print(err)
        print(type(err))
    """)

We obtain the following output from the test suite:

AssertionError: '===end of test===\n' != "'float' object has no attribute '__lshif[47 chars]==\n"
+ 'float' object has no attribute '__lshift__'
+ <class 'AttributeError'>
  ===end of test===
 : Global context

In CPython, there is an AttributeError just for accessing the attribute/method. In VOC, accessing works perfectly fine, it's only invoking the __lshift__() method that throws the AttributeError. This behavior is incorrect.

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

No branches or pull requests

1 participant