[New-bugs-announce] [issue11295] On Windows, Python crashes on ANSI / Windows-formatted source files

Jonathan Hayward report at bugs.python.org
Wed Feb 23 01:22:26 CET 2011

New submission from Jonathan Hayward <jonathan.hayward at pobox.com>:

So far as I can tell, Python 2.7 crashes on at least some ANSI / Windows \r\n-delimited source files. More specifically, as invoked by Apache as a CGI script, the source file line:

import cgi

generated an error logged by Apache, complaining that the module "cgi\r" couldn't be imported.

Email sent as follows:


Today I was visiting with a friend and installing OSS on his computer. On an x86_64 Windows 7 box, he had already installed Apache, and I installed Python with a python.org installer. I opened up Notepad and created a "Hello world" Python CGI script, put it in the cgi-bin directory, saw it crash, and looked in the logs.

The log message complained that I had tried to "import cgi\r": in other words, Python on Windows was choking because the file I made in Notepad used "\r\n" for line breaks. (The equivalent script made with vim, and presumably "\n" for line breaks worked predictably.)

Isn't it a defect/design flaw for Python on Windows to choke on "\r\n"-separated files? Should I file a bug, or is this a side effect of decisions that are now non-negotiable? (I wasn't thrilled, after trying to sell my friend on the idea that Python is a good language with a low barrier to entry, to find that it choked on a Notepad-edited "Hello world!" CGI script.)

components: Interpreter Core
messages: 129142
nosy: JonathanHayward
priority: normal
severity: normal
status: open
title: On Windows, Python crashes on ANSI / Windows-formatted source files
type: behavior
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list