From ff1e0daf2a45e999c113f3aeb3e6938613c48e8f Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Fri, 20 Sep 2024 08:12:42 +0200 Subject: [PATCH] remove leftover python2 "print"s --- doc/listings/copyable-receive.py | 6 +++--- doc/listings/copyable-send.py | 2 +- doc/listings/pb2client.py | 12 ++++++------ doc/listings/pb2server.py | 2 +- doc/listings/pb3calculator.py | 2 +- doc/listings/pb3user.py | 6 +++--- misc/run-deprecations.py | 8 ++++---- src/foolscap/appserver/cli.py | 1 - src/foolscap/appserver/client.py | 1 - src/foolscap/appserver/server.py | 1 - src/foolscap/appserver/services.py | 1 - src/foolscap/banana.py | 1 - src/foolscap/broker.py | 1 - src/foolscap/logging/cli.py | 1 - src/foolscap/logging/dumper.py | 1 - src/foolscap/logging/filter.py | 1 - src/foolscap/logging/gatherer.py | 1 - src/foolscap/logging/incident.py | 1 - src/foolscap/logging/log.py | 1 - src/foolscap/logging/publish.py | 1 - src/foolscap/logging/tail.py | 1 - src/foolscap/logging/web.py | 1 - src/foolscap/negotiate.py | 1 - src/foolscap/referenceable.py | 1 - src/foolscap/slicers/list.py | 1 - src/foolscap/slicers/root.py | 1 - src/foolscap/slicers/set.py | 1 - src/foolscap/slicers/tuple.py | 1 - src/foolscap/test/apphelper.py | 1 - src/foolscap/test/bench_banana.py | 1 - src/foolscap/test/check-connections-client.py | 1 - src/foolscap/test/check-connections-server.py | 2 -- src/foolscap/test/common.py | 1 - src/foolscap/test/test__versions.py | 1 - src/foolscap/test/test_banana.py | 1 - src/foolscap/test/test_copyable.py | 1 - src/foolscap/test/test_gifts.py | 1 - src/foolscap/test/test_interfaces.py | 1 - src/foolscap/test/test_pb.py | 1 - src/foolscap/test/test_tub.py | 1 - 40 files changed, 19 insertions(+), 53 deletions(-) diff --git a/doc/listings/copyable-receive.py b/doc/listings/copyable-receive.py index 335168b9..3f5899c8 100644 --- a/doc/listings/copyable-receive.py +++ b/doc/listings/copyable-receive.py @@ -18,9 +18,9 @@ def setCopyableState(self, d): self.shoe_size = "they wouldn't tell us" def display(self): - print "Name:", self.name - print "Age:", self.age - print "Shoe Size:", self.shoe_size + print("Name:", self.name) + print("Age:", self.age) + print("Shoe Size:", self.shoe_size) def getRecord(rref, name): d = rref.callRemote("getuser", name=name) diff --git a/doc/listings/copyable-send.py b/doc/listings/copyable-send.py index 9c32bd6f..1fc182b5 100644 --- a/doc/listings/copyable-send.py +++ b/doc/listings/copyable-send.py @@ -37,6 +37,6 @@ def remote_getuser(self, name): tub.listenOn("tcp:12345") tub.setLocation("localhost:12345") url = tub.registerReference(db, "database") -print "the database is at:", url +print("the database is at:", url) tub.startService() reactor.run() diff --git a/doc/listings/pb2client.py b/doc/listings/pb2client.py index e6067f64..b9b3306f 100644 --- a/doc/listings/pb2client.py +++ b/doc/listings/pb2client.py @@ -5,25 +5,25 @@ from foolscap.api import Tub def gotError1(why): - print "unable to get the RemoteReference:", why + print("unable to get the RemoteReference:", why) reactor.stop() def gotError2(why): - print "unable to invoke the remote method:", why + print("unable to invoke the remote method:", why) reactor.stop() def gotReference(remote): - print "got a RemoteReference" - print "asking it to add 1+2" + print("got a RemoteReference") + print("asking it to add 1+2") d = remote.callRemote("add", a=1, b=2) d.addCallbacks(gotAnswer, gotError2) def gotAnswer(answer): - print "the answer is", answer + print("the answer is", answer) reactor.stop() if len(sys.argv) < 2: - print "Usage: pb2client.py URL" + print("Usage: pb2client.py URL") sys.exit(1) url = sys.argv[1] tub = Tub() diff --git a/doc/listings/pb2server.py b/doc/listings/pb2server.py index 1c9f471d..19b1828b 100644 --- a/doc/listings/pb2server.py +++ b/doc/listings/pb2server.py @@ -14,7 +14,7 @@ def remote_subtract(self, a, b): tub.listenOn("tcp:12345") tub.setLocation("localhost:12345") url = tub.registerReference(myserver, "math-service") -print "the object is available at:", url +print("the object is available at:", url) tub.startService() reactor.run() diff --git a/doc/listings/pb3calculator.py b/doc/listings/pb3calculator.py index df419312..57645a8b 100644 --- a/doc/listings/pb3calculator.py +++ b/doc/listings/pb3calculator.py @@ -35,7 +35,7 @@ def remote_pop(self): tub.listenOn("tcp:12345") tub.setLocation("localhost:12345") url = tub.registerReference(Calculator(), "calculator") -print "the object is available at:", url +print("the object is available at:", url) application = service.Application("pb2calculator") tub.setServiceParent(application) diff --git a/doc/listings/pb3user.py b/doc/listings/pb3user.py index 2b053232..7ff1e44b 100644 --- a/doc/listings/pb3user.py +++ b/doc/listings/pb3user.py @@ -6,12 +6,12 @@ class Observer(Referenceable): def remote_event(self, msg): - print "event:", msg + print("event:", msg) def printResult(number): - print "the result is", number + print("the result is", number) def gotError(err): - print "got an error:", err + print("got an error:", err) def gotRemote(remote): o = Observer() d = remote.callRemote("addObserver", observer=o) diff --git a/misc/run-deprecations.py b/misc/run-deprecations.py index 49b69861..8cfaf14e 100644 --- a/misc/run-deprecations.py +++ b/misc/run-deprecations.py @@ -51,7 +51,7 @@ def run_command(main): pw = os.environ.get("PYTHONWARNINGS") DDW = "default::DeprecationWarning" if pw != DDW: - print "note: $PYTHONWARNINGS is '%s', not the expected %s" % (pw, DDW) + print("note: $PYTHONWARNINGS is '%s', not the expected %s" % (pw, DDW)) sys.stdout.flush() pp = RunPP() @@ -84,11 +84,11 @@ def add(line): if warnings: if config["warnings"]: with open(config["warnings"], "wb") as f: - print >>f, "".join(warnings) - print "ERROR: %d deprecation warnings found" % len(warnings) + print("".join(warnings), flush=True) + print("ERROR: %d deprecation warnings found" % len(warnings)) sys.exit(1) - print "no deprecation warnings" + print("no deprecation warnings") if signal: sys.exit(signal) sys.exit(rc) diff --git a/src/foolscap/appserver/cli.py b/src/foolscap/appserver/cli.py index 7a327566..719056d5 100644 --- a/src/foolscap/appserver/cli.py +++ b/src/foolscap/appserver/cli.py @@ -1,4 +1,3 @@ -from __future__ import print_function, unicode_literals import six, os, sys, shutil, errno, time, signal from io import StringIO from twisted.python import usage diff --git a/src/foolscap/appserver/client.py b/src/foolscap/appserver/client.py index 71a7a53a..1feeb491 100644 --- a/src/foolscap/appserver/client.py +++ b/src/foolscap/appserver/client.py @@ -1,4 +1,3 @@ -from __future__ import print_function, unicode_literals import six import os, sys from io import BytesIO diff --git a/src/foolscap/appserver/server.py b/src/foolscap/appserver/server.py index 4e40fe0b..5d90ecaa 100644 --- a/src/foolscap/appserver/server.py +++ b/src/foolscap/appserver/server.py @@ -1,4 +1,3 @@ -from __future__ import print_function, unicode_literals import os, sys, json, ast import six from twisted.application import service diff --git a/src/foolscap/appserver/services.py b/src/foolscap/appserver/services.py index eaf092dc..1838bf41 100644 --- a/src/foolscap/appserver/services.py +++ b/src/foolscap/appserver/services.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals import os import six from twisted.python import usage, runtime, filepath, log diff --git a/src/foolscap/banana.py b/src/foolscap/banana.py index cd1864c4..133b9ace 100644 --- a/src/foolscap/banana.py +++ b/src/foolscap/banana.py @@ -1,4 +1,3 @@ -from __future__ import print_function import six import struct, time diff --git a/src/foolscap/broker.py b/src/foolscap/broker.py index d540e4ed..6b23b8d4 100644 --- a/src/foolscap/broker.py +++ b/src/foolscap/broker.py @@ -2,7 +2,6 @@ # This module is responsible for the per-connection Broker object -from __future__ import print_function import six import types, time from itertools import count diff --git a/src/foolscap/logging/cli.py b/src/foolscap/logging/cli.py index 2e6bc14b..4b8f2ae2 100644 --- a/src/foolscap/logging/cli.py +++ b/src/foolscap/logging/cli.py @@ -1,4 +1,3 @@ -from __future__ import print_function import sys from io import StringIO from twisted.python import usage diff --git a/src/foolscap/logging/dumper.py b/src/foolscap/logging/dumper.py index b9f7248b..d7eff53b 100644 --- a/src/foolscap/logging/dumper.py +++ b/src/foolscap/logging/dumper.py @@ -1,4 +1,3 @@ -from __future__ import print_function, unicode_literals import six, sys, errno, textwrap from twisted.python import usage from foolscap.logging import flogfile diff --git a/src/foolscap/logging/filter.py b/src/foolscap/logging/filter.py index 76a0d821..69c5de77 100644 --- a/src/foolscap/logging/filter.py +++ b/src/foolscap/logging/filter.py @@ -1,4 +1,3 @@ -from __future__ import print_function import six from twisted.python import usage import sys, os, bz2, time diff --git a/src/foolscap/logging/gatherer.py b/src/foolscap/logging/gatherer.py index ed507ba0..28898df0 100644 --- a/src/foolscap/logging/gatherer.py +++ b/src/foolscap/logging/gatherer.py @@ -1,4 +1,3 @@ -from __future__ import print_function, unicode_literals import six, os, sys, time, bz2 signal = None try: diff --git a/src/foolscap/logging/incident.py b/src/foolscap/logging/incident.py index de4d1814..502d5b3e 100644 --- a/src/foolscap/logging/incident.py +++ b/src/foolscap/logging/incident.py @@ -1,4 +1,3 @@ -from __future__ import print_function import six import sys, os.path, time, bz2 import json diff --git a/src/foolscap/logging/log.py b/src/foolscap/logging/log.py index 14b73e57..d0d18548 100644 --- a/src/foolscap/logging/log.py +++ b/src/foolscap/logging/log.py @@ -1,4 +1,3 @@ -from __future__ import print_function import os, sys, time, weakref, binascii import traceback import collections diff --git a/src/foolscap/logging/publish.py b/src/foolscap/logging/publish.py index 35416812..a09d54ec 100644 --- a/src/foolscap/logging/publish.py +++ b/src/foolscap/logging/publish.py @@ -1,4 +1,3 @@ -from __future__ import print_function import os from collections import deque import six diff --git a/src/foolscap/logging/tail.py b/src/foolscap/logging/tail.py index 5c13c61b..4af072ae 100644 --- a/src/foolscap/logging/tail.py +++ b/src/foolscap/logging/tail.py @@ -1,4 +1,3 @@ -from __future__ import print_function, unicode_literals import six, os, sys, time from zope.interface import implementer from twisted.internet import reactor diff --git a/src/foolscap/logging/web.py b/src/foolscap/logging/web.py index 8c601744..d239f461 100644 --- a/src/foolscap/logging/web.py +++ b/src/foolscap/logging/web.py @@ -1,4 +1,3 @@ -from __future__ import print_function import time import six from six.moves.urllib.parse import quote diff --git a/src/foolscap/negotiate.py b/src/foolscap/negotiate.py index 2cbaa5dd..c05b0f01 100644 --- a/src/foolscap/negotiate.py +++ b/src/foolscap/negotiate.py @@ -1,6 +1,5 @@ # -*- test-case-name: foolscap.test.test_negotiate -*- -from __future__ import print_function import time import six from twisted.python.failure import Failure diff --git a/src/foolscap/referenceable.py b/src/foolscap/referenceable.py index 5ec793e1..70902195 100644 --- a/src/foolscap/referenceable.py +++ b/src/foolscap/referenceable.py @@ -4,7 +4,6 @@ # Referenceable (callable) objects. All details of actually invoking methods # live in call.py -from __future__ import print_function import weakref from functools import total_ordering import six diff --git a/src/foolscap/slicers/list.py b/src/foolscap/slicers/list.py index 04d7eec2..644bdd59 100644 --- a/src/foolscap/slicers/list.py +++ b/src/foolscap/slicers/list.py @@ -1,6 +1,5 @@ # -*- test-case-name: foolscap.test.test_banana -*- -from __future__ import print_function from twisted.python import log from twisted.internet.defer import Deferred from foolscap.tokens import Violation diff --git a/src/foolscap/slicers/root.py b/src/foolscap/slicers/root.py index 3d37a27e..fa5415cd 100644 --- a/src/foolscap/slicers/root.py +++ b/src/foolscap/slicers/root.py @@ -1,6 +1,5 @@ # -*- test-case-name: foolscap.test.test_banana -*- -from __future__ import print_function import six from zope.interface import implementer from twisted.internet.defer import Deferred diff --git a/src/foolscap/slicers/set.py b/src/foolscap/slicers/set.py index f23c351a..0f6228af 100644 --- a/src/foolscap/slicers/set.py +++ b/src/foolscap/slicers/set.py @@ -1,6 +1,5 @@ # -*- test-case-name: foolscap.test.test_banana -*- -from __future__ import print_function from twisted.internet import defer from twisted.python import log from foolscap.slicers.list import ListSlicer diff --git a/src/foolscap/slicers/tuple.py b/src/foolscap/slicers/tuple.py index 0ac4eafd..3ba83f46 100644 --- a/src/foolscap/slicers/tuple.py +++ b/src/foolscap/slicers/tuple.py @@ -1,6 +1,5 @@ # -*- test-case-name: foolscap.test.test_banana -*- -from __future__ import print_function from twisted.internet.defer import Deferred from foolscap.tokens import Violation from foolscap.slicer import BaseUnslicer diff --git a/src/foolscap/test/apphelper.py b/src/foolscap/test/apphelper.py index c8f89d0b..f0e14fd9 100644 --- a/src/foolscap/test/apphelper.py +++ b/src/foolscap/test/apphelper.py @@ -5,7 +5,6 @@ script lets the test work on windows too. """ -from __future__ import unicode_literals import sys, os.path import six diff --git a/src/foolscap/test/bench_banana.py b/src/foolscap/test/bench_banana.py index 380b9d17..75ace0cb 100644 --- a/src/foolscap/test/bench_banana.py +++ b/src/foolscap/test/bench_banana.py @@ -1,4 +1,3 @@ -from __future__ import print_function import io from foolscap import storage diff --git a/src/foolscap/test/check-connections-client.py b/src/foolscap/test/check-connections-client.py index 45478097..c6079ab4 100644 --- a/src/foolscap/test/check-connections-client.py +++ b/src/foolscap/test/check-connections-client.py @@ -1,5 +1,4 @@ #! /usr/bin/python -from __future__ import print_function # This is the client side of a manual test for the socks/tor # connection-handler code. To use it, first set up the server as described in diff --git a/src/foolscap/test/check-connections-server.py b/src/foolscap/test/check-connections-server.py index 827378b4..87108575 100644 --- a/src/foolscap/test/check-connections-server.py +++ b/src/foolscap/test/check-connections-server.py @@ -1,7 +1,5 @@ #! /usr/bin/python -from __future__ import print_function - # This is the server side of a manual test for the socks/tor # connection-handler code. On the server host, configure Tor to route a # hidden service to our port with something like: diff --git a/src/foolscap/test/common.py b/src/foolscap/test/common.py index 98bac6ad..e6e5699d 100644 --- a/src/foolscap/test/common.py +++ b/src/foolscap/test/common.py @@ -1,6 +1,5 @@ # -*- test-case-name: foolscap.test.test_pb -*- -from __future__ import print_function import six import time from zope.interface import implementer, implementer_only, implementedBy, Interface diff --git a/src/foolscap/test/test__versions.py b/src/foolscap/test/test__versions.py index 4925eb84..361c10a6 100644 --- a/src/foolscap/test/test__versions.py +++ b/src/foolscap/test/test__versions.py @@ -1,4 +1,3 @@ -from __future__ import print_function from twisted.trial import unittest import time import platform diff --git a/src/foolscap/test/test_banana.py b/src/foolscap/test/test_banana.py index 2933dd63..c3fa8601 100644 --- a/src/foolscap/test/test_banana.py +++ b/src/foolscap/test/test_banana.py @@ -1,4 +1,3 @@ -from __future__ import print_function import six import os import os.path diff --git a/src/foolscap/test/test_copyable.py b/src/foolscap/test/test_copyable.py index 911fef9b..9ac11ae5 100644 --- a/src/foolscap/test/test_copyable.py +++ b/src/foolscap/test/test_copyable.py @@ -1,4 +1,3 @@ -from __future__ import print_function import six from twisted.trial import unittest from twisted.python import components, failure, reflect diff --git a/src/foolscap/test/test_gifts.py b/src/foolscap/test/test_gifts.py index c602116f..4a3df0fd 100644 --- a/src/foolscap/test/test_gifts.py +++ b/src/foolscap/test/test_gifts.py @@ -1,4 +1,3 @@ -from __future__ import print_function from zope.interface import implementer from twisted.trial import unittest from twisted.internet import defer, protocol, reactor diff --git a/src/foolscap/test/test_interfaces.py b/src/foolscap/test/test_interfaces.py index fdc3fa1c..91364c2a 100644 --- a/src/foolscap/test/test_interfaces.py +++ b/src/foolscap/test/test_interfaces.py @@ -1,6 +1,5 @@ # -*- test-case-name: foolscap.test.test_interfaces -*- -from __future__ import print_function from zope.interface import implementer_only from twisted.trial import unittest diff --git a/src/foolscap/test/test_pb.py b/src/foolscap/test/test_pb.py index 0e8d7c9e..4a83701c 100644 --- a/src/foolscap/test/test_pb.py +++ b/src/foolscap/test/test_pb.py @@ -1,6 +1,5 @@ # -*- test-case-name: foolscap.test.test_pb -*- -from __future__ import print_function import re if False: diff --git a/src/foolscap/test/test_tub.py b/src/foolscap/test/test_tub.py index f20b7d3c..fc90ccac 100644 --- a/src/foolscap/test/test_tub.py +++ b/src/foolscap/test/test_tub.py @@ -1,6 +1,5 @@ # -*- test-case-name: foolscap.test.test_tub -*- -from __future__ import print_function import os.path import os from twisted.trial import unittest