duplicity-talk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Duplicity-talk] Duplicity 0.6.19: help to pipe problem


From: Дмитрий Че рняк
Subject: [Duplicity-talk] Duplicity 0.6.19: help to pipe problem
Date: Sun, 09 Sep 2012 20:26:03 +0400
User-agent: Roundcube Webmail/0.5.3

Hi, All!

When duplicity invoked as

duplicity --help >somefile

or, in my actual case:

duplicity --help|grep -q -- --name

The error will be generated:

address@hidden:~/test$ duplicity --help >a
Traceback (most recent call last):
  File "/usr/bin/duplicity", line 1391, in <module>
    with_tempdir(main)
  File "/usr/bin/duplicity", line 1384, in with_tempdir
    fn()
  File "/usr/bin/duplicity", line 1235, in main
    action = "" />  File "/usr/lib/python2.6/dist-packages/duplicity/commandline.py", line 970, in ProcessCommandLine
    args = parse_cmdline_options(cmdline_list)
  File "/usr/lib/python2.6/dist-packages/duplicity/commandline.py", line 534, in parse_cmdline_options
    (options, args) = parser.parse_args()
  File "/usr/lib/python2.6/optparse.py", line 1394, in parse_args
    stop = self._process_args(largs, rargs, values)
  File "/usr/lib/python2.6/optparse.py", line 1434, in _process_args
    self._process_long_opt(rargs, values)
  File "/usr/lib/python2.6/optparse.py", line 1509, in _process_long_opt
    option.process(opt, value, values, self)
  File "/usr/lib/python2.6/optparse.py", line 788, in process
    self.action, self.dest, opt, value, values, parser)
  File "/usr/lib/python2.6/dist-packages/duplicity/commandline.py", line 170, in take_action
    self, action, dest, opt, value, values, parser)
  File "/usr/lib/python2.6/optparse.py", line 810, in take_action
    parser.print_help()
  File "/usr/lib/python2.6/dist-packages/duplicity/commandline.py", line 197, in print_help
    file.write(self.format_help().decode('utf-8').encode(encoding, "replace"))
TypeError: encode() argument 1 must be string, not None

The problem is in commandline.py line 187:

encoding = getattr(file, "encoding", "UTF-8")
return encoding

Actually there should be:

if encoding: return encoding
return "UTF-8"

It is because the third argument of getattr will be substituted only when requested attribute not exists at all.

But, i suspect, there actually is the file.encoding attribute with the value of None.

Here is the patch:

=============================================

--- commandline.py      2012-09-09 20:15:10.230192530 +0400
+++ commandline.py.new  2012-09-09 20:16:25.029191293 +0400
@@ -185,7 +185,8 @@
         which is default encoding in python3 and most recent unixes
         """
         encoding = getattr(file, "encoding", "UTF-8")
-        return encoding
+        if encoding: return encoding
+        return "UTF-8"
 
     def print_help(self, file=None):
         """
==============================================

 

---
WBR, Dmitry.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]