Merge lp:~jls-boost/bzr/bug952132 into lp:bzr

Proposed by Scanferlato
Status: Rejected
Rejected by: Martin Packman
Proposed branch: lp:~jls-boost/bzr/bug952132
Merge into: lp:bzr
Diff against target: 89 lines (+34/-10)
2 files modified
bzrlib/win32utils.py (+33/-9)
doc/en/whats-new/whats-new-in-2.5.txt (+1/-1)
To merge this branch: bzr merge lp:~jls-boost/bzr/bug952132
Reviewer Review Type Date Requested Status
Martin Packman (community) Disapprove
Jelmer Vernooij (community) Abstain
Review via email: mp+98827@code.launchpad.net

Description of the change

see comments in file win32utils.py, function get_unicode_argv()

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Abstain
Revision history for this message
Martin Packman (gz) wrote :

Sorry for the delay reviewing this. Basically I don't think the added code complication is worth it for a corner case like this. Instead we probably want to do less magic with the commandline in the first place.

I've pulled out your typo fixes and sent them for merging separately however:

<https://code.launchpad.net/~gz/bzr/2.5_jls-boost_typo_fix/+merge/117156>

review: Disapprove

Unmerged revisions

6512. By Scanferlato

Workaround for bug #952132
(two typos also included)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/win32utils.py'
2--- bzrlib/win32utils.py 2011-12-21 14:17:33 +0000
3+++ bzrlib/win32utils.py 2012-03-22 12:12:20 +0000
4@@ -118,6 +118,11 @@
5 REG_SZ = 1
6 REG_EXPAND_SZ = 2
7
8+# Pythonwin related
9+PYTHONWIN_EXE_NAME = 'Pythonwin.exe'
10+PYTHONWIN_ERROR_MSG = 'Pythonwin started with an incorrect number \
11+of command line arguments.\nPlease see details in bug #952132.'
12+
13
14 def debug_memory_win32api(message='', short=True):
15 """Use trace.note() to dump the running memory info."""
16@@ -515,21 +520,21 @@
17 default.
18 :return: A list of unicode strings.
19 """
20- # First, spit the command line
21+ # First, split the command line
22 s = cmdline.Splitter(command_line, single_quotes_allowed=single_quotes_allowed)
23-
24- # Bug #587868 Now make sure that the length of s agrees with sys.argv
25- # we do this by simply counting the number of arguments in each. The counts should
26- # agree no matter what encoding sys.argv is in (AFAIK)
27- # len(arguments) < len(sys.argv) should be an impossibility since python gets
28+
29+ # Bug #587868 Now make sure that the length of s agrees with sys.argv
30+ # we do this by simply counting the number of arguments in each. The counts should
31+ # agree no matter what encoding sys.argv is in (AFAIK)
32+ # len(arguments) < len(sys.argv) should be an impossibility since python gets
33 # args from the very same PEB as does GetCommandLineW
34 arguments = list(s)
35-
36+
37 # Now shorten the command line we get from GetCommandLineW to match sys.argv
38 if len(arguments) < len(argv):
39 raise AssertionError("Split command line can't be shorter than argv")
40 arguments = arguments[len(arguments) - len(argv):]
41-
42+
43 # Carry on to process globs (metachars) in the command line
44 # expand globs if necessary
45 # TODO: Use 'globbing' instead of 'glob.glob', this gives us stuff like
46@@ -551,10 +556,29 @@
47 command_line = GetCommandLineW()
48 if command_line is None:
49 raise ctypes.WinError()
50+
51+ from bzrlib import trace
52+ trace.mutter('command_line: %s', command_line)
53+
54+ # determine whether bzr is running under Pythonwin
55+ arg_list = command_line.split()
56+ if len(arg_list) > 0:
57+ if arg_list[0].find(PYTHONWIN_EXE_NAME) > 0:
58+ # command_line has the arguments typed on the DOS shell:
59+ # Pythonwin.exe, bzr.py, arg1, arg2, ..., argN
60+ # sys.argv gets arguments from the Run Script dialog box:
61+ # bzr.py, arg1, arg2, ... , argN
62+ # Although bzr uses only the arguments from command_line,
63+ # in both cases the effective number of arguments (N) must
64+ # be the same. The total length of these lists differ by one,
65+ # because command_line has an extra item (Pythonwin.exe).
66+ if (len(arg_list) - 1) != len(sys.argv):
67+ raise AssertionError(PYTHONWIN_ERROR_MSG)
68+
69 # Skip the first argument, since we only care about parameters
70 argv = _command_line_to_argv(command_line, sys.argv)[1:]
71 return argv
72-
73+
74
75 def get_environ_unicode(key, default=None):
76 """Get `key` from environment as unicode or `default` if unset
77
78=== modified file 'doc/en/whats-new/whats-new-in-2.5.txt'
79--- doc/en/whats-new/whats-new-in-2.5.txt 2012-03-09 16:48:55 +0000
80+++ doc/en/whats-new/whats-new-in-2.5.txt 2012-03-22 12:12:20 +0000
81@@ -2,7 +2,7 @@
82 What's New in Bazaar 2.5?
83 *************************
84
85-Bazaar 2.5 bas been released on the 24th of February 2012 and marks the
86+Bazaar 2.5 has been released on the 24th of February 2012 and marks the
87 start of a new long-term-stable series. From here, we will only make bugfix
88 releases on the 2.5 series (2.5.1, etc, and support it until April 2017),
89 while 2.6 will become our new development series.