<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def detect_version(env, cc):
 """Return the version of the GNU compiler, or None if it is not a GNU compiler."""

    cc = env.subst(cc)
    if not cc:
        return None
    version = None
    #pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['-dumpversion'],
    pipe = SCons.Action._subproc(env, SCons.Util.CLVar(cc) + ['--version'],
                                 stdin = 'devnull',
                                 stderr = 'devnull',
                                 stdout = subprocess.PIPE)
    # -dumpversion was added in GCC 3.0.  As long as we're supporting
    # GCC versions older than that, we should use --version and a
    # regular expression.
    #line = pipe.stdout.read().strip()
    #if line:
    #    version = line
    line = SCons.Util.to_str(pipe.stdout.readline())
    match = re.search(r'[0-9]+(\.[0-9]+)+', line)
    if match:
        version = match.group(0)
    # Non-GNU compiler's output (like AIX xlc's) may exceed the stdout buffer:
    # So continue with reading to let the child process actually terminate.
    while SCons.Util.to_str(pipe.stdout.readline()):
        pass
    ret = pipe.wait()
    if ret != 0:
        return None
    return version