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/uuid.py

    r2 r391  
    303303            # prevent output on stderr
    304304            cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, args)
    305             pipe = os.popen(cmd)
     305            with os.popen(cmd) as pipe:
     306                for line in pipe:
     307                    words = line.lower().split()
     308                    for i in range(len(words)):
     309                        if words[i] in hw_identifiers:
     310                            return int(
     311                                words[get_index(i)].replace(':', ''), 16)
    306312        except IOError:
    307313            continue
    308 
    309         for line in pipe:
    310             words = line.lower().split()
    311             for i in range(len(words)):
    312                 if words[i] in hw_identifiers:
    313                     return int(words[get_index(i)].replace(':', ''), 16)
    314314    return None
    315315
     
    354354        except IOError:
    355355            continue
    356         for line in pipe:
    357             value = line.split(':')[-1].strip().lower()
    358             if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
    359                 return int(value.replace('-', ''), 16)
     356        else:
     357            for line in pipe:
     358                value = line.split(':')[-1].strip().lower()
     359                if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
     360                    return int(value.replace('-', ''), 16)
     361        finally:
     362            pipe.close()
    360363
    361364def _netbios_getnode():
     
    406409        if hasattr(lib, 'uuid_generate_time'):
    407410            _uuid_generate_time = lib.uuid_generate_time
     411            if _uuid_generate_random is not None:
     412                break  # found everything we were looking for
     413
     414    # The uuid_generate_* functions are broken on MacOS X 10.5, as noted
     415    # in issue #8621 the function generates the same sequence of values
     416    # in the parent process and all children created using fork (unless
     417    # those children use exec as well).
     418    #
     419    # Assume that the uuid_generate functions are broken from 10.5 onward,
     420    # the test can be adjusted when a later version is fixed.
     421    import sys
     422    if sys.platform == 'darwin':
     423        import os
     424        if int(os.uname()[2].split('.')[0]) >= 9:
     425            _uuid_generate_random = _uuid_generate_time = None
    408426
    409427    # On Windows prior to 2000, UuidCreate gives a UUID containing the
     
    490508    # 0x01b21dd213814000 is the number of 100-ns intervals between the
    491509    # UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
    492     timestamp = int(nanoseconds/100) + 0x01b21dd213814000L
    493     if timestamp <= _last_timestamp:
     510    timestamp = int(nanoseconds//100) + 0x01b21dd213814000L
     511    if _last_timestamp is not None and timestamp <= _last_timestamp:
    494512        timestamp = _last_timestamp + 1
    495513    _last_timestamp = timestamp
Note: See TracChangeset for help on using the changeset viewer.