Changeset 391 for python/trunk/Lib/os.py
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Lib/os.py
r10 r391 266 266 """ 267 267 268 from os.path import join, isdir, islink268 islink, join, isdir = path.islink, path.join, path.isdir 269 269 270 270 # We may not have read permission for top, in which case we can't … … 292 292 yield top, dirs, nondirs 293 293 for name in dirs: 294 path = join(top, name)295 if followlinks or not islink( path):296 for x in walk( path, topdown, onerror, followlinks):294 new_path = join(top, name) 295 if followlinks or not islink(new_path): 296 for x in walk(new_path, topdown, onerror, followlinks): 297 297 yield x 298 298 if not topdown: … … 517 517 518 518 def _exists(name): 519 try: 520 eval(name) 521 return True 522 except NameError: 523 return False 519 return name in globals() 524 520 525 521 # Supply spawn*() (probably only for Unix) … … 745 741 except NameError: # statvfs_result may not exist 746 742 pass 747 748 if not _exists("urandom"):749 def urandom(n):750 """urandom(n) -> str751 752 Return a string of n random bytes suitable for cryptographic use.753 754 """755 try:756 _urandomfd = open("/dev/urandom", O_RDONLY)757 except (OSError, IOError):758 raise NotImplementedError("/dev/urandom (or equivalent) not found")759 try:760 bs = b""761 while n - len(bs) >= 1:762 bs += read(_urandomfd, n - len(bs))763 finally:764 close(_urandomfd)765 return bs
Note:
See TracChangeset
for help on using the changeset viewer.