[Pythonmac-SIG] rfc822 lib

Francois Granger fgranger@altern.org
Mon, 24 Jul 2000 12:28:53 +0200


on 23/07/00 23:01, Rod Morehead at rmore@rmore.net wrote:

> I would guess that this is because if you open a file in text mode on
> the Mac CR and LF are swapped and CR-LF become LF-CR which confuses
> the code (if you open it in binary mode they aren't, but then '\n'
> isn't a mac newline '\r' is).

I did not thought of this. If the rfc library can work with this, it will
not be a big issue since I never access the file directly. Only the content
of the message may be with wrong lines ending ?

>=20
> If performance isn't too important an easy workaround would be to try
> opening the file in binary mode ('rb') and then if that fails fall
> back to text mode. If that still fails then I would suspect something
> else is the problem.

I'll give it a try tonight. In the mean time I got the quick and dirty
solution of:
1) test for end of file
2) make a backup of the file
3) replace all '\r\n' by '\n'
4) write this to the file
5) close the file
6) reopen it in 'r' mode.

Somewhat ugly.

--=20
Fran=E7ois Granger
fgranger@altern.org