Opened 4 years ago

Closed 3 years ago

#19735 closed enhancement (fixed)

Upgrade to Python 2.7.12

Reported by: slelievre Owned by:
Priority: critical Milestone: sage-7.5
Component: packages: standard Keywords:
Cc: dimpase, fbissey, leif, vbraun, wluebbe Merged in:
Authors: François Bissey Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: 85e931b (Commits) Commit: 85e931baf9d76af3b4f011d6b499227b6dd4aea7
Dependencies: Stopgaps:

Description (last modified by jdemeyer)

Tarball: https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz

Since Python 2.7.13 has issues with __new__, I postpone that to #22037.

Change History (19)

comment:1 Changed 4 years ago by fbissey

Breaks timeit because of https://bugs.python.org/issue5633 more precisely this commit https://hg.python.org/cpython/rev/14d1018940cb.

That's the kind of problems

sage: from sage.misc.sage_timeit import sage_timeit
sage: sage_timeit('3^100000', globals(), preparse=True, number=50)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-2-e93b8105f8e1> in <module>()
----> 1 sage_timeit('3^100000', globals(), preparse=True, number=Integer(50))

/home/frb15/gentoo/usr/lib/python2.7/site-packages/sage/misc/sage_timeit.pyc in sage_timeit(stmt, globals_dict, preparse, number, repeat, precision, seconds)
   218     # to the shell namespace?
   219 
--> 220     src = timeit_.template % {'stmt': timeit_.reindent(stmt, 8), 'setup': "pass"}
   221     code = compile(src, "<magic-timeit>", "exec")
   222     ns = {}

KeyError: ‘init’

Every single doctest relying on timeit breaks. From what I can see from the commit adding 'init': '' to the timeit_.template call may be enough. I haven't tested this yet.

comment:2 Changed 3 years ago by slelievre

  • Description modified (diff)
  • Summary changed from upgrade Python to 2.7.11 to Upgrade to Python 2.7.12

comment:3 Changed 3 years ago by dimpase

what is the plan? this ticket seems to be important for Sage support on OSX 10.12 (aka Sierra), see #21567

comment:4 Changed 3 years ago by fbissey

Haven't tested yet, I have a feeling we'll have to fix the timeit template as I mentioned 9 months ago. I wouldn't think that problem would go away.

comment:5 Changed 3 years ago by jdemeyer

  • Dependencies set to #21552

comment:6 Changed 3 years ago by fbissey

Gentoo has stabilized 2.7.12 so now I have a few doctests failures because of it.

--- src.orig/sage/misc/sage_timeit.py	2016-11-30 14:54:28.076049582 +1300
+++ src/sage/misc/sage_timeit.py	2016-11-30 15:01:53.256127012 +1300
@@ -218,7 +218,7 @@
     # to the shell namespace?
 
     src = timeit_.template % {'stmt': timeit_.reindent(stmt, 8),
-                             'setup': "pass"}
+                             'setup': "pass", 'init' : ''}
     code = compile(src, "<magic-timeit>", "exec")
     ns = {}
     if not globals_dict:

fixed most of them, but I still have

sage -t --long /usr/lib64/python2.7/site-packages/sage/combinat/words/word.py
**********************************************************************
File "/usr/lib64/python2.7/site-packages/sage/combinat/words/word.py", line 511, in sage.combinat.words.word.InfiniteWord_iter_with_caching
Failed example:
    dumps(w)
Expected:
    Traceback (most recent call last):
    ...
    PicklingError: Can't pickle <type 'generator'>: attribute lookup __builtin__.generator failed
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 501, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/usr/lib64/python2.7/site-packages/sage/doctest/forker.py", line 864, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.combinat.words.word.InfiniteWord_iter_with_caching[9]>", line 1, in <module>
        dumps(w)
      File "sage/structure/sage_object.pyx", line 1116, in sage.structure.sage_object.dumps (/scratch2/portage/sci-mathematics/sage-9999/work/sage-9999/src-python2_7/build/cythonized/sage/structure/sage_object.c:13886)
        return comp.compress(cPickle.dumps(obj, protocol=2))
    TypeError: can't pickle generator objects

in quadruple. At least, one doctest is currently in the don't know the cause of failure basket.

comment:7 Changed 3 years ago by jdemeyer

  • Description modified (diff)
  • Milestone changed from sage-7.0 to sage-7.5
  • Priority changed from major to critical

comment:8 Changed 3 years ago by jdemeyer

  • Dependencies #21552 deleted

comment:9 Changed 3 years ago by thansen

It looks like just the error message of the expected error changed. So it's just a matter of updating the doctest, no?

comment:10 Changed 3 years ago by fbissey

Yes just the error message of the doctest but don't forget to adjust sage_timeit.py. We have also been discussing inclusion of https://bugs.python.org/issue1222585 in another ticket. Do you also use it in debian? We do in Gentoo.

comment:11 Changed 3 years ago by fbissey

I am putting a branch together now.

comment:12 Changed 3 years ago by fbissey

At least one of the patches has actually been upstreamed, removing...

comment:13 follow-up: Changed 3 years ago by thansen

I didn't find a reference to #1222585 in the python Debian package.

comment:14 in reply to: ↑ 13 Changed 3 years ago by fbissey

Replying to thansen:

I didn't find a reference to #1222585 in the python Debian package.

I guess one of the person pushing was a Gentoo dev. It is useful and the correct thing to do but the impact is probably invisible on a full GNU system.

comment:15 Changed 3 years ago by fbissey

The tinfo.patch which looks like is cygwin stuff needs work or possibly removal.

comment:16 Changed 3 years ago by fbissey

xcode stuff added, will be trivial to regenerate the patch.

comment:17 Changed 3 years ago by fbissey

  • Authors set to François Bissey
  • Branch set to u/fbissey/python2.7.12
  • Commit set to 85e931baf9d76af3b4f011d6b499227b6dd4aea7
  • Status changed from new to needs_review

OK, I think the new tinfo.patch is correct as the migration was trivial. I also had to fix uuid-issue_11063.patch and it is a bit less trivial there, so whoever thought we need that should look at it. I didn't include the distutils_c++ patch as it should really be done to python2 and python3 and we probably want to limit the changes done in this ticket.


New commits:

c35ea3cUpgrade python2 to 2.7.12 and update tinfo and uuid patches
85e931bfix sage_timeit and word.py for python 2.7.12

comment:18 Changed 3 years ago by vbraun

  • Reviewers set to Volker Braun
  • Status changed from needs_review to positive_review

comment:19 Changed 3 years ago by vbraun

  • Branch changed from u/fbissey/python2.7.12 to 85e931baf9d76af3b4f011d6b499227b6dd4aea7
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.