Box* frozensetNew(Box* _cls, Box* container, BoxedDict* kwargs) { RELEASE_ASSERT(_cls->cls == type_cls, ""); BoxedClass* cls = static_cast<BoxedClass*>(_cls); RELEASE_ASSERT(isSubclass(cls, frozenset_cls), ""); if (_cls == frozenset_cls && !_PyArg_NoKeywords("frozenset()", kwargs)) { throwCAPIException(); } if (_cls != frozenset_cls) { return makeNewSet(cls, container); } if (container != NULL) { if (container->cls == frozenset_cls) return incref(container); BoxedSet* result = makeNewSet(cls, container); if (result->s.size() != 0) { return result; } Py_DECREF(result); } static Box* emptyfrozenset = NULL; if (!emptyfrozenset) { emptyfrozenset = new (frozenset_cls) BoxedSet(); PyGC_RegisterStaticConstant(emptyfrozenset); } Py_INCREF(emptyfrozenset); return emptyfrozenset; }
extern "C" PyCodeObject* PyCode_NewEmpty(const char* filename, const char* funcname, int firstlineno) noexcept { static PyObject* emptystring = NULL; static PyObject* nulltuple = NULL; PyObject* filename_ob = NULL; PyObject* funcname_ob = NULL; PyCodeObject* result = NULL; if (emptystring == NULL) { emptystring = PyGC_RegisterStaticConstant(PyString_FromString("")); if (emptystring == NULL) goto failed; } if (nulltuple == NULL) { nulltuple = PyGC_RegisterStaticConstant(PyTuple_New(0)); if (nulltuple == NULL) goto failed; } funcname_ob = PyString_FromString(funcname); if (funcname_ob == NULL) goto failed; filename_ob = PyString_FromString(filename); if (filename_ob == NULL) goto failed; result = PyCode_New(0, /* argcount */ 0, /* nlocals */ 0, /* stacksize */ 0, /* flags */ emptystring, /* code */ nulltuple, /* consts */ nulltuple, /* names */ nulltuple, /* varnames */ nulltuple, /* freevars */ nulltuple, /* cellvars */ filename_ob, /* filename */ funcname_ob, /* name */ firstlineno, /* firstlineno */ emptystring /* lnotab */ ); failed: Py_XDECREF(funcname_ob); Py_XDECREF(filename_ob); return result; }
static void setup_readline(void) { #ifdef SAVE_LOCALE char *saved_locale = strdup(setlocale(LC_CTYPE, NULL)); if (!saved_locale) Py_FatalError("not enough memory to save locale"); #endif #ifdef __APPLE__ /* the libedit readline emulation resets key bindings etc * when calling rl_initialize. So call it upfront */ if (using_libedit_emulation) rl_initialize(); /* Detect if libedit's readline emulation uses 0-based * indexing or 1-based indexing. */ add_history("1"); if (history_get(1) == NULL) { libedit_history_start = 0; } else { libedit_history_start = 1; } clear_history(); #endif /* __APPLE__ */ using_history(); rl_readline_name = "python"; #if defined(PYOS_OS2) && defined(PYCC_GCC) /* Allow $if term= in .inputrc to work */ rl_terminal_name = getenv("TERM"); #endif /* Force rebind of TAB to insert-tab */ rl_bind_key('\t', rl_insert); /* Bind both ESC-TAB and ESC-ESC to the completion function */ rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap); rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap); /* Set our hook functions */ rl_startup_hook = on_startup_hook; #ifdef HAVE_RL_PRE_INPUT_HOOK rl_pre_input_hook = on_pre_input_hook; #endif /* Set our completion function */ rl_attempted_completion_function = flex_complete; /* Set Python word break characters */ completer_word_break_characters = rl_completer_word_break_characters = strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?"); /* All nonalphanums except '.' */ begidx = PyGC_RegisterStaticConstant(PyInt_FromLong(0L)); endidx = PyGC_RegisterStaticConstant(PyInt_FromLong(0L)); PyGC_RegisterStaticConstantLocation(&completer); /* Initialize (allows .inputrc to override) * * XXX: A bug in the readline-2.2 library causes a memory leak * inside this function. Nothing we can do about it. */ #ifdef __APPLE__ if (using_libedit_emulation) rl_read_init_file(NULL); else #endif /* __APPLE__ */ rl_initialize(); RESTORE_LOCALE(saved_locale) }