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

Alpine linux 3.15 on pypy3 test_52_numeric_ops_float fails #4

Open
sundarnagarajan opened this issue Jan 14, 2023 · 2 comments
Open

Comments

@sundarnagarajan
Copy link
Owner

sundarnagarajan commented Jan 14, 2023

ERROR: test_52_numeric_ops_float (__main__.test_pyprotect)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_pyprotect.py", line 1137, in test_52_numeric_ops_float
    assert(ceil(w1) == 101)
  File "Proxy.pxi", line 114, in pyprotect.protected.Proxy.__ceil__
AttributeError: 'CF' object has no attribute '__ceil__'. Did you mean: __bool__?

Not yet ivnestigated.
The same test does not fail on PY3 / PY2 / PYPY2 on ubuntu jammy

@sundarnagarajan
Copy link
Owner Author

sundarnagarajan commented Jan 16, 2023

  • ceil() and floor() work on int (test_51_numeric_ops_int)
  • ceil() and floor() work on CF class derived from float, but
  • Proxy does not see __ceil__ or __floor__ methods in CF object

On Alpine Linux, on PYPY, ceil() and float() depend on something other than or more than __ceil__ and __floor__ methods

Workaround (for test failing):

if hasattr(n1, '__ceil__') and hasattr(n1, '__floor__'):
    res1 = (ceil(n1), floor(n1))
    res2 = (ceil(w1), floor(w1))
    assert(res2 == res1)

sundarnagarajan added a commit that referenced this issue Jan 16, 2023
@sundarnagarajan
Copy link
Owner Author

sundarnagarajan commented Jan 16, 2023

Implemented (more) correct answer in pyprotct/Proxy.pxi
Fix in c127f2a

--- a/pyprotect/Proxy.pxi
+++ b/pyprotect/Proxy.pxi
@@ -108,10 +108,10 @@ cdef class Proxy(object):
         return self.pvt_o.__trunc__()
 
     def __floor__(self):
-        return self.pvt_o.__floor__()
+        return math.floor(self.pvt_o)
 
     def __ceil__(self):
-        return self.pvt_o.__ceil__()
+        return math.ceil(self.pvt_o)

Keeping this issue open.

This is a surprising behavior in pypy3, and a behavior that specifically manifests on Alpine Linux (and not Ubuntu). This cannot be written off as "Python2 - will not fix".

sundarnagarajan added a commit that referenced this issue Jan 16, 2023
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

No branches or pull requests

1 participant