~ubuntu-branches/ubuntu/trusty/python3.4/trusty-proposed

« back to all changes in this revision

Viewing changes to Lib/test/tf_inherit_check.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-11-25 09:44:27 UTC
  • Revision ID: package-import@ubuntu.com-20131125094427-lzxj8ap5w01lmo7f
Tags: upstream-3.4~b1
ImportĀ upstreamĀ versionĀ 3.4~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Helper script for test_tempfile.py.  argv[2] is the number of a file
 
2
# descriptor which should _not_ be open.  Check this by attempting to
 
3
# write to it -- if we succeed, something is wrong.
 
4
 
 
5
import sys
 
6
import os
 
7
 
 
8
verbose = (sys.argv[1] == 'v')
 
9
try:
 
10
    fd = int(sys.argv[2])
 
11
 
 
12
    try:
 
13
        os.write(fd, b"blat")
 
14
    except OSError:
 
15
        # Success -- could not write to fd.
 
16
        sys.exit(0)
 
17
    else:
 
18
        if verbose:
 
19
            sys.stderr.write("fd %d is open in child" % fd)
 
20
        sys.exit(1)
 
21
 
 
22
except Exception:
 
23
    if verbose:
 
24
        raise
 
25
    sys.exit(1)