Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(45382)

Side by Side Diff: Modules/readline.c

Issue 25203: Incorrect handling MemoryError in readline.set_completer_delims
Patch Set: Created 4 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* This module makes GNU readline available to Python. It has ideas 1 /* This module makes GNU readline available to Python. It has ideas
2 * contributed by Lee Busby, LLNL, and William Magro, Cornell Theory 2 * contributed by Lee Busby, LLNL, and William Magro, Cornell Theory
3 * Center. The completer interface was inspired by Lele Gaifax. More 3 * Center. The completer interface was inspired by Lele Gaifax. More
4 * recently, it was largely rewritten by Guido van Rossum. 4 * recently, it was largely rewritten by Guido van Rossum.
5 */ 5 */
6 6
7 /* Standard definitions */ 7 /* Standard definitions */
8 #include "Python.h" 8 #include "Python.h"
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <setjmp.h> 10 #include <setjmp.h>
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 set_completer_delims(PyObject *self, PyObject *args) 457 set_completer_delims(PyObject *self, PyObject *args)
458 { 458 {
459 char *break_chars; 459 char *break_chars;
460 460
461 if (!PyArg_ParseTuple(args, "s:set_completer_delims", &break_chars)) { 461 if (!PyArg_ParseTuple(args, "s:set_completer_delims", &break_chars)) {
462 return NULL; 462 return NULL;
463 } 463 }
464 /* Keep a reference to the allocated memory in the module state in case 464 /* Keep a reference to the allocated memory in the module state in case
465 some other module modifies rl_completer_word_break_characters 465 some other module modifies rl_completer_word_break_characters
466 (see issue #17289). */ 466 (see issue #17289). */
467 free(completer_word_break_characters); 467 break_chars = strdup(break_chars);
468 completer_word_break_characters = strdup(break_chars); 468 if (break_chars) {
469 if (completer_word_break_characters) { 469 free(completer_word_break_characters);
470 rl_completer_word_break_characters = completer_word_break_characters; 470 completer_word_break_characters = break_chars;
471 rl_completer_word_break_characters = break_chars;
471 Py_RETURN_NONE; 472 Py_RETURN_NONE;
472 } 473 }
473 else 474 else
474 return PyErr_NoMemory(); 475 return PyErr_NoMemory();
475 } 476 }
476 477
477 PyDoc_STRVAR(doc_set_completer_delims, 478 PyDoc_STRVAR(doc_set_completer_delims,
478 "set_completer_delims(string) -> None\n\ 479 "set_completer_delims(string) -> None\n\
479 set the readline word delimiters for tab-completion"); 480 set the readline word delimiters for tab-completion");
480 481
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 1324
1324 mod_state = (readlinestate *) PyModule_GetState(m); 1325 mod_state = (readlinestate *) PyModule_GetState(m);
1325 PyOS_ReadlineFunctionPointer = call_readline; 1326 PyOS_ReadlineFunctionPointer = call_readline;
1326 setup_readline(mod_state); 1327 setup_readline(mod_state);
1327 1328
1328 PyModule_AddIntConstant(m, "_READLINE_VERSION", RL_READLINE_VERSION); 1329 PyModule_AddIntConstant(m, "_READLINE_VERSION", RL_READLINE_VERSION);
1329 PyModule_AddIntConstant(m, "_READLINE_RUNTIME_VERSION", rl_readline_version) ; 1330 PyModule_AddIntConstant(m, "_READLINE_RUNTIME_VERSION", rl_readline_version) ;
1330 1331
1331 return m; 1332 return m;
1332 } 1333 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+