[issue13524] critical error with import tempfile
Changes by Tim Golden m...@timgolden.me.uk: -- resolution: - wont fix status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13524] critical error with import tempfile
Tim Golden m...@timgolden.me.uk added the comment: OK, the long and short is that spwaning a process without passing in SystemRoot is asking for trouble. There's a blog post here which gives an example: http://jpassing.com/2009/12/28/the-hidden-danger-of-forgetting-to-specify-systemroot-in-a-custom-environment-block/ And, certainly this works: import os import subprocess subprocess.Popen( notepad.exe, env={SystemRoot : os.environ['SystemRoot']} ) I'm not quite sure what approach we should take in the subprocess module. Is it a docs warning? Should we refuse to proceed if there's no SystemRoot? Is it the caller's responsibility? I'll ask on python-dev to gather opinions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13524] critical error with import tempfile
New submission from Andrey Morozov andrey.moro...@itseez.com: run_me.py: import subprocess, sys e = {'PATH_TO_MY_APPS' : path/to/my/apps} p = subprocess.Popen(sys.executable + test1.py 123, env=e, shell=True, stdout=subprocess.PIPE) print(p.stdout.readlines()) p.wait() test1.py: 1: import sys, os 2: #import tempfile 3: print(hello : + sys.platform + PATH: + os.environ['PATH_TO_MY_APPS']) System: Python 2.7.2 x64, Windows x64 7 Pro + SP1 Problem: if I run python run_me.py then I see on my stdout: ['hello : win32 PATH: path/to/my/apps\r\n'] but if I uncomment line number 2 in test1.py and run python run_me.py then I see on my stdout : C:\tmp\python_testpython run_me.py Traceback (most recent call last): File test1.py, line 2, in module import tempfile File C:\Python27\lib\tempfile.py, line 34, in module from random import Random as _Random File C:\Python27\lib\random.py, line 883, in module _inst = Random() File C:\Python27\lib\random.py, line 97, in __init__ self.seed(x) File C:\Python27\lib\random.py, line 111, in seed a = long(_hexlify(_urandom(16)), 16) WindowsError: [Error -2146893818] Invalid Signature [] -- files: run_me.py messages: 148792 nosy: Andrey.Morozov priority: normal severity: normal status: open title: critical error with import tempfile type: crash versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file23838/run_me.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13524] critical error with import tempfile
Andrey Morozov andrey.moro...@itseez.com added the comment: WIDW ? -- Added file: http://bugs.python.org/file23839/test1.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13524] critical error with import tempfile
Tim Golden m...@timgolden.me.uk added the comment: The environment passed to a Windows process must contain certain things. (I don't at this moment remember exactly what). You can't just pass the one thing you're adding. Change your e = ... line to something like: e = os.environ e['PATH_TO_MY_CODE'] = '/x/y/z' and then try the code. Obviously the subprocess module doesn't have enough checks in place for this -- it actually segfaults on my WinXP machine. But can you confirm that this is indeed your issue? -- nosy: +tim.golden ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13524] critical error with import tempfile
Andrey Morozov andrey.moro...@itseez.com added the comment: it fix my problem: e = os.environ.copy() e['PATH_TO_MY_APPS'] = path/to/my/apps p = subprocess.Popen(sys.executable + test1.py 123, env=e, shell=True, stdout=subprocess.PIPE) answer: need have copy of environments -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13524] critical error with import tempfile
Tim Golden m...@timgolden.me.uk added the comment: Re-opening because there's a real problem here which can crash Python hard. Simplest reproduction: import sys import subprocess subprocess.Popen (sys.executable, env={}) Affects 2.x and 3.x tip (haven't tried others yet but I don't imagine it's different) -- assignee: - tim.golden components: +Library (Lib), Windows stage: - test needed status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13524] critical error with import tempfile
Antoine Pitrou pit...@free.fr added the comment: Re-opening because there's a real problem here which can crash Python hard. Works under Linux. Is it Windows-specific? -- nosy: +pitrou stage: test needed - versions: -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13524] critical error with import tempfile
Tim Golden m...@timgolden.me.uk added the comment: Yes. I've added the Windows component on the tracker. (At least I think I have). It's to do with CreateProcess needing at least certain items in the environment passed. I'm trying to track down some docs on MSDN which specify which must be there. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com