traits error with Either File List exists

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

traits error with Either File List exists

Satrajit Ghosh
i'm running into an error with either of the following traits:

Either(File(exists=True), List(File(exists=True)))
Either(File(exists=True), List(File))

traceback available at:
http://gist.github.com/355998

this error does not arise if i do any of:

Either(File, List(File))
Either(File, List(File(exists=True)))
Either(List(File),File(exists=True))
Either(List(File(exists=True)),File)
Either(List(File(exists=True)),File(exists=True))

since i'm new to traits and may be doing something fundamentally incorrect, it would be good to know why this error occurs.

cheers,

satra

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: traits error with Either File List exists

Robert Kern
On Sun, Apr 4, 2010 at 11:16 PM, Satrajit Ghosh <[hidden email]> wrote:

> i'm running into an error with either of the following traits:
>
> Either(File(exists=True), List(File(exists=True)))
> Either(File(exists=True), List(File))
>
> traceback available at:
> http://gist.github.com/355998
>
> this error does not arise if i do any of:
>
> Either(File, List(File))
> Either(File, List(File(exists=True)))
> Either(List(File),File(exists=True))
> Either(List(File(exists=True)),File)
> Either(List(File(exists=True)),File(exists=True))
>
> since i'm new to traits and may be doing something fundamentally incorrect,
> it would be good to know why this error occurs.

This is a bug in the validator for File(exists=True). I just checked
in a fix to make sure that we validate the type of the value first
before trying to pass it to os.path.isfile(). Now passing a list to a
File(exists=True) trait will correctly raise a TraitError so your
Either() construction will then check the second argument, as you
intended.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: traits error with Either File List exists

Satrajit Ghosh
thanks very much.

cheers,

satra

On Mon, Apr 5, 2010 at 10:27 AM, Robert Kern <[hidden email]> wrote:
On Sun, Apr 4, 2010 at 11:16 PM, Satrajit Ghosh <[hidden email]> wrote:
> i'm running into an error with either of the following traits:
>
> Either(File(exists=True), List(File(exists=True)))
> Either(File(exists=True), List(File))
>
> traceback available at:
> http://gist.github.com/355998
>
> this error does not arise if i do any of:
>
> Either(File, List(File))
> Either(File, List(File(exists=True)))
> Either(List(File),File(exists=True))
> Either(List(File(exists=True)),File)
> Either(List(File(exists=True)),File(exists=True))
>
> since i'm new to traits and may be doing something fundamentally incorrect,
> it would be good to know why this error occurs.

This is a bug in the validator for File(exists=True). I just checked
in a fix to make sure that we validate the type of the value first
before trying to pass it to os.path.isfile(). Now passing a list to a
File(exists=True) trait will correctly raise a TraitError so your
Either() construction will then check the second argument, as you
intended.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev