[issue41177] ConvertingList and ConvertingTuple lack iterators and ConvertingDict lacks items()

2020-07-30 Thread Brett Hannigan


Brett Hannigan  added the comment:

Just wanted to check-in to see if there were any updates on my proposed PR?

--

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



[issue41177] ConvertingList and ConvertingTuple lack iterators and ConvertingDict lacks items()

2020-07-06 Thread Brett Hannigan


Brett Hannigan  added the comment:

O.K. CLA is now signed and if I check on the "check-yourself" with my github 
user it is showing that I have signed it now.

--

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



[issue41177] ConvertingList and ConvertingTuple lack iterators and ConvertingDict lacks items()

2020-07-06 Thread Brett Hannigan


Brett Hannigan  added the comment:

Thanks.

I don't know why it still says CLA not signed - I signed it a week ago, but 
I'll try to figure that out this week.

--

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



[issue41177] ConvertingList and ConvertingTuple lack iterators and ConvertingDict lacks items()

2020-07-06 Thread Brett Hannigan


Brett Hannigan  added the comment:

I encountered the need for the iterators when trying to create a subclass of 
the QueueHandler class that would manage both the QueueHandler and the 
QueueListener. The implementation is very similar to that described in this 
Medium post:
https://medium.com/@rob.blackbourn/how-to-use-python-logging-queuehandler-with-dictconfig-1e8b1284e27a

Both the original poster and I encountered one small issue: when using a 
dictConfig to instantiate the new subclass, the main QueueHandler gets a 
ConvertingList of the handlers that the user has requested be used. The 
subclass would then pass these to the QueueListener, but the constructor for 
the QueueListener takes *handlers (that is, it will convert the ConvertingList 
to a tuple). Unfortunately, because ConvertingList does not expose the 
iterator, converting from the ConvertingList to the tuple results in a tuple of 
unconverted handler references (ultimately strings).

The author of the Medium article gets around this by creating a little function 
that simply loops over the length of the ConvertingList and does a "get" on 
each item on the list, to ensure that the item is converted. Since 
ConvertingList is not documented though, there is concern that this approach 
could break in the future if the interface changes etc. 

With the implementation of the iterator in this PR, the conversion of the 
ConvertingList to the tuple will automatically result in a tuple of converted 
handlers, so one doesn't need to know about the ConvertingList object - it 
handles things behind the scenes.

Here is the code that the Medium article currently uses to force conversion:

def _resolve_handlers(l):
if not isinstance(l, ConvertingList):
return l

# Indexing the list performs the evaluation.
return [l[i] for i in range(len(l))]

--

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



[issue41177] ConvertingList and ConvertingTuple lack iterators and ConvertingDict lacks items()

2020-07-01 Thread Brett Hannigan


Change by Brett Hannigan :


--
versions:  -Python 3.10

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



[issue41177] ConvertingList and ConvertingTuple lack iterators and ConvertingDict lacks items()

2020-06-30 Thread Brett Hannigan


New submission from Brett Hannigan :

The logging.config module uses three internal data structures to hold items 
that may need to be converted to a handler or other object: ConvertingList, 
ConvertingTuple, and ConvertingDict.

These three objects provide interfaces to get converted items using the 
__getitem__ methods. However, if a user tries to iterate over items in the 
container, they will get the un-converted entries.

--
components: Library (Lib)
messages: 372724
nosy: Brett Hannigan
priority: normal
severity: normal
status: open
title: ConvertingList and ConvertingTuple lack iterators and ConvertingDict 
lacks items()
type: enhancement
versions: Python 3.7

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



[issue22848] Subparser help does not respect SUPPRESS argument

2014-11-12 Thread Brett Hannigan

Changes by Brett Hannigan bhanni...@dnanexus.com:


--
keywords: +patch
Added file: http://bugs.python.org/file37187/argparse.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22848
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22848] Subparser help does not respect SUPPRESS argument

2014-11-11 Thread Brett Hannigan

New submission from Brett Hannigan:

When adding an argument to a subparser and passing help=argparse.SUPPRESS, I 
would expect this argument to not show up when running help.  Instead, I find 
that the argument is listed and the help given is ==SUPPRESS==.  For example 
(also in attached python script):
import argparse

parser = argparse.ArgumentParser('test')
subparsers = parser.add_subparsers()
parser_foo = subparsers.add_parser('foo', help='This is help for foo')
parser_bar = subparsers.add_parser('bar', help=argparse.SUPPRESS)

parser.parse_args(['-h'])

usage: test [-h] {foo,bar} ...

positional arguments:
  {foo,bar}
foo   This is help for foo
bar   ==SUPPRESS==

optional arguments:
  -h, --help  show this help message and exit

I believe I have found the proper fix in argparse.py
In the class _SubParsersAction look at the method add_parser().
There is the following block of code:

if 'help' in kwargs:
help = kwargs.pop('help')
choice_action = self._ChoicesPseudoAction(name, help)
self._choices_actions.append(choice_action)

This should instead check to see if help is SUPPRESS or not like so:

if 'help' in kwargs:
help = kwargs.pop('help')
if help != SUPPRESS:
choice_action = self._ChoicesPseudoAction(name, help)
self._choices_actions.append(choice_action)

If I make this change locally, then the above code does in fact suppress 
printing the bar option.

--
components: Library (Lib)
files: argparse_test.py
messages: 231035
nosy: Brett.Hannigan
priority: normal
severity: normal
status: open
title: Subparser help does not respect SUPPRESS argument
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file37177/argparse_test.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22848
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22848] Subparser help does not respect SUPPRESS argument

2014-11-11 Thread Brett Hannigan

Changes by Brett Hannigan bhanni...@dnanexus.com:


Added file: http://bugs.python.org/file37178/argparse.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22848
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com