Ticket #5689: classic-division.patch

File classic-division.patch, 18.7 KB (added by Vladimir Perić, 5 years ago)
  • twisted/conch/ssh/connection.py

    diff --git twisted/conch/ssh/connection.py twisted/conch/ssh/connection.py
    index 53c9cf7..2527199 100644
    class SSHConnection(service.SSHService): 
    235235            #packet = packet[:channel.localWindowLeft+4]
    236236        data = common.getNS(packet[4:])[0]
    237237        channel.localWindowLeft -= dataLength
    238         if channel.localWindowLeft < channel.localWindowSize / 2:
     238        if channel.localWindowLeft < channel.localWindowSize // 2:
    239239            self.adjustWindow(channel, channel.localWindowSize - \
    240240                                       channel.localWindowLeft)
    241241            #log.msg('local window left: %s/%s' % (channel.localWindowLeft,
    class SSHConnection(service.SSHService): 
    264264            return
    265265        data = common.getNS(packet[8:])[0]
    266266        channel.localWindowLeft -= dataLength
    267         if channel.localWindowLeft < channel.localWindowSize / 2:
     267        if channel.localWindowLeft < channel.localWindowSize // 2:
    268268            self.adjustWindow(channel, channel.localWindowSize -
    269269                                       channel.localWindowLeft)
    270270        log.callWithLogger(channel, channel.extReceived, typeCode, data)
  • twisted/conch/test/test_manhole.py

    diff --git twisted/conch/test/test_manhole.py twisted/conch/test/test_manhole.py
    index 3b31984..09dd52c 100644
    def determineDefaultFunctionName(): 
    2222    compiled from interactive input or at the top-level of modules.
    2323    """
    2424    try:
    25         1 / 0
     25        1 // 0
    2626    except:
    2727        # The last frame is this function.  The second to last frame is this
    2828        # function's caller, which is module-scope, which is what we want,
  • twisted/internet/test/test_posixbase.py

    diff --git twisted/internet/test/test_posixbase.py twisted/internet/test/test_posixbase.py
    index 1d6c72c..2e0c2ec 100644
    class TCPPortTests(TestCase): 
    188188        """
    189189        port = Port(12345, ServerFactory())
    190190        port.connected = True
    191         port.connectionLost = lambda reason: 1 / 0
     191        port.connectionLost = lambda reason: 1 // 0
    192192        return self.assertFailure(port.stopListening(), ZeroDivisionError)
    193193
    194194
  • twisted/mail/imap4.py

    diff --git twisted/mail/imap4.py twisted/mail/imap4.py
    index 6ca8384..1284f50 100644
    class IMAP4Server(basic.LineReceiver, policies.TimeoutMixin): 
    19191919                sign = "+"
    19201920            else:
    19211921                sign = "-"
    1922             odate = odate + sign + str(((abs(ttup[9]) / 3600) * 100 + (abs(ttup[9]) % 3600) / 60)).zfill(4)
     1922            odate = odate + sign + str(((abs(ttup[9]) // 3600) * 100 + (abs(ttup[9]) % 3600) // 60)).zfill(4)
    19231923        _w('INTERNALDATE ' + _quote(odate))
    19241924
    19251925    def spew_rfc822header(self, id, msg, _w=None, _f=None):
  • twisted/mail/smtp.py

    diff --git twisted/mail/smtp.py twisted/mail/smtp.py
    index d872111..3b8bd0a 100644
    def rfc822date(timeinfo=None,local=1): 
    289289
    290290        (tzhr, tzmin) = divmod(abs(tz), 3600)
    291291        if tz:
    292             tzhr *= int(abs(tz)/tz)
     292            tzhr *= int(abs(tz)//tz)
    293293        (tzmin, tzsec) = divmod(tzmin, 60)
    294294    else:
    295295        (tzhr, tzmin) = (0,0)
  • twisted/python/test/test_release.py

    diff --git twisted/python/test/test_release.py twisted/python/test/test_release.py
    index 55f360e..d5bf1d5 100644
    class UtilityTest(TestCase): 
    476476        def chAndBreak():
    477477            os.mkdir('releaseCh')
    478478            os.chdir('releaseCh')
    479             1/0
     479            1//0
    480480        self.assertRaises(ZeroDivisionError,
    481481                          release.runChdirSafe, chAndBreak)
    482482        self.assertEqual(cwd, os.getcwd())
  • twisted/test/generator_failure_tests.py

    diff --git twisted/test/generator_failure_tests.py twisted/test/generator_failure_tests.py
    index dcc6d42..be1344f 100644
     
    44"""
    55Python 2.5+ test cases for failures thrown into generators.
    66"""
     7from __future__ import division
    78
    89import sys
    910import traceback
  • twisted/test/reflect_helper_ZDE.py

    diff --git twisted/test/reflect_helper_ZDE.py twisted/test/reflect_helper_ZDE.py
    index bd05fbc..0c53583 100644
     
    11
    22# Helper module for a test_reflect test
    33
    4 1/0
     41//0
  • twisted/test/test_amp.py

    diff --git twisted/test/test_amp.py twisted/test/test_amp.py
    index 1f4c369..325af40 100644
    class CommandDispatchTests(unittest.TestCase): 
    655655        self.sender.expectError()
    656656
    657657        callResult = self.dispatcher.callRemote(Hello, hello='world')
    658         callResult.addCallback(lambda result: 1 / 0)
     658        callResult.addCallback(lambda result: 1 // 0)
    659659
    660660        self.dispatcher.ampBoxReceived(amp.AmpBox({
    661661                    'hello': "yay", 'print': "ignored", '_answer': "1"}))
    class CommandDispatchTests(unittest.TestCase): 
    671671        self.sender.expectError()
    672672
    673673        callResult = self.dispatcher.callRemote(Hello, hello='world')
    674         callResult.addErrback(lambda result: 1 / 0)
     674        callResult.addErrback(lambda result: 1 // 0)
    675675
    676676        self.dispatcher.ampBoxReceived(amp.AmpBox({
    677677                    '_error': '1', '_error_code': 'bugs',
  • twisted/test/test_application.py

    diff --git twisted/test/test_application.py twisted/test/test_application.py
    index 7736c5b..e1ac29f 100644
    class TestInternet2(unittest.TestCase): 
    476476
    477477    def testBrokenTimer(self):
    478478        d = defer.Deferred()
    479         t = internet.TimerService(1, lambda: 1 / 0)
     479        t = internet.TimerService(1, lambda: 1 // 0)
    480480        oldFailed = t._failed
    481481        def _failed(why):
    482482            oldFailed(why)
  • twisted/test/test_banana.py

    diff --git twisted/test/test_banana.py twisted/test/test_banana.py
    index 88ad2e6..c4b69de 100644
    class BananaTestCase(unittest.TestCase): 
    111111        self.enc.sendEncoded(smallest)
    112112        encoded = self.io.getvalue()
    113113        self.io.truncate(0)
    114         self.enc.setPrefixLimit(self.enc.prefixLimit / 2)
     114        self.enc.setPrefixLimit(self.enc.prefixLimit // 2)
    115115
    116116        self.assertRaises(banana.BananaError, self.enc.dataReceived, encoded)
    117117
    class BananaTestCase(unittest.TestCase): 
    139139        self.enc.sendEncoded(largest)
    140140        encoded = self.io.getvalue()
    141141        self.io.truncate(0)
    142         self.enc.setPrefixLimit(self.enc.prefixLimit / 2)
     142        self.enc.setPrefixLimit(self.enc.prefixLimit // 2)
    143143
    144144        self.assertRaises(banana.BananaError, self.enc.dataReceived, encoded)
    145145
  • twisted/test/test_defer.py

    diff --git twisted/test/test_defer.py twisted/test/test_defer.py
    index f6f1596..1b11346 100644
    class DeferredTestCase(unittest.TestCase): 
    240240
    241241    def testCallbackErrors(self):
    242242        l = []
    243         d = defer.Deferred().addCallback(lambda _: 1 / 0).addErrback(l.append)
     243        d = defer.Deferred().addCallback(lambda _: 1 // 0).addErrback(l.append)
    244244        d.callback(1)
    245245        self.assert_(isinstance(l[0].value, ZeroDivisionError))
    246246        l = []
    class FirstErrorTests(unittest.TestCase): 
    10981098        compare equal to instances of other types.
    10991099        """
    11001100        try:
    1101             1 / 0
     1101            1 // 0
    11021102        except:
    11031103            firstFailure = failure.Failure()
    11041104
    class LogTestCase(unittest.TestCase): 
    15651565        and its final result (the one not handled by any callback) is an
    15661566        exception, that exception will be logged immediately.
    15671567        """
    1568         defer.Deferred().addCallback(lambda x: 1 / 0).callback(1)
     1568        defer.Deferred().addCallback(lambda x: 1 // 0).callback(1)
    15691569        gc.collect()
    15701570        self._check()
    15711571
    class LogTestCase(unittest.TestCase): 
    15751575        """
    15761576        def _subErrorLogWithInnerFrameRef():
    15771577            d = defer.Deferred()
    1578             d.addCallback(lambda x: 1 / 0)
     1578            d.addCallback(lambda x: 1 // 0)
    15791579            d.callback(1)
    15801580
    15811581        _subErrorLogWithInnerFrameRef()
    class LogTestCase(unittest.TestCase): 
    15881588        """
    15891589        def _subErrorLogWithInnerFrameCycle():
    15901590            d = defer.Deferred()
    1591             d.addCallback(lambda x, d=d: 1 / 0)
     1591            d.addCallback(lambda x, d=d: 1 // 0)
    15921592            d._d = d
    15931593            d.callback(1)
    15941594
  • twisted/test/test_defgen.py

    diff --git twisted/test/test_defgen.py twisted/test/test_defgen.py
    index 1d1ef1c..1ccd8e4 100644
    class DeferredGeneratorTests(BaseDefgenTests, unittest.TestCase): 
    115115
    116116    def _genBuggy(self):
    117117        yield waitForDeferred(getThing())
    118         1/0
     118        1//0
    119119    _genBuggy = deferredGenerator(_genBuggy)
    120120
    121121
  • twisted/test/test_failure.py

    diff --git twisted/test/test_failure.py twisted/test/test_failure.py
    index 8a3670e..3963f8c 100644
     
    44"""
    55Test cases for failure module.
    66"""
     7from __future__ import division
    78
    89import re
    910import sys
  • twisted/test/test_log.py

    diff --git twisted/test/test_log.py twisted/test/test_log.py
    index 86f03d5..7fe05df 100644
    class LogTest(unittest.TestCase): 
    8383        L1 = []
    8484        L2 = []
    8585        def broken(events):
    86             1 / 0
     86            1 // 0
    8787
    8888        for observer in [L1.append, broken, L2.append]:
    8989            log.addObserver(observer)
    class FakeFile(list): 
    258258
    259259class EvilStr:
    260260    def __str__(self):
    261         1/0
     261        1//0
    262262
    263263class EvilRepr:
    264264    def __str__(self):
    265265        return "Happy Evil Repr"
    266266    def __repr__(self):
    267         1/0
     267        1//0
    268268
    269269class EvilReprStr(EvilStr, EvilRepr):
    270270    pass
  • twisted/test/test_protocols.py

    diff --git twisted/test/test_protocols.py twisted/test/test_protocols.py
    index 0e03ad9..db12d3c 100644
    a''' 
    232232            t = proto_helpers.StringIOWithoutClosing()
    233233            a = LineTester()
    234234            a.makeConnection(protocol.FileWrapper(t))
    235             for i in range(len(self.buffer)/packet_size + 1):
     235            for i in range(len(self.buffer) // packet_size + 1):
    236236                s = self.buffer[i*packet_size:(i+1)*packet_size]
    237237                a.dataReceived(s)
    238238            self.assertEqual(self.output, a.received)
    a''' 
    254254            clock = task.Clock()
    255255            a = LineTester(clock)
    256256            a.makeConnection(protocol.FileWrapper(t))
    257             for i in range(len(self.pause_buf)/packet_size + 1):
     257            for i in range(len(self.pause_buf) // packet_size + 1):
    258258                s = self.pause_buf[i*packet_size:(i+1)*packet_size]
    259259                a.dataReceived(s)
    260260            self.assertEqual(self.pause_output1, a.received)
    a''' 
    277277            clock = task.Clock()
    278278            a = LineTester(clock)
    279279            a.makeConnection(protocol.FileWrapper(t))
    280             for i in range(len(self.rawpause_buf)/packet_size + 1):
     280            for i in range(len(self.rawpause_buf) // packet_size + 1):
    281281                s = self.rawpause_buf[i*packet_size:(i+1)*packet_size]
    282282                a.dataReceived(s)
    283283            self.assertEqual(self.rawpause_output1, a.received)
    a''' 
    297297            t = proto_helpers.StringIOWithoutClosing()
    298298            a = LineTester()
    299299            a.makeConnection(protocol.FileWrapper(t))
    300             for i in range(len(self.stop_buf)/packet_size + 1):
     300            for i in range(len(self.stop_buf) // packet_size + 1):
    301301                s = self.stop_buf[i*packet_size:(i+1)*packet_size]
    302302                a.dataReceived(s)
    303303            self.assertEqual(self.stop_output, a.received)
    class NetstringReceiverTestCase(unittest.TestCase, LPTestCaseMixin): 
    455455            for s in self.strings:
    456456                a.sendString(s)
    457457            out = t.value()
    458             for i in range(len(out)/packet_size + 1):
     458            for i in range(len(out) // packet_size + 1):
    459459                s = out[i*packet_size:(i+1)*packet_size]
    460460                if s:
    461461                    a.dataReceived(s)
  • twisted/test/test_threads.py

    diff --git twisted/test/test_threads.py twisted/test/test_threads.py
    index e1ddd82..0b218a3 100644
    class DeferredResultTestCase(unittest.TestCase): 
    275275        # alas, this test appears to flunk the default reactor too
    276276
    277277        d = threads.deferToThread(lambda: None)
    278         d.addCallback(lambda ign: threads.deferToThread(lambda: 1/0))
     278        d.addCallback(lambda ign: threads.deferToThread(lambda: 1//0))
    279279        return self.assertFailure(d, ZeroDivisionError)
    280280
    281281
  • twisted/trial/test/erroneous.py

    diff --git twisted/trial/test/erroneous.py twisted/trial/test/erroneous.py
    index e1fd21c..f66f4d4 100644
     
    11# -*- test-case-name: twisted.trial.test.test_tests -*-
    22# Copyright (c) Twisted Matrix Laboratories.
    33# See LICENSE for details.
     4from __future__ import division
    45
    56from twisted.trial import unittest, util
    67from twisted.internet import reactor, protocol, defer
  • twisted/trial/test/mockdoctest.py

    diff --git twisted/trial/test/mockdoctest.py twisted/trial/test/mockdoctest.py
    index 6d5bce7..85beadd 100644
     
    33
    44# this module is a trivial class with doctests and a __test__ attribute
    55# to test trial's doctest support with python2.4
    6 
     6from __future__ import division
    77
    88class Counter(object):
    99    """a simple counter object for testing trial's doctest support
  • twisted/trial/test/test_assertions.py

    diff --git twisted/trial/test/test_assertions.py twisted/trial/test/test_assertions.py
    index c720a64..b7847ff 100644
     
    44"""
    55Tests for assertions provided by L{twisted.trial.unittest.TestCase}.
    66"""
     7from __future__ import division
    78
    89import warnings
    910from pprint import pformat
  • twisted/trial/test/test_log.py

    diff --git twisted/trial/test/test_log.py twisted/trial/test/test_log.py
    index 7afdcdf..a137a9f 100644
     
    44"""
    55Test the interaction between trial and errors logged during test run.
    66"""
     7from __future__ import division
    78
    89import time
    910
  • twisted/trial/test/test_pyunitcompat.py

    diff --git twisted/trial/test/test_pyunitcompat.py twisted/trial/test/test_pyunitcompat.py
    index 72e7f11..7b85154 100644
     
    22# See LICENSE for details.
    33#
    44# Maintainer: Jonathan Lange
    5 
     5from __future__ import division
    66
    77import sys
    88import traceback
  • twisted/trial/test/test_reporter.py

    diff --git twisted/trial/test/test_reporter.py twisted/trial/test/test_reporter.py
    index 9c5af7b..89f446a 100644
     
    66"""
    77Tests for L{twisted.trial.reporter}.
    88"""
    9 
     9from __future__ import division
    1010
    1111import errno, sys, os, re, StringIO
    1212from inspect import getmro
  • twisted/trial/test/weird.py

    diff --git twisted/trial/test/weird.py twisted/trial/test/weird.py
    index e35526d..3533f56 100644
     
     1from __future__ import division
     2
    13from twisted.trial import unittest
    24from twisted.internet import defer
    35
  • twisted/web/static.py

    diff --git twisted/web/static.py twisted/web/static.py
    index 3992ac8..3474f2d 100644
     
    55"""
    66Static resources for L{twisted.web}.
    77"""
     8from __future__ import division
    89
    910import os
    1011import warnings
  • twisted/web/test/test_template.py

    diff --git twisted/web/test/test_template.py twisted/web/test/test_template.py
    index 2e2ab94..b29303b 100644
    class FailingElement(Element): 
    656656    def render(self, request):
    657657        a = 42
    658658        b = 0
    659         return a / b
     659        return a // b
    660660
    661661
    662662
  • twisted/web/test/test_webclient.py

    diff --git twisted/web/test/test_webclient.py twisted/web/test/test_webclient.py
    index 1841402..7291c6e 100644
    class FileBodyProducerTests(unittest.TestCase): 
    12151215        producer = FileBodyProducer(
    12161216            StringIO(expectedResult), self.cooperator, readSize)
    12171217        complete = producer.startProducing(consumer)
    1218         for i in range(len(expectedResult) / readSize + 1):
     1218        for i in range(len(expectedResult) // readSize + 1):
    12191219            self._scheduled.pop(0)()
    12201220        self.assertEqual([], self._scheduled)
    12211221        self.assertEqual(expectedResult, output.getvalue())
    class FileBodyProducerTests(unittest.TestCase): 
    12331233        producer = FileBodyProducer(inputFile, self.cooperator, readSize)
    12341234        consumer = FileConsumer(StringIO())
    12351235        producer.startProducing(consumer)
    1236         for i in range(len(inputBytes) / readSize + 2):
     1236        for i in range(len(inputBytes) // readSize + 2):
    12371237            self._scheduled.pop(0)()
    12381238        self.assertTrue(inputFile.closed)
    12391239
  • twisted/web/test/test_xml.py

    diff --git twisted/web/test/test_xml.py twisted/web/test/test_xml.py
    index 365e101..513a943 100644
    alert("I hate you"); 
    543543            '\x80\x95\xb6[\xea0\xb90\xc80 \x00<\x00/\x00T\x00I\x00T\x00L\x00E'
    544544            '\x00>\x00<\x00/\x00J\x00A\x00P\x00A\x00N\x00E\x00S\x00E\x00>\x00')
    545545        def reverseBytes(s):
    546             fmt = str(len(s) / 2) + 'H'
     546            fmt = str(len(s) // 2) + 'H'
    547547            return struct.pack('<' + fmt, *struct.unpack('>' + fmt, s))
    548548        urd = microdom.parseString(reverseBytes(s.encode('UTF-16')))
    549549        ud = microdom.parseString(s.encode('UTF-16'))
  • twisted/web/twcgi.py

    diff --git twisted/web/twcgi.py twisted/web/twcgi.py
    index b1f001a..dca2bb7 100644
    class CGIProcessProtocol(protocol.ProcessProtocol, pb.Viewable): 
    254254                headerend, delimiter = headerEnds[0]
    255255                self.headertext = text[:headerend]
    256256                # This is a final version of the header text.
    257                 linebreak = delimiter[:len(delimiter)/2]
     257                linebreak = delimiter[:len(delimiter)//2]
    258258                headers = self.headertext.split(linebreak)
    259259                for header in headers:
    260260                    br = header.find(': ')
  • twisted/words/test/test_irc.py

    diff --git twisted/words/test/test_irc.py twisted/words/test/test_irc.py
    index 46af3c7..ffda689 100644
    class ClientMsgTests(unittest.TestCase): 
    15761576        """
    15771577        message = 'o' * (irc.MAX_COMMAND_LENGTH - 2)
    15781578        self.assertLongMessageSplitting(
    1579             message, 3, length=irc.MAX_COMMAND_LENGTH / 2)
     1579            message, 3, length=irc.MAX_COMMAND_LENGTH // 2)
    15801580
    15811581
    15821582    def test_newlinesBeforeLineBreaking(self):