Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue6479] platform.py writes to hard coded platform dependant "dev/null"

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jul 13, 2009, 12:38 PM

Post #1 of 6 (285 views)
Permalink
[issue6479] platform.py writes to hard coded platform dependant "dev/null"

New submission from John Burnett <python [at] johnburnett>:

The functions _syscmd_uname and _syscmd_file are hard-coded to pipe
stderr to "/dev/null", as opposed to os.devnull. On Windows, this has
the effect of creating a file called "null" to a local "dev" directory
(if the directory exists).

Attached is a fix. While the _syscmd_uname change isn't entirely
necessary on Windows due to its sys.platform check, I changed both
functions for consistency (and I'm not sure what other platforms might
not have a "/dev/null" either).

----------
components: Library (Lib)
files: devnull.patch
keywords: patch
messages: 90499
nosy: john.burnett
severity: normal
status: open
title: platform.py writes to hard coded platform dependant "dev/null"
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2
Added file: http://bugs.python.org/file14497/devnull.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6479>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 13, 2009, 12:45 PM

Post #2 of 6 (270 views)
Permalink
[issue6479] platform.py writes to hard coded platform dependant "dev/null" [In reply to]

Changes by Benjamin Peterson <benjamin [at] python>:


----------
assignee: -> lemburg
nosy: +lemburg

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6479>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 13, 2009, 1:14 PM

Post #3 of 6 (277 views)
Permalink
[issue6479] platform.py writes to hard coded platform dependant "dev/null" [In reply to]

Marc-Andre Lemburg <mal [at] egenix> added the comment:

On which Windows platform would that be ?

Both internal helper functions bypass using an external command for
Windows and DOS platforms.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6479>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 13, 2009, 3:37 PM

Post #4 of 6 (269 views)
Permalink
[issue6479] platform.py writes to hard coded platform dependant "dev/null" [In reply to]

John Burnett <python [at] johnburnett> added the comment:

I'm not sure how you're seeing that those functions bypass external
commands?

I'm running Vista64, and it certainly looks like calling
platform.architecture calls _syscmd_file, which then immediately calls
os.popen("file %s 2> /dev/null"). This causes windows to try and open a
file called "file", which fails, and pipes the resulting error ("'file'
is not recognized as an internal or external command, operable program
or batch file.") to a file named "null" in my "c:\dev" directory.

This will happen on any system that doesn't /dev/null. _syscmd_uname
does the same thing, but "protects" against it by testing for platform
type. I'm not familiar enough with the supported platforms to know if
it's covering all the bases, but a safer thing to do would be to just
use os.devnull anyway.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6479>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 13, 2009, 3:52 PM

Post #5 of 6 (279 views)
Permalink
[issue6479] platform.py writes to hard coded platform dependant "dev/null" [In reply to]

Marc-Andre Lemburg <mal [at] egenix> added the comment:

John Burnett wrote:
> John Burnett <python [at] johnburnett> added the comment:
>
> I'm not sure how you're seeing that those functions bypass external
> commands?

Both functions use this bypass mechanism:

if sys.platform in ('dos','win32','win16','os2'):
return default

> I'm running Vista64, and it certainly looks like calling
> platform.architecture calls _syscmd_file, which then immediately calls
> os.popen("file %s 2> /dev/null"). This causes windows to try and open a
> file called "file", which fails, and pipes the resulting error ("'file'
> is not recognized as an internal or external command, operable program
> or batch file.") to a file named "null" in my "c:\dev" directory.

Could you please tell me what sys.platform is set to on Vista 64 ?

If it's "win64", then I'll have to add that to the above test.
AFAIK, we chose to leave it set to "win32" even on 64-bit Windows
versions, so the above test should trigger on Vista 64 as well.

> This will happen on any system that doesn't /dev/null. _syscmd_uname
> does the same thing, but "protects" against it by testing for platform
> type. I'm not familiar enough with the supported platforms to know if
> it's covering all the bases, but a safer thing to do would be to just
> use os.devnull anyway.

I've added a similar patch in r74002, but those functions should
not really do anything on Windows at all.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6479>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 13, 2009, 4:53 PM

Post #6 of 6 (276 views)
Permalink
[issue6479] platform.py writes to hard coded platform dependant "dev/null" [In reply to]

John Burnett <python [at] johnburnett> added the comment:

You're right, Vista64 is returning "win32" for the platform.

And ahh, I see what I did: in Python 2.5.2, _syscmd_file wasn't using a
sys.platform check. Then when I looked at the current version, I saw it
was still using "/dev/null", but didn't see a platform check was added
to skip that part in rev 66104.

Regardless, thanks for adding the change... who knows, it might get hit
some day on a new platform ;).

----------
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue6479>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.