[issue26952] argparse help formatter crashes

2019-07-07 Thread Alexander Kapshuna


Alexander Kapshuna  added the comment:

I have a feeling that nesting groups has nothing to do with it. Got same 
traceback when I forgot to fill my mutually exclusive groups with arguments. 

import argparse

parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group()
parser.parse_args(['-h'])

# Result:

Traceback (most recent call last):
  File "/home/kapsh/.PyCharmCE2019.1/config/scratches/scratch_12.py", line 5, 
in 
parser.parse_args(['-h'])
  File "/usr/lib/python3.7/argparse.py", line 1749, in parse_args
args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python3.7/argparse.py", line 1781, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.7/argparse.py", line 1987, in _parse_known_args
start_index = consume_optional(start_index)
  File "/usr/lib/python3.7/argparse.py", line 1927, in consume_optional
take_action(action, args, option_string)
  File "/usr/lib/python3.7/argparse.py", line 1855, in take_action
action(self, namespace, argument_values, option_string)
  File "/usr/lib/python3.7/argparse.py", line 1037, in __call__
parser.print_help()
  File "/usr/lib/python3.7/argparse.py", line 2474, in print_help
self._print_message(self.format_help(), file)
  File "/usr/lib/python3.7/argparse.py", line 2458, in format_help
return formatter.format_help()
  File "/usr/lib/python3.7/argparse.py", line 284, in format_help
help = self._root_section.format_help()
  File "/usr/lib/python3.7/argparse.py", line 215, in format_help
item_help = join([func(*args) for func, args in self.items])
  File "/usr/lib/python3.7/argparse.py", line 215, in 
item_help = join([func(*args) for func, args in self.items])
  File "/usr/lib/python3.7/argparse.py", line 322, in _format_usage
action_usage = format(optionals + positionals, groups)
  File "/usr/lib/python3.7/argparse.py", line 397, in _format_actions_usage
start = actions.index(group._group_actions[0])
IndexError: list index out of range

--
nosy: +kapsh

___
Python tracker 
<https://bugs.python.org/issue26952>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36043] FileCookieJar constructor don't accept PathLike

2019-02-21 Thread Alexander Kapshuna


Alexander Kapshuna  added the comment:

Oh sorry, I just thought that everybody has forgotten about this part of 
library. Nevermind my patch then, your work is certainly better, matrixise.

--

___
Python tracker 
<https://bugs.python.org/issue36043>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36043] FileCookieJar constructor don't accept PathLike

2019-02-19 Thread Alexander Kapshuna


New submission from Alexander Kapshuna :

FileCookieJar and it's subclasses don't accept Paths and DirEntrys.
Minimal code to reproduce:

===

import pathlib
from http.cookiejar import FileCookieJar

saved_cookies = pathlib.Path('my_cookies.txt')
jar = FileCookieJar(saved_cookies)

===

Results in: "ValueError: filename must be string-like".
Workaround is to convert Path explicitly or call load() which doesn't check for 
type, but it would be nice to see all APIs in standard library consistent.

I also did quick and dirty patch which silently converts filename argument 
using os.fspath(). This way it won't break any existing code relying on 
FileCookieJar.filename being string.

--
components: Library (Lib)
files: cookiejar_straightforward_convert.patch
keywords: patch
messages: 335993
nosy: Alexander Kapshuna
priority: normal
severity: normal
status: open
title: FileCookieJar constructor don't accept PathLike
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8
Added file: 
https://bugs.python.org/file48156/cookiejar_straightforward_convert.patch

___
Python tracker 
<https://bugs.python.org/issue36043>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com