Skip to content

Commit 6b59847

Browse files
print_function in xlib
1 parent ae4a61a commit 6b59847

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

scrapy/xlib/lsprofcalltree.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Jp Calderone & Itamar Shtull-Trauring
44
# Johan Dahlin
55

6+
from __future__ import print_function
67
import optparse
78
import os
89
import sys
@@ -27,7 +28,7 @@ def __init__(self, profiler):
2728

2829
def output(self, out_file):
2930
self.out_file = out_file
30-
print >> out_file, 'events: Ticks'
31+
print('events: Ticks', file=out_file)
3132
self._print_summary()
3233
for entry in self.data:
3334
self._entry(entry)
@@ -37,24 +38,24 @@ def _print_summary(self):
3738
for entry in self.data:
3839
totaltime = int(entry.totaltime * 1000)
3940
max_cost = max(max_cost, totaltime)
40-
print >> self.out_file, 'summary: %d' % (max_cost,)
41+
print('summary: %d' % (max_cost,), file=self.out_file)
4142

4243
def _entry(self, entry):
4344
out_file = self.out_file
4445

4546
code = entry.code
4647
#print >> out_file, 'ob=%s' % (code.co_filename,)
4748
if isinstance(code, str):
48-
print >> out_file, 'fi=~'
49+
print('fi=~', file=out_file)
4950
else:
50-
print >> out_file, 'fi=%s' % (code.co_filename,)
51-
print >> out_file, 'fn=%s' % (label(code),)
51+
print('fi=%s' % (code.co_filename,), file=out_file)
52+
print('fn=%s' % (label(code),), file=out_file)
5253

5354
inlinetime = int(entry.inlinetime * 1000)
5455
if isinstance(code, str):
55-
print >> out_file, '0 ', inlinetime
56+
print('0 ', inlinetime, file=out_file)
5657
else:
57-
print >> out_file, '%d %d' % (code.co_firstlineno, inlinetime)
58+
print('%d %d' % (code.co_firstlineno, inlinetime), file=out_file)
5859

5960
# recursive calls are counted in entry.calls
6061
if entry.calls:
@@ -69,23 +70,23 @@ def _entry(self, entry):
6970

7071
for subentry in calls:
7172
self._subentry(lineno, subentry)
72-
print >> out_file
73+
print(file=out_file)
7374

7475
def _subentry(self, lineno, subentry):
7576
out_file = self.out_file
7677
code = subentry.code
7778
#print >> out_file, 'cob=%s' % (code.co_filename,)
78-
print >> out_file, 'cfn=%s' % (label(code),)
79+
print('cfn=%s' % (label(code),), file=out_file)
7980
if isinstance(code, str):
80-
print >> out_file, 'cfi=~'
81-
print >> out_file, 'calls=%d 0' % (subentry.callcount,)
81+
print('cfi=~', file=out_file)
82+
print('calls=%d 0' % (subentry.callcount,), file=out_file)
8283
else:
83-
print >> out_file, 'cfi=%s' % (code.co_filename,)
84-
print >> out_file, 'calls=%d %d' % (
85-
subentry.callcount, code.co_firstlineno)
84+
print('cfi=%s' % (code.co_filename,), file=out_file)
85+
print('calls=%d %d' % (
86+
subentry.callcount, code.co_firstlineno), file=out_file)
8687

8788
totaltime = int(subentry.totaltime * 1000)
88-
print >> out_file, '%d %d' % (lineno, totaltime)
89+
print('%d %d' % (lineno, totaltime), file=out_file)
8990

9091
def main(args):
9192
usage = "%s [-o output_file_path] scriptfile [arg] ..."

scrapy/xlib/pydispatch/saferef.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Refactored "safe reference" from dispatcher.py"""
2+
from __future__ import print_function
23
import weakref, traceback
34

45
def safeRef(target, onDelete = None):

0 commit comments

Comments
 (0)