From da2a4da94bdb285c7b568e4fd0e546577e446f33 Mon Sep 17 00:00:00 2001 From: "steven.bethard" Date: Mon, 4 May 2009 05:20:50 +0000 Subject: Make append* actions copy their default value. Bump version numbers, and clean up description text in setup.py. Ignore some generated and local files. --- argparse.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'argparse.py') diff --git a/argparse.py b/argparse.py index bc640a2..8544dd7 100644 --- a/argparse.py +++ b/argparse.py @@ -72,8 +72,9 @@ considered public as object names -- the API of the formatter objects is still considered an implementation detail.) """ -__version__ = '0.9.1' +__version__ = '0.9.2' +import copy as _copy import os as _os import re as _re import sys as _sys @@ -833,7 +834,9 @@ class _AppendAction(Action): metavar=metavar) def __call__(self, parser, namespace, values, option_string=None): - _ensure_value(namespace, self.dest, []).append(values) + items = _copy.copy(_ensure_value(namespace, self.dest, [])) + items.append(values) + setattr(namespace, self.dest, items) class _AppendConstAction(Action): @@ -857,7 +860,9 @@ class _AppendConstAction(Action): metavar=metavar) def __call__(self, parser, namespace, values, option_string=None): - _ensure_value(namespace, self.dest, []).append(self.const) + items = _copy.copy(_ensure_value(namespace, self.dest, [])) + items.append(self.const) + setattr(namespace, self.dest, items) class _CountAction(Action): -- cgit v1.2.1