Bzr crashes when running windows native on Cygwin to create a branch
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Confirmed
|
Medium
|
Unassigned |
Bug Description
If I branch from a location to create a new branch using the windows native exe inside a cygwin prompt then bzr displays the following (note if I run inside a DOS prompt it works):
bzr: ERROR: exceptions.
Traceback (most recent call last):
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
File "bzrlib\
TypeError: encode() argument 1 must be string, not None
bzr 0.12.0 on python 2.4.4.final.0 (win32)
This should be pretty easy to fix. The problem is that on Cygwin sys.stdout doesn't seem to be getting a proper encoding value. We have a function that is supposed to be used for this:
osutils. get_terminal_ encoding( )
This patch should fix it:
canceled the request. .encode( sys.stdout. encoding, 'replace') .encode( sys.stdout. encoding, 'replace') get_terminal_ encoding( ) encode( encoding, 'replace')
=== modified file 'bzrlib/ui/text.py'
--- bzrlib/ui/text.py 2006-10-31 01:30:31 +0000
+++ bzrlib/ui/text.py 2006-11-06 17:14:08 +0000
@@ -82,7 +82,10 @@
:return: The password string, return None if the user
"""
- prompt = (prompt % kwargs)
+ # prompt = (prompt % kwargs)
+ encoding = osutils.
+ prompt = (prompt % kwargs)
+ prompt = prompt.
prompt += ': '
# There's currently no way to say 'i decline to enter a password'
# as opposed to 'my password is empty' -- does it matter?
Also, it wouldn't be terribly hard to write a test for this. You just override sys.stdout with a StringIO() object, which doesn't have a .encoding attribute. (Use a try/finally to make sure to restore the original sys.stdout).
Alternatively, you can use the bzrlib. tests.StringIOW rapper( ) which adds a .encoding attribute to StringIO, and set it to None.
Also, we would need to override getpass.getpass() so that we don't actually try to prompt the user on the terminal. We may want to refactor getpass() so that it is called from a member of TextUIFactory, so we can subclass for testing.
Nick: Can you test the patch and see if it works, before we spend too much time writing tests, etc.