Changeset 388 for python/vendor/current/Lib/os.py
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Lib/os.py
r2 r388 264 264 """ 265 265 266 from os.path import join, isdir, islink266 islink, join, isdir = path.islink, path.join, path.isdir 267 267 268 268 # We may not have read permission for top, in which case we can't … … 290 290 yield top, dirs, nondirs 291 291 for name in dirs: 292 path = join(top, name)293 if followlinks or not islink( path):294 for x in walk( path, topdown, onerror, followlinks):292 new_path = join(top, name) 293 if followlinks or not islink(new_path): 294 for x in walk(new_path, topdown, onerror, followlinks): 295 295 yield x 296 296 if not topdown: … … 515 515 516 516 def _exists(name): 517 try: 518 eval(name) 519 return True 520 except NameError: 521 return False 517 return name in globals() 522 518 523 519 # Supply spawn*() (probably only for Unix) … … 743 739 except NameError: # statvfs_result may not exist 744 740 pass 745 746 if not _exists("urandom"):747 def urandom(n):748 """urandom(n) -> str749 750 Return a string of n random bytes suitable for cryptographic use.751 752 """753 try:754 _urandomfd = open("/dev/urandom", O_RDONLY)755 except (OSError, IOError):756 raise NotImplementedError("/dev/urandom (or equivalent) not found")757 try:758 bs = b""759 while n - len(bs) >= 1:760 bs += read(_urandomfd, n - len(bs))761 finally:762 close(_urandomfd)763 return bs
Note:
See TracChangeset
for help on using the changeset viewer.