def clean_bytecode_extension(filename):
    """
    Replaces Python bytecode extensions (``.pyc``) with their source extension.
    """
    path, extension = os.path.splitext(filename)
    if extension == '.pyc':
        filename = '%s.py' % path
    return filename