mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
Merged revisions 75061-75062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r75061 | benjamin.peterson | 2009-09-25 15:34:04 -0500 (Fri, 25 Sep 2009) | 1 line fix print statement ........ r75062 | benjamin.peterson | 2009-09-25 15:56:52 -0500 (Fri, 25 Sep 2009) | 2 lines correct the fixpath.py script to work in Python 3 #6999 ........
This commit is contained in:
parent
ae1b4d2d1a
commit
0e33da095f
2 changed files with 13 additions and 12 deletions
|
@ -64,7 +64,7 @@ class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool):
|
||||||
print(line)
|
print(line)
|
||||||
|
|
||||||
def warn(msg):
|
def warn(msg):
|
||||||
print >> sys.stderr, "WARNING: %s" % (msg,)
|
print("WARNING: %s" % (msg,), file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def main(fixer_pkg, args=None):
|
def main(fixer_pkg, args=None):
|
||||||
|
@ -159,8 +159,8 @@ def main(fixer_pkg, args=None):
|
||||||
options.processes)
|
options.processes)
|
||||||
except refactor.MultiprocessingUnsupported:
|
except refactor.MultiprocessingUnsupported:
|
||||||
assert options.processes > 1
|
assert options.processes > 1
|
||||||
print >> sys.stderr, "Sorry, -j isn't " \
|
print("Sorry, -j isn't supported on this platform.",
|
||||||
"supported on this platform."
|
file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
rt.summarize()
|
rt.summarize()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#! /usr/bin/env python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
# Change the #! line occurring in Python scripts. The new interpreter
|
# Change the #! line occurring in Python scripts. The new interpreter
|
||||||
# pathname must be given with a -i option.
|
# pathname must be given with a -i option.
|
||||||
|
@ -43,8 +43,9 @@ def main():
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o == '-i':
|
if o == '-i':
|
||||||
new_interpreter = a
|
new_interpreter = a.encode()
|
||||||
if not new_interpreter or new_interpreter[0] != '/' or not args:
|
if not new_interpreter or not new_interpreter.startswith(b'/') or \
|
||||||
|
not args:
|
||||||
err('-i option or file-or-directory missing\n')
|
err('-i option or file-or-directory missing\n')
|
||||||
err(usage)
|
err(usage)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
@ -61,7 +62,7 @@ def main():
|
||||||
|
|
||||||
ispythonprog = re.compile('^[a-zA-Z0-9_]+\.py$')
|
ispythonprog = re.compile('^[a-zA-Z0-9_]+\.py$')
|
||||||
def ispython(name):
|
def ispython(name):
|
||||||
return ispythonprog.match(name) >= 0
|
return bool(ispythonprog.match(name))
|
||||||
|
|
||||||
def recursedown(dirname):
|
def recursedown(dirname):
|
||||||
dbg('recursedown(%r)\n' % (dirname,))
|
dbg('recursedown(%r)\n' % (dirname,))
|
||||||
|
@ -88,7 +89,7 @@ def recursedown(dirname):
|
||||||
def fix(filename):
|
def fix(filename):
|
||||||
## dbg('fix(%r)\n' % (filename,))
|
## dbg('fix(%r)\n' % (filename,))
|
||||||
try:
|
try:
|
||||||
f = open(filename, 'r')
|
f = open(filename, 'rb')
|
||||||
except IOError as msg:
|
except IOError as msg:
|
||||||
err('%s: cannot open: %r\n' % (filename, msg))
|
err('%s: cannot open: %r\n' % (filename, msg))
|
||||||
return 1
|
return 1
|
||||||
|
@ -101,7 +102,7 @@ def fix(filename):
|
||||||
head, tail = os.path.split(filename)
|
head, tail = os.path.split(filename)
|
||||||
tempname = os.path.join(head, '@' + tail)
|
tempname = os.path.join(head, '@' + tail)
|
||||||
try:
|
try:
|
||||||
g = open(tempname, 'w')
|
g = open(tempname, 'wb')
|
||||||
except IOError as msg:
|
except IOError as msg:
|
||||||
f.close()
|
f.close()
|
||||||
err('%s: cannot create: %r\n' % (tempname, msg))
|
err('%s: cannot create: %r\n' % (tempname, msg))
|
||||||
|
@ -139,11 +140,11 @@ def fix(filename):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def fixline(line):
|
def fixline(line):
|
||||||
if not line.startswith('#!'):
|
if not line.startswith(b'#!'):
|
||||||
return line
|
return line
|
||||||
if "python" not in line:
|
if b"python" not in line:
|
||||||
return line
|
return line
|
||||||
return '#! %s\n' % new_interpreter
|
return b'#! ' + new_interpreter + b'\n'
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue