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

py3: get rid of an hex problem #24201

Closed
fchapoton opened this issue Nov 12, 2017 · 13 comments
Closed

py3: get rid of an hex problem #24201

fchapoton opened this issue Nov 12, 2017 · 13 comments

Comments

@fchapoton
Copy link
Contributor

Starting sage with python3 stop with

/usr/lib64/python3.6/site-packages/sage/rings/real_mpfr.pyx in init sage.rings.real_mpfr()
   2033 
   2034             sage: [RR(s).hex() for s in ['+inf', '-inf', 'nan']]
   2035             ['inf', '-inf', 'nan']
   2036         """
   2037         cdef char *s
   2038         cdef int r
   2039         sig_on()
   2040         r = mpfr_asprintf(&s, "%Ra", self.value)
   2041         sig_off()
   2042         if r < 0:  # MPFR free()s its buffer itself in this case
   2043             raise RuntimeError("unable to convert an mpfr number to a string")
   2044         t = str(s)
   2045         mpfr_free_str(s)
   2046         return t
   2047 
-> 2048     hex = __hex__
        global hex = undefined
        global __hex__ = undefined
   2049 
   2050     def __copy__(self):
   2051         """
   2052         Return copy of ``self`` - since ``self`` is immutable, we just return
   2053         ``self`` again.
   2054 
   2055         EXAMPLES::
   2056 
   2057             sage: a = 3.5
   2058             sage: copy(a) is  a
   2059             True
   2060         """
   2061         return self    # since object is immutable.
   2062 
   2063     def _integer_(self, Z=None):

NameError: name '__hex__' is not defined

CC: @kiwifb

Component: python3

Author: Frédéric Chapoton

Branch/Commit: 358ef36

Reviewer: François Bissey

Issue created by migration from https://trac.sagemath.org/ticket/24201

@fchapoton fchapoton added this to the sage-8.1 milestone Nov 12, 2017
@fchapoton
Copy link
Contributor Author

Commit: 358ef36

@fchapoton
Copy link
Contributor Author

Author: Frédéric Chapoton

@fchapoton
Copy link
Contributor Author

comment:1

here is a tentative, maybe sufficient ?


New commits:

358ef36py3: get rid of an hex alias

@fchapoton
Copy link
Contributor Author

Branch: u/chapoton/24201

@kiwifb
Copy link
Member

kiwifb commented Nov 12, 2017

comment:2

Well, that get us a tiny bit further

/usr/lib64/python3.6/site-packages/sage/rings/real_mpfr.pyx in init sage.rings.real_mpfr()
   2033 
   2034             sage: [hex(RR(s)) for s in ['+inf', '-inf', 'nan']]
   2035             ['inf', '-inf', 'nan']
   2036         """
   2037         cdef char *s
   2038         cdef int r
   2039         sig_on()
   2040         r = mpfr_asprintf(&s, "%Ra", self.value)
   2041         sig_off()
   2042         if r < 0:  # MPFR free()s its buffer itself in this case
   2043             raise RuntimeError("unable to convert an mpfr number to a string")
   2044         t = str(s)
   2045         mpfr_free_str(s)
   2046         return t
   2047 
-> 2048     def __copy__(self):
        global __copy__ = undefined
        global self = undefined
   2049         """
   2050         Return copy of ``self`` - since ``self`` is immutable, we just return
   2051         ``self`` again.
   2052 
   2053         EXAMPLES::
   2054 
   2055             sage: a = 3.5
   2056             sage: copy(a) is  a
   2057             True
   2058         """
   2059         return self    # since object is immutable.
   2060 
   2061     def _integer_(self, Z=None):
   2062         """
   2063         If this floating-point number is actually an integer, return that

NameError: name '__hex__' is not defined

but it now complains about __exe__????

@fchapoton
Copy link
Contributor Author

comment:3

Well. Could be a circular import problem. Maybe try to apply the changes in

sagemath/sagetrac-mirror@2ffe4e2...public/python3-experiment-8.1.rc0

Could you also please confirm that using the full branch "public/python3-experiment-8.1.rc0" gives you a starting python3-sage ? Nobody else told me that..

@kiwifb
Copy link
Member

kiwifb commented Nov 12, 2017

comment:4

I am a dummy, I just applied the patch but didn't re-compile when it is a .pyx file - I won't do much with my sage-on-gentoo install so close to bed time (local time). I will put testing your branch on my TODO list for tomorrow. I need to convert it into a patch first to use in my own build system.

@fchapoton
Copy link
Contributor Author

comment:5

green bot

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member

kiwifb commented Nov 12, 2017

Reviewer: François Bissey

@kiwifb
Copy link
Member

kiwifb commented Nov 12, 2017

comment:7

What an idiot. I changed the description (in my defence it was empty) instead of commenting. So here is the comment:

Once recompiled things go OK, next problem is in finite_enumerated_sets.py. I see you already have something for that.

And let's put a description.

@kiwifb

This comment has been minimized.

@vbraun
Copy link
Member

vbraun commented Dec 11, 2017

Changed branch from u/chapoton/24201 to 358ef36

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

No branches or pull requests

3 participants