Staging
v0.5.1
https://github.com/python/cpython
Revision ab577c1b32a09348aa0470df00cd4865b9e28a31 authored by Neal Norwitz on 27 January 2008, 01:24:44 UTC, committed by Neal Norwitz on 27 January 2008, 01:24:44 UTC
Let the O/S supply a port if none of the default ports can be used.
This should make the tests more robust at the expense of allowing
tests to be sloppier by not requiring them to cleanup after themselves.
(It will legitamitely help when running two test suites simultaneously
or if another process is already using one of the predefined ports.)

This will hopefully fix test_asynchat.
1 parent b03528c
Raw File
Tip revision: ab577c1b32a09348aa0470df00cd4865b9e28a31 authored by Neal Norwitz on 27 January 2008, 01:24:44 UTC
Backport r58453:
Tip revision: ab577c1
fixheader.py
#! /usr/bin/env python

# Add some standard cpp magic to a header file

import sys

def main():
    args = sys.argv[1:]
    for filename in args:
        process(filename)

def process(filename):
    try:
        f = open(filename, 'r')
    except IOError, msg:
        sys.stderr.write('%s: can\'t open: %s\n' % (filename, str(msg)))
        return
    data = f.read()
    f.close()
    if data[:2] <> '/*':
        sys.stderr.write('%s does not begin with C comment\n' % filename)
        return
    try:
        f = open(filename, 'w')
    except IOError, msg:
        sys.stderr.write('%s: can\'t write: %s\n' % (filename, str(msg)))
        return
    sys.stderr.write('Processing %s ...\n' % filename)
    magic = 'Py_'
    for c in filename:
        if ord(c)<=0x80 and c.isalnum():
            magic = magic + c.upper()
        else: magic = magic + '_'
    sys.stdout = f
    print '#ifndef', magic
    print '#define', magic
    print '#ifdef __cplusplus'
    print 'extern "C" {'
    print '#endif'
    print
    f.write(data)
    print
    print '#ifdef __cplusplus'
    print '}'
    print '#endif'
    print '#endif /*', '!'+magic, '*/'

if __name__ == '__main__':
    main()
back to top