[Python-bugs-list] [ python-Bugs-481171 ] Hang using files named prn.txt, etc

noreply@sourceforge.net noreply@sourceforge.net
Tue, 13 Nov 2001 17:20:06 -0800


Bugs item #481171, was opened at 2001-11-12 21:43
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=481171&group_id=5470

Category: Windows
Group: Platform-specific
>Status: Open
Resolution: Wont Fix
>Priority: 2
Submitted By: Andrew Bennetts (spiv)
Assigned to: Tim Peters (tim_one)
Summary: Hang using files named prn.txt, etc

Initial Comment:
Windows reserves many possible filenames as reserved 
device names.

Examples are prn.xxx, con.xxx, com1.xxx aux.xxx, etc, 
where xxx can be any extension.  Attempts to 
create/read/write to these files can hang the 
interpreter, but ideally would just throw an OSError.

A partial list of device names is mentioned at:
http://cert.uni-
stuttgart.de/archive/bugtraq/2001/07/msg00086.html

----------------------------------------------------------------------

>Comment By: Andrew Bennetts (spiv)
Date: 2001-11-13 17:20

Message:
Logged In: YES 
user_id=50945

Yes, I read the message (and most of the thread) :)

Apologies for re-opening this bug, but I believe that
something can still be done about it.

I'm using Windows 2K (SP 2), so those patches don't apply to
me.  Those patches merely prevent windows crashing on
certain types of accesses to devices, e.g. the now
well-known C:\NUL\NUL bug.  They don't prevent applications
from hanging when trying to access prn.txt.

Further in the thread starting at that URL, there is some
discussion of possible work-arounds for safely
opening/creating files.  I'm not a Win32 C programmer, so
I've no idea about the technical feasibility of these
solutions in Python.

While I agree that the real problem is in the OS, it seems
to be standard behaviour now for apps to workaround it.  For
example, Textpad (www.textpad.com) will just pop up a dialog
saying "You cannot create this file: this name is reserved
device name" or something similar.  Whether they've just
hard-coded a list of known names or if they're doing
something more advanced I don't know.

This caused a fair bit of confusion for me recently: Python
hung inexplicably in splitting a CSV file of stock data into
seperate files, and one of the Australian Stock Exchange's
stock symbols is "PRN".  The script was extremely simple, so
I eventually realised what was going on, but I dread an
unwary person having to debug this problem in a larger
application.

If you think this sort of ugliness doesn't belong in Python
then feel free to close this bug again, and I won't feel
offended :)

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2001-11-13 09:41

Message:
Logged In: YES 
user_id=31435

Did you read the message you referenced with that URL?  I 
agree with it:

"""
Conclusion : applications should not filter out DDNs, 
because they don't fix the problem (basically they make it 
even worse), the OS patch is better because it
fixes *ALL* problems, ...

CONCLUSION : patch your OS, and stop whining about so
called 'bugs' in applications, you will never be able
to completely patch the problem that way.
"""

They're right:  applications cannot fix this; if it's a 
problem for you, then you should download and apply the MS 
OS patches linked to from that article.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=481171&group_id=5470