#26390 closed enhancement (fixed)

py3: some changes in misc

Reported by: chapoton Owned by:
Priority: major Milestone: sage-8.4
Component: python3 Keywords:
Cc: embray Merged in:
Authors: Erik Bray, Frédéric Chapoton Reviewers: Vincent Klein
Report Upstream: N/A Work issues:
Branch: a7fcc75 (Commits) Commit: a7fcc750ff28571d138ece4aeae18e6986f36921
Dependencies: Stopgaps:

Description (last modified by chapoton)

extracted from #26321

Change History (12)

comment:1 Changed 14 months ago by chapoton

  • Branch set to public/26390
  • Commit set to a7fcc750ff28571d138ece4aeae18e6986f36921
  • Description modified (diff)
  • Status changed from new to needs_review

New commits:

a7fcc75various py3 changes in misc

comment:2 Changed 14 months ago by vklein

  • Owner changed from (none) to vklein

comment:3 Changed 14 months ago by vklein

-        sage: g = mypartial(f, 2, 3)
+        sage: g = mypartial(f, 2, 3)  # py2; on Python 3 this is an error
         Traceback (most recent call last):
         ...
         DeprecationWarning: object.__init__() takes no parameters

Why not testing the error case with py3 ? And if it is not worth it why keeping the test in py2 ?

comment:4 Changed 14 months ago by chapoton

one should ask @embray, author of this

comment:5 Changed 14 months ago by embray

Because it's checking behavior that is no longer applicable on Python 3.

comment:6 follow-up: Changed 14 months ago by vklein

Ok.

I am also surprised by a doctests behaviour.

When i see this

sage: sage_input(long(-5), verify=True)  # py2
# Verified
-long(5)
sage: sage_input(long(-7), preparse=False, verify=True)
# Verified
-7L
sage: sage_input(long(11), preparse=None, verify=True)  # py2
# Verified
long(11)

i expect the second test to fail in python3 but it doesn't whith a sage -t --long src/sage/misc/sage_input.py, what is the trick ?

comment:7 Changed 14 months ago by vklein

  • Owner changed from vklein to (none)
  • Reviewers set to Vincent Klein

I am ok with this ticket, i will set it to positive review after green bot.

comment:8 in reply to: ↑ 6 Changed 14 months ago by embray

Replying to vklein:

i expect the second test to fail in python3 but it doesn't whith a sage -t --long src/sage/misc/sage_input.py, what is the trick ?

There are some tricks in the doctest parser for massaging differences between Python 2 and 3 w.r.t. to the Python 2 long type. For example, the L-suffix is just ignored on Python 3 as long as the preceding numerals are the same.

But I don't think the Sage pre-parser will take long(1) and output long(1) on Python 3. So there are a few exceptions. But the majority of long-related tests work on Python 3.

comment:9 Changed 14 months ago by vklein

Ok, thank you for clarifying that.

comment:10 Changed 14 months ago by vklein

  • Status changed from needs_review to positive_review

comment:11 Changed 14 months ago by vklein

  • Authors set to Erik Bray, Frédéric Chapoton

comment:12 Changed 14 months ago by vbraun

  • Branch changed from public/26390 to a7fcc750ff28571d138ece4aeae18e6986f36921
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.