[Python-checkins] cpython: Issue #12760: Add a create mode to open(). Patch by David Townshend.

Terry Reedy tjreedy at udel.edu
Mon Jan 9 23:20:32 CET 2012



On 1/9/2012 4:40 PM, charles-francois.natali wrote:
> http://hg.python.org/cpython/rev/bf609baff4d3
> changeset:   74315:bf609baff4d3
> user:        Charles-François Natali<neologix at free.fr>
> date:        Mon Jan 09 22:40:02 2012 +0100
> summary:
>    Issue #12760: Add a create mode to open(). Patch by David Townshend.

> +    if creating + reading + writing + appending>  1:
>           raise ValueError("can't have read/write/append mode at once")
> -    if not (reading or writing or appending):
> +    if not (creating or reading or writing or appending):
>           raise ValueError("must have exactly one of read/write/append mode")

I think the error message(s) should be updated with 'create' as you did 
in the C Code below. Would not
     if creating + reading + writing + appending !=  1:
         raise ValueError(
             "must have exactly one of create/read/write/append mode")
be sufficient?

>           PyErr_SetString(PyExc_ValueError,
> -                        "must have exactly one of read/write/append mode");
> +                        "must have exactly one of create/read/write/append mode");

>                   PyErr_SetString(PyExc_ValueError,
> -                                "Must have exactly one of read/write/append "
> +                                "Must have exactly one of create/read/write/append "
>                                   "mode and at most one plus");

Terry



More information about the Python-checkins mailing list