Merge lp:~glyph/divmod.org/combinator-py3 into lp:divmod.org

Proposed by Glyph Lefkowitz
Status: Merged
Approved by: Glyph Lefkowitz
Approved revision: 2701
Merged at revision: 2708
Proposed branch: lp:~glyph/divmod.org/combinator-py3
Merge into: lp:divmod.org
Diff against target: 134 lines (+16/-17)
3 files modified
Combinator/combinator/branchmgr.py (+14/-14)
Combinator/combinator/xsite.py (+1/-1)
Combinator/sitecustomize.py (+1/-2)
To merge this branch: bzr merge lp:~glyph/divmod.org/combinator-py3
Reviewer Review Type Date Requested Status
Jean-Paul Calderone Approve
Tristan Seligmann Needs Fixing
Review via email: mp+148853@code.launchpad.net

Description of the change

Support enough of python 3 in Combinator so that it doesn't raise an exception when being imported. This is convenient because it allows for Twisted development in a Combinator-managed checkout without having to re-set PYTHONPATH.

To post a comment you must log in.
Revision history for this message
Tristan Seligmann (mithrandi) wrote :

The rest of this looks good to me, but the following code seems problematic:

40 - print 'removing unknown:', unknownFile
41 + print('removing unknown: ' + str(unknownFile))

I'm pretty sure this is going to blow up with some encode or decode error if `unknownFile` contains non-ASCII characters, so not only will Combinator (I guess just chbranch/mkbranch?) explode, but you won't even be able to determine which file is making it explode.

...either that, or the code is already broken, in which case I guess this is a moot point.

review: Needs Fixing
Revision history for this message
Jean-Paul Calderone (exarkun) wrote :

That changed line is also without test coverage. As far as I can tell, it's the *only* uncovered changed line in the branch (it is hard to get coverage reporting on `sitecustomize.py` though).

`unknownFile` is clearly a string. It is less clear whether that is a byte string or a unicode string (on Python 3). But on Python 2 it's clearly a byte string. Exercising that branch on Python 2 should be pretty easy, I'll give it a shot.

Revision history for this message
Jean-Paul Calderone (exarkun) wrote :

See lp:~exarkun/divmod.org/combinator-py3 where I added test coverage for this. Not sure what the proper Launchpad merge proposal etiquette is for this. Please merge my branches into this branch and your branch into trunk?

review: Approve
Revision history for this message
Glyph Lefkowitz (glyph) wrote :

I guess this is approved now?

Revision history for this message
Jean-Paul Calderone (exarkun) wrote :

I guess a reviewer is supposed to submit an "Approve" review and also separately edit the ticket state to be "Approved"?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Combinator/combinator/branchmgr.py'
2--- Combinator/combinator/branchmgr.py 2009-11-25 18:48:46 +0000
3+++ Combinator/combinator/branchmgr.py 2013-02-16 05:53:19 +0000
4@@ -125,11 +125,11 @@
5 display its output.
6 """
7 popenstr = commandString(args)
8- print prompt(popenstr)
9+ print(prompt(popenstr))
10
11 output, code = runCommand(popenstr)
12
13- print 'C: ' + '\nC: '.join(output.splitlines())
14+ print('C: ' + '\nC: '.join(output.splitlines()))
15 return checkStatus(popenstr, output, code)
16
17
18@@ -339,7 +339,7 @@
19 if yth.endswith('.bch'):
20 yth = os.path.join(self.sitePathsPath, yth)
21 projName = os.path.splitext(os.path.split(yth)[-1])[0]
22- branchPath = file(yth).read().strip()
23+ branchPath = open(yth).read().strip()
24 yield projName, branchPath
25
26
27@@ -378,7 +378,7 @@
28
29 def currentBranchFor(self, projectName):
30
31- return file(os.path.join(self.sitePathsPath, projectName)+'.bch'
32+ return open(os.path.join(self.sitePathsPath, projectName)+'.bch'
33 ).read().strip()
34
35
36@@ -506,7 +506,7 @@
37 for line in statusf.splitlines():
38 if line[0] == '?' or line[0] == 'I':
39 unknownFile = line[7:].strip()
40- print 'removing unknown:', unknownFile
41+ print('removing unknown: ' + str(unknownFile))
42 if os.path.isdir(unknownFile):
43 shutil.rmtree(unknownFile)
44 else:
45@@ -518,7 +518,7 @@
46 if not os.path.exists(self.sitePathsPath):
47 os.makedirs(self.sitePathsPath)
48
49- f = file(os.path.join(self.sitePathsPath, projectName) + '.bch', 'w')
50+ f = open(os.path.join(self.sitePathsPath, projectName) + '.bch', 'w')
51 f.write(branchRelativePath)
52 f.close()
53 finally:
54@@ -565,9 +565,9 @@
55 if not os.path.exists(dst):
56 stream.write('link: %r => %r\n <on account of %r>\n' %
57 (dst, src, ent))
58- file(dst, 'w').write(file(src).read())
59+ open(dst, 'w').write(open(src).read())
60 if os.name != 'nt':
61- os.chmod(dst, 0755)
62+ os.chmod(dst, 0o755)
63
64
65
66@@ -623,21 +623,21 @@
67 """
68 try:
69 return operation(*args)
70- except MissingTrunkLocation, e:
71+ except MissingTrunkLocation as e:
72 raise SystemExit(
73 "The location of %r trunk is not known. Specify a URI as the "
74 "3rd argument to check out a branch (check out trunk to make "
75 "this unnecessary)." % e.args)
76- except NonExistentBranch, e:
77+ except NonExistentBranch as e:
78 raise SystemExit(
79 "No such branch: %r" % e.args)
80- except DuplicateBranch, e:
81+ except DuplicateBranch as e:
82 raise SystemExit(
83 "Branch named %r exists already." % e.args)
84 except UncleanTrunkWorkingCopy:
85 raise SystemExit(
86 "Can't unbranch while trunk working copy contains modifications.")
87- except InvalidBranch, e:
88+ except InvalidBranch as e:
89 raise SystemExit("Cannot merge trunk.")
90
91
92@@ -680,10 +680,10 @@
93 for k, v in _combinatorMain(theBranchManager.getCurrentBranches):
94 if whichBranch is not None:
95 if k == whichBranch:
96- print v
97+ print(v)
98 break
99 else:
100- print k + ":", v
101+ print(k + ": " + v)
102
103
104
105
106=== modified file 'Combinator/combinator/xsite.py'
107--- Combinator/combinator/xsite.py 2009-03-31 19:25:11 +0000
108+++ Combinator/combinator/xsite.py 2013-02-16 05:53:19 +0000
109@@ -67,7 +67,7 @@
110 if line.startswith("#"):
111 continue
112 if line.startswith("import"):
113- exec line
114+ exec(line)
115 continue
116 line = line.rstrip()
117 dir, dircase = makepath(sitedir, line)
118
119=== modified file 'Combinator/sitecustomize.py'
120--- Combinator/sitecustomize.py 2009-03-28 18:35:36 +0000
121+++ Combinator/sitecustomize.py 2013-02-16 05:53:19 +0000
122@@ -1,11 +1,10 @@
123
124 import sys
125-import os
126
127 from combinator.branchmgr import theBranchManager
128 theBranchManager.addPaths()
129
130-for key in sys.modules.keys():
131+for key in list(sys.modules.keys()):
132 # Unload all Combinator modules that had to be loaded in order to call
133 # addPaths(). Although the very very beginning of this script needs to
134 # load the trunk combinator (or whichever one your shell points at), once

Subscribers

People subscribed via source and target branches

to all changes: