[New-bugs-announce] [issue15929] argparse non alphanum characters replacement

Julien Castets report at bugs.python.org
Wed Sep 12 11:00:57 CEST 2012

New submission from Julien Castets:

argparse.add_argument replaces dashes with underscores. If an argument contains another non alphanum character, accessing to it will result to a syntax error.

#! /usr/bin/env python

import argparse

if __name__ == '__main__':
    argParser = argparse.ArgumentParser()
    argParser.add_argument('--foo+', action='store_true')
    arguments = argParser.parse_args()

    print 'getattr foo+: %s' % getattr(arguments, 'foo+') # ok
    print arguments.foo+ # syntax error

The patch replaces every non alnum character with an underscore.

components: None
files: argparse.patch
keywords: patch
messages: 170361
nosy: brmzkw
priority: normal
severity: normal
status: open
title: argparse non alphanum characters replacement
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file27178/argparse.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list