#734 closed defect (invalid)

Tahoe CLI with unicode patches applied fails when stdout is redirected

Reported by: francois Owned by: francois
Priority: major Milestone: 1.7.0
Component: code-frontend-cli Version: 1.4.1
Keywords: i18n unicode Cc:
Launchpad Bug:

Description

Andrej Falout reported this bug on the mailing-list.

http://allmydata.org/pipermail/tahoe-dev/2009-June/001969.html

andrej@polar:/usr/src/tahoe/darcs/09-06-11_19-00/tahoe> tahoe ls
--node-directory='/home/andrej/.tahoe-allmydata.com/' tahoe:'/' > /dev/null
Traceback (most recent call last):
  File "/usr/src/tahoe/darcs/09-06-11_19-00/tahoe/support/bin/tahoe", line 8, in <module>
    load_entry_point('allmydata-tahoe==1.4.1-r3926', 'console_scripts', 'tahoe')()
  File "/usr/src/tahoe/darcs/09-06-11_19-00/tahoe/src/allmydata/scripts/runner.py", line 91, in run
    rc = runner(sys.argv[1:])
  File "/usr/src/tahoe/darcs/09-06-11_19-00/tahoe/src/allmydata/scripts/runner.py", line 78, in runner
    rc = cli.dispatch[command](so)
  File "/usr/src/tahoe/darcs/09-06-11_19-00/tahoe/src/allmydata/scripts/cli.py", line 385, in list
    rc = tahoe_ls.list(options)
  File "/usr/src/tahoe/darcs/09-06-11_19-00/tahoe/src/allmydata/scripts/tahoe_ls.py", line 125, in list
    line.append(unicode_to_stdout(name) + classify)
  File "/usr/src/tahoe/darcs/09-06-11_19-00/tahoe/src/allmydata/util/stringutils.py", line 70, in unicode_to_stdout
    return s.encode(sys.stdout.encoding, 'replace')
TypeError: encode() argument 1 must be string, not None
andrej@polar:/usr/src/tahoe/darcs/09-06-11_19-00/tahoe> tahoe --version
allmydata-tahoe: 1.4.1-r3926, foolscap: 0.4.1, pycryptopp: 0.5.12, zfec:
1.4.4, Twisted: 8.2.0, Nevow: 0.9.32, zope.interface: 3.5.0, python: 2.6.0,
platform: Linux-SuSE_11.1-x86_64-64bit_ELF, sqlite: 3.6.4, simplejson:
2.0.7, argparse: 0.8.0, pyOpenSSL: 0.7, pyutil: 1.3.30, zbase32: 1.1.1,
setuptools: 0.6c12dev, pysqlite: 2.4.1
andrej@polar:/usr/src/tahoe/darcs/09-06-11_19-00/tahoe>

Change History (10)

comment:1 Changed at 2009-06-12T08:38:17Z by francois

  • Owner set to francois

comment:2 Changed at 2009-06-12T08:38:20Z by francois

  • Status changed from new to assigned

comment:3 Changed at 2009-06-30T17:53:46Z by zooko

  • Milestone changed from 1.5.0 to eventually

comment:4 Changed at 2009-11-23T02:23:36Z by davidsarah

  • Keywords i18n added

comment:5 Changed at 2009-11-23T03:20:11Z by davidsarah

  • Keywords unicode added

comment:6 Changed at 2009-12-07T03:57:55Z by davidsarah

Possible fix (untested) in ticket:534#comment:79.

comment:7 Changed at 2010-02-02T00:19:14Z by davidsarah

  • Milestone changed from eventually to 1.7.0

Should be same milestone as #534.

comment:8 Changed at 2010-04-24T04:48:56Z by zooko

To test this we can mock out {{sys.stdout}}} to have None for its encoding attribute.

By the way, do we know if having the encoding be None is intended behavior by Python? (It seems like it probably is.)

comment:9 Changed at 2010-05-11T16:04:35Z by zooko

I really want to see this patch in trunk in the next 48 hours for Tahoe-LAFS v1.7, but I can't contribute to it myself right now.

comment:10 Changed at 2010-05-11T19:35:22Z by davidsarah

  • Resolution set to invalid
  • Status changed from assigned to closed

The patches in #534 to which this ticket applied are probably not now going to be committed; they have been superceded by francois' later patches. I'll take into account the possibility of sys.stdout.encoding being None when reviewing the latter.

Note: See TracTickets for help on using tickets.