Changeset 391 for python/trunk/Lib/os.py


Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Lib/os.py

    r10 r391  
    266266    """
    267267
    268     from os.path import join, isdir, islink
     268    islink, join, isdir = path.islink, path.join, path.isdir
    269269
    270270    # We may not have read permission for top, in which case we can't
     
    292292        yield top, dirs, nondirs
    293293    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):
    297297                yield x
    298298    if not topdown:
     
    517517
    518518def _exists(name):
    519     try:
    520         eval(name)
    521         return True
    522     except NameError:
    523         return False
     519    return name in globals()
    524520
    525521# Supply spawn*() (probably only for Unix)
     
    745741except NameError: # statvfs_result may not exist
    746742    pass
    747 
    748 if not _exists("urandom"):
    749     def urandom(n):
    750         """urandom(n) -> str
    751 
    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.