[py-dev] patch to allow usage of py.lib within non-administrator account on windows
Harald Armin Massa
haraldarminmassa at gmail.com
Tue Jul 22 12:15:01 CEST 2008
Hello!
atm. py.lib uses
os.tmpfile()
within fdcapture.py.
On windows os.tmpfile() tries to create the file within the root of
c:\; and it is quite good practice to disallow write access to this
directory for non-admin users (as this avoids killing crucial system
files)
So installation on windows using an user without write-access to c:\,
even setup.py fails with "permission.denied"
More info in:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/4aa54e927f11bbc3?tvc=2
It is fixable by using:
def maketmpfile(self):
""" create a temporary file
"""
#~ f = os.tmpfile()
f=tempfile.TemporaryFile()
newf = py.io.dupfile(f)
f.close()
return newf
def writeorg(self, str):
""" write a string to the original file descriptor
"""
tempfp = tempfile.TemporaryFile()
try:
os.dup2(self._savefd, tempfp.fileno())
tempfp.write(str)
finally:
tempfp.close()
within lines 42ff of py/io/fdcapture.py, of course after importing tempfile.
I submit this patch into public domain.
Harald
--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
no fx, no carrier pidgeon
-
EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned!
More information about the Pytest-dev
mailing list