Commits

Anonymous committed 9747b0d

Convert to Python 3.x division rules.

Comments (0)

Files changed (15)

QMTest/TestCmd.py

 # PARTICULAR PURPOSE.  THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS,
 # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+from __future__ import division
 
 __author__ = "Steven Knight <knight at baldmt dot com>"
 __revision__ = "TestCmd.py 0.37.D001 2010/01/11 16:55:50 knight"

QMTest/TestSCons.py

 """
 
 # __COPYRIGHT__
+from __future__ import division
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 StatList = [
     Stat('memory-initial', 'kbytes',
          r'Memory before reading SConscript files:\s+(\d+)',
-         convert=lambda s: int(s) / 1024),
+         convert=lambda s: int(s) // 1024),
     Stat('memory-prebuild', 'kbytes',
          r'Memory before building targets:\s+(\d+)',
-         convert=lambda s: int(s) / 1024),
+         convert=lambda s: int(s) // 1024),
     Stat('memory-final', 'kbytes',
          r'Memory after building targets:\s+(\d+)',
-         convert=lambda s: int(s) / 1024),
+         convert=lambda s: int(s) // 1024),
 
     Stat('time-sconscript', 'seconds',
          r'Total SConscript file execution time:\s+([\d.]+) seconds'),

QMTest/scons_tdb.py

 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
+from __future__ import division
 
 """
 QMTest classes to support SCons' testing and Aegis-inspired workflow.
 #
 # This will allow (as much as possible) us to time just the code itself,
 # not Python function call overhead.
+from __future__ import division
 
 import getopt
 import sys
 program without arguments.  The baseline overhead differs between
 Python versions!
 """
+from __future__ import division
 
 try:
     import gc
 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+from __future__ import division
 
 import optparse
 import os
                 good = 0
                 for v in vm.groups():
                     var, value = v.split('=', 1)
-                    value = int((int(value) * opts.max) / elapsed)
+                    value = int((int(value) * opts.max) // elapsed)
                     os.environ[var] = str(value)
             run += 1
 
 # in each category, the number of non-blank lines, and the number of
 # non-comment lines.  The last figure (non-comment) lines is the most
 # interesting one for most purposes.
+from __future__ import division
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 

bin/svn-bisect.py

 #!/usr/bin/env python
 # -*- Python -*-
+from __future__ import division
 
 import sys
 from math import log, ceil
 while upper-lower > 1:
     print msg % (ceil(log(upper-lower,2)), lower, upper)
 
-    mid = int((lower + upper)/2)
+    mid = (lower + upper)//2
     midfails = testfail(mid)
     if midfails == lowerfails:
         lower = mid

src/engine/SCons/Defaults.py

 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #
+from __future__ import division
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 
-
 import os
-import os.path
 import errno
 import shutil
 import stat
         self.variable = variable
         self.method = method
     def __call__(self, *args, **kw):
-        try: 1/0
+        try: 1//0
         except ZeroDivisionError: 
             # Don't start iterating with the current stack-frame to
             # prevent creating reference cycles (f_back is safe).

src/engine/SCons/Node/FSTests.py

 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #
+from __future__ import division
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
             # We round down the current time to the nearest even integer
             # value, subtract two to make sure the timestamp is not "now,"
             # and then convert it back to a float.
-            tstamp = float(int(time.time() / 2) * 2) - 2
+            tstamp = float(int(time.time() // 2) * 2) - 2.0
             os.utime(test.workpath("tstamp"), (tstamp - 2.0, tstamp))
             f = fs.File("tstamp")
             t = f.get_timestamp()
         f2 = test.workpath('tdir2', 'file2')
         test.write(f1, 'file1\n')
         test.write(f2, 'file2\n')
-        current_time = float(int(time.time() / 2) * 2)
+        current_time = float(int(time.time() // 2) * 2)
         t1 = current_time - 4.0
         t2 = current_time - 2.0
         os.utime(f1, (t1 - 2.0, t1))
             # We round down the current time to the nearest even integer
             # value, subtract two to make sure the timestamp is not "now,"
             # and then convert it back to a float.
-            tstamp = float(int(time.time() / 2) * 2) - 2
+            tstamp = float(int(time.time() // 2) * 2) - 2.0
             os.utime(test.workpath("rep2", "tstamp"), (tstamp - 2.0, tstamp))
             f = fs.File("tstamp")
             t = f.get_timestamp()

src/engine/SCons/Script/SConscript.py

 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+from __future__ import division
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 def get_calling_namespaces():
     """Return the locals and globals for the function that called
     into this module in the current call stack."""
-    try: 1/0
+    try: 1//0
     except ZeroDivisionError: 
         # Don't start iterating with the current stack-frame to
         # prevent creating reference cycles (f_back is safe).

src/engine/SCons/TaskmasterTests.py

 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #
+from __future__ import division
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
         t.exception_set(3)
         assert t.exception == 3
 
-        try: 1/0
+        try: 1//0
         except: pass
         t.exception_set(None)
         exc_type, exc_value, exc_tb = t.exception
             pass
 
         try:
-            1/0
+            1//0
         except:
             tb = sys.exc_info()[2]
         t.exception_set((Exception3, "arg", tb))

src/engine/SCons/Tool/intelc.py

 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
+from __future__ import division
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
     m = re.match(r'([0-9]+)\.([0-9]+)\.([0-9]+)', vstr)
     if m:
         vmaj,vmin,build = m.groups()
-        return float(vmaj) * 10 + float(vmin) + float(build) / 1000.;
+        return float(vmaj) * 10. + float(vmin) + float(build) / 1000.;
     else:
         f = float(vstr)
         if is_windows:

src/script/scons-time.py

 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
+from __future__ import division
 from __future__ import nested_scopes
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
         between 5 and 9 horizontal lines on the graph, on some set of
         boundaries that are multiples of 10/100/1000/etc.
         """
-        i = largest / 5
+        i = largest // 5
         if not i:
             return largest
         multiplier = 1
         while i >= 10:
-            i = i / 10
+            i = i // 10
             multiplier = multiplier * 10
         return i * multiplier
 
         # Round up to next integer.
         largest = int(largest) + 1
         increment = self.increment_size(largest)
-        return ((largest + increment - 1) / increment) * increment
+        return ((largest + increment - 1) // increment) * increment
 
 class Line:
     def __init__(self, points, type, title, label, comment, fmt="%s %s"):

test/option/debug-time.py

 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
+from __future__ import division
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"