@@ -148,16 +148,15 @@ def __call__(self, argument_parser, completer=None, always_complete_options=True
148148 # not an argument completion invocation
149149 return
150150
151- global debug_stream
152151 try :
153- debug_stream = os .fdopen (9 , "w" )
154- except :
155- debug_stream = sys .stderr
152+ argcomplete . debug_stream = os .fdopen (9 , "w" )
153+ except IOError :
154+ argcomplete . debug_stream = sys .stderr
156155
157156 if output_stream is None :
158157 try :
159158 output_stream = os .fdopen (8 , "wb" )
160- except :
159+ except IOError :
161160 argcomplete .debug ("Unable to open fd 8 for writing, quitting" )
162161 exit_method (1 )
163162
@@ -234,7 +233,7 @@ def __call__(self, argument_parser, completer=None, always_complete_options=True
234233 # to ever match.
235234 outstr = outstr .replace ('\n ' , ' ' ).replace ('\t ' , ' ' ).replace (' ' , ' ' ).strip ()
236235 # generate a filler entry that should always sort first
237- filler = ' {0:><{width}}' .format ('' , width = len (outstr ))
236+ filler = ' {0:><{width}}' .format ('' , width = len (outstr )/ 2 )
238237 outstr = ifs .join ([filler , outstr ])
239238
240239 output_stream .write (outstr .encode (argcomplete .sys_encoding ))
@@ -243,6 +242,5 @@ def __call__(self, argument_parser, completer=None, always_complete_options=True
243242 # go forward with normal filesystem completion
244243 output_stream .write (ifs .join ([]).encode (argcomplete .sys_encoding ))
245244 output_stream .flush ()
246- debug_stream .flush ()
245+ argcomplete . debug_stream .flush ()
247246 exit_method (0 )
248-
0 commit comments