argparse drops private method _ensure_value

The `argparse` library refactored to improvem performance of common use
cases.  Handling a list is not a common scenario and the function
_ensure_values (which was obviously private) disappeared.

This commit simply uses the same strategy that the upstream `argparse`
maintainers used.  Since this is a subclass of a private object type
anyway, this is expected sort of behaviour.
This commit is contained in:
Martin A. Brown 2022-10-23 18:45:02 +00:00
parent 4cb5e881d2
commit fafc30ac0e
1 changed files with 1 additions and 2 deletions

View File

@ -8,7 +8,6 @@ from __future__ import unicode_literals
import os
import argparse
import copy as _copy
import logging
@ -30,7 +29,7 @@ class DirectoriesExist(argparse._AppendAction):
message = message % (values, option_string)
logger.critical(message)
raise ValueError(message)
items = _copy.copy(argparse._ensure_value(namespace, self.dest, []))
items = getattr(namespace, self.dest, [])
items.append(values)
setattr(namespace, self.dest, items)