~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-10 06:26:39 UTC
  • mto: This revision was merged to the branch mainline in revision 2070.
  • Revision ID: john@arbash-meinel.com-20061010062639-6d527d0f9a3401d8
Catch an exception while opening /dev/urandom rather than using os.path.exists()

Show diffs side-by-side

added added

removed removed

Lines of Context:
659
659
except (NotImplementedError, AttributeError):
660
660
    # If python doesn't have os.urandom, or it doesn't work,
661
661
    # then try to first pull random data from /dev/urandom
662
 
    if os.path.exists("/dev/urandom"):
 
662
    try:
663
663
        rand_bytes = file('/dev/urandom', 'rb').read
664
664
    # Otherwise, use this hack as a last resort
665
 
    else:
 
665
    except (IOError, OSError):
666
666
        # not well seeded, but better than nothing
667
667
        def rand_bytes(n):
668
668
            import random