Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-28 Thread Greg Ewing
Michael Foord wrote: You said that having an exception hierarchy was impossible because the only information we have is the error number. No, I said that having an exception hierarchy wouldn't help you to sort out the different meanings of a single error code. If you have some *other* way of

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-28 Thread Michael Foord
Greg Ewing wrote: Michael Foord wrote: Well, the file type knows what mode it is opened in so catching these errors is really not difficult at all. Yes, in this particular case it could do some checking of its own before making the system call. But this still has nothing to do with the except

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-28 Thread Greg Ewing
Michael Foord wrote: Well, the file type knows what mode it is opened in so catching these errors is really not difficult at all. Yes, in this particular case it could do some checking of its own before making the system call. But this still has nothing to do with the exception hierarchy. --

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-28 Thread Nick Coghlan
Antoine Pitrou wrote: > Le Mon, 28 Sep 2009 06:41:17 +1000, Nick Coghlan a écrit : >> Michael's response cut to the heart of the issue though - a richer IO >> exception hierarchy can make life interesting for compatibility purposes >> (especially when creating "file-like" interfaces to non-file obj

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-28 Thread Michael Foord
Greg Ewing wrote: Michael Foord wrote: Some of the error messages are truly awful though as things stand, especially for someone new to Python. Try to read from a file handle opened in read mode for example: IOError: [Errno 9] Bad file descriptor Subdividing the IOError exception won't help

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-28 Thread Pascal Chambon
+-InvalidFileNameError (filepath max lengths, or "? / : " characters in a windows file name...) This might be a bit too precise. Unix just has EINVAL, which covers any kind of invalid parameter, not just file names. Allright thanks, an InvalidParameter (or similar) exception should do it

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread Greg Ewing
Michael Foord wrote: Some of the error messages are truly awful though as things stand, especially for someone new to Python. Try to read from a file handle opened in read mode for example: IOError: [Errno 9] Bad file descriptor Subdividing the IOError exception won't help with that, because

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread Antoine Pitrou
Le Mon, 28 Sep 2009 06:41:17 +1000, Nick Coghlan a écrit : > > Not as such - a big exception hierarchy rewrite was rejected, but > nothing specifically limited to the IO exceptions. > > Michael's response cut to the heart of the issue though - a richer IO > exception hierarchy can make life inter

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread Michael Foord
Nick Coghlan wrote: Antoine Pitrou wrote: This deserves its own PEP IMO, although I'm not sure it would be accepted (ISTR the idea of a detailed IO exception hierarchy was already refused in the past). Not as such - a big exception hierarchy rewrite was rejected, but nothing specifica

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread Nick Coghlan
Antoine Pitrou wrote: > This deserves its own PEP IMO, although I'm not sure it would be accepted > (ISTR the idea of a detailed IO exception hierarchy was already refused > in the past). Not as such - a big exception hierarchy rewrite was rejected, but nothing specifically limited to the IO exc

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread James Y Knight
On Sep 27, 2009, at 4:20 AM, Pascal Chambon wrote: Thus, at the moment IOErrors rather have the semantic of "particular case of OSError", and it's kind of confusing to have them remain in their own separate tree... Furthermore, OSErrors are often used where IOErrors would perfectly fit, eg.

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread Antoine Pitrou
MRAB mrabarnett.plus.com> writes: > > If the characters are always the same number of bytes) then overwriting > could be possible; that would, however, make the behaviour more > complicated (sometimes you can, sometimes you can't), so it's probably > just simpler to forbid read+write text streams

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread MRAB
Pascal Chambon wrote: > Found in current io PEP : > Q: Do we want to mandate in the specification that switching between > reading and writing on a read-write object implies a .flush()? Or is > that an implementation convenience that users should not rely on? > -> it seems that the only important

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread Antoine Pitrou
Le Sun, 27 Sep 2009 10:20:23 +0200, Pascal Chambon a écrit : > Q: Do we want to mandate in the specification that switching between > reading and writing on a read-write object implies a .flush()? It doesn't and shouldn't be mandated in the specification, IMO. An implementation should be free to

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread Michael Foord
Pascal Chambon wrote: Found in current io PEP : Q: Do we want to mandate in the specification that switching between reading and writing on a read-write object implies a .flush()? Or is that an implementation convenience that users should not rely on? -> it seems that the only important matter

Re: [Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread Greg Ewing
Pascal Chambon wrote: -> it seems that the only important matter is : file pointer positions and bytes/characters read should always be the ones that the user expects, as if there were no buffering. That sounds right to me. Q from me : What happens in read/write text files, when overwriting

[Python-Dev] IO module precisions and exception hierarchy

2009-09-27 Thread Pascal Chambon
Found in current io PEP : Q: Do we want to mandate in the specification that switching between reading and writing on a read-write object implies a .flush()? Or is that an implementation convenience that users should not rely on? -> it seems that the only important matter is : file pointer posit