':param raise_errors: If this is true, errors will be raised as `ParserError`s instead of calling sys.exit'

def parse_args(self, args=None, namespace=None, raise_errors=False, file=None):

    ArgumentParser.file = file
    try:
        return super(ArgumentParser, self).parse_args(args, namespace)
    except ParserError as e:
        if raise_errors:
            raise
        super(ArgumentParser, e.parser).error(e.message)
    finally:
        ArgumentParser.file = None
