def add_extension(module, name, code):
code = int(code)<EOL>if not <NUM_LIT:1> <= code <= <NUM_LIT>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>key = (module, name)<EOL>if (_extension_registry.get(key) == code and<EOL>_inverted_registry.get(code) == key):<EOL><INDENT>return <EOL><DEDENT>if key in _extension_registry:<EOL><INDENT>raise ValueError("<STR_LIT>" %<EOL>(key, _extension_registry[key]))<EOL><DEDENT>if code in _inverted_registry:<EOL><INDENT>raise ValueError("<STR_LIT>" %<EOL>(code, _inverted_registry[code]))<EOL><DEDENT>_extension_registry[key] = code<EOL>_inverted_registry[code] = key<EOL>
Register an extension code.