#15995: Python 3 preparation: Adapt to the changed integer division semantics (/
vs. //)
--------------------------------+------------------------
       Reporter:  wluebbe       |        Owner:
           Type:  enhancement   |       Status:  new
       Priority:  major         |    Milestone:  sage-6.2
      Component:  distribution  |   Resolution:
       Keywords:  python3       |    Merged in:
        Authors:                |    Reviewers:
Report Upstream:  N/A           |  Work issues:
         Branch:                |       Commit:
   Dependencies:                |     Stopgaps:
--------------------------------+------------------------

Comment (by wluebbe):

 The first attempt went like this: {{{futurize -w -f division
 src/}}}.[[br]]
 This added {{{from __future__ import division}}} to 411 py modules. [[br]]
 Running the doctests {{{./sage -t -p --all}}} gave billions of lines of
 doctest failures ... - I had to cancel the run. [[br]]
 But this result should not have come as a surprise because I had not fixed
 anything yet ...

 The task is to identify those {{{/}}} and {{{/=}}} that operate solely on
 ints and longs and then change them to {{{//}}} and {{{//=}}}.

 The Python source distribution has a script {{{Tools/scripts/finddiv.py}}}
 which has identified similar 416 py modules as the above programs (it
 performs clearly better as a simple grep since it tokenizes the code). It
 also outputs those 2625 lines that contain the / and /= operators - but
 for **all** types of operands (the analysis is purely syntactical).

 There is another script {{{Tools/scripts/fixdiv.py}}} that uses the output
 of [[br]]
 {{{python -Qwarnall yourscripts 2>the-warnings}}} to create a simple
 (commented) patch file for those division operators that only deal with
 ints and longs. This is possible since it uses the type information
 obtained by running the Python programs.
 This should be much more useful!

 But currently I am stuck:
 * I don't know how to pass the option {{{-Qwarnall}}} to the Python
 interpreter when running the doctests
 * and the warning output screws up the doctests.
 It may be possible to use the {{{warnings}}} module to write the warnings
 to a file instead if stderr (by replacing {{{warnings.showwarning()}}}
 with a custom function).

--
Ticket URL: <http://trac.sagemath.org/ticket/15995#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to