Permalink
Browse files

Clean up the _get_build_prefix code - close the open fd and print the…

… error message if the fd could not be opened (denied).

Signed-off-by: David <db@d1b.org>
  • Loading branch information...
1 parent eeaa64d commit e7bf29e239b24f7d13c7b423457b4ae06b445bc1 @d1b d1b committed Nov 23, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 pip/locations.py
View
@@ -35,9 +35,14 @@ def _get_build_prefix():
try:
os.mkdir(path)
except OSError:
- fd = os.open(path, os.O_RDONLY)
- stat = os.fstat(fd)
- if os.getuid() != stat.st_uid:
+ file_uid = None
+ try:
+ fd = os.open(path, os.O_RDONLY)
+ file_uid = os.fstat(fd).st_uid
+ os.close(fd)
+ except OSError:
+ file_uid = None
+ if file_uid != os.getuid():
print ("The temporary folder for building (%s) " % path +
"is not owned by your user!")
print("pip will not work until the temporary folder is " + \

0 comments on commit e7bf29e

Please sign in to comment.