Skip to content

Commit 550eabe

Browse files
Update latest Python module code
Use Python 3.x readline.c from GitHub 3.13 branch (commit 417dd3a dated 2024-05-06, released as part of 3.13.0). Add corresponding Argument Clinic header file, readline.c.h (commit be5e8a0 dated exactly a year ago on 2023-10-17, also part of 3.13.0). As a reminder, we currently patch the following in readline.c: - Rename module name in PyModuleDef struct: "readline" -> "gnureadline" - Rename function: PyInit_readline -> PyInit_gnureadline - Add: #undef WITH_EDITLINE - Include "../../readline/readline.h" and not <readline/readline.h> - Include "../../readline/history.h" and not <readline/history.h>
1 parent 1fb1f92 commit 550eabe

File tree

2 files changed

+108
-50
lines changed

2 files changed

+108
-50
lines changed

Modules/3.x/clinic/readline.c.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
preserve
33
[clinic start generated code]*/
44

5-
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6-
# include "pycore_gc.h" // PyGC_Head
7-
# include "pycore_runtime.h" // _Py_ID()
8-
#endif
9-
5+
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
106

117
PyDoc_STRVAR(readline_parse_and_bind__doc__,
128
"parse_and_bind($module, string, /)\n"
@@ -146,7 +142,7 @@ readline_append_history_file(PyObject *module, PyObject *const *args, Py_ssize_t
146142
if (!_PyArg_CheckPositional("append_history_file", nargs, 1, 2)) {
147143
goto exit;
148144
}
149-
nelements = _PyLong_AsInt(args[0]);
145+
nelements = PyLong_AsInt(args[0]);
150146
if (nelements == -1 && PyErr_Occurred()) {
151147
goto exit;
152148
}
@@ -183,7 +179,7 @@ readline_set_history_length(PyObject *module, PyObject *arg)
183179
PyObject *return_value = NULL;
184180
int length;
185181

186-
length = _PyLong_AsInt(arg);
182+
length = PyLong_AsInt(arg);
187183
if (length == -1 && PyErr_Occurred()) {
188184
goto exit;
189185
}
@@ -404,7 +400,7 @@ readline_remove_history_item(PyObject *module, PyObject *arg)
404400
PyObject *return_value = NULL;
405401
int entry_number;
406402

407-
entry_number = _PyLong_AsInt(arg);
403+
entry_number = PyLong_AsInt(arg);
408404
if (entry_number == -1 && PyErr_Occurred()) {
409405
goto exit;
410406
}
@@ -439,17 +435,14 @@ readline_replace_history_item(PyObject *module, PyObject *const *args, Py_ssize_
439435
if (!_PyArg_CheckPositional("replace_history_item", nargs, 2, 2)) {
440436
goto exit;
441437
}
442-
entry_number = _PyLong_AsInt(args[0]);
438+
entry_number = PyLong_AsInt(args[0]);
443439
if (entry_number == -1 && PyErr_Occurred()) {
444440
goto exit;
445441
}
446442
if (!PyUnicode_Check(args[1])) {
447443
_PyArg_BadArgument("replace_history_item", "argument 2", "str", args[1]);
448444
goto exit;
449445
}
450-
if (PyUnicode_READY(args[1]) == -1) {
451-
goto exit;
452-
}
453446
line = args[1];
454447
return_value = readline_replace_history_item_impl(module, entry_number, line);
455448

@@ -585,7 +578,7 @@ readline_get_history_item(PyObject *module, PyObject *arg)
585578
PyObject *return_value = NULL;
586579
int idx;
587580

588-
idx = _PyLong_AsInt(arg);
581+
idx = PyLong_AsInt(arg);
589582
if (idx == -1 && PyErr_Occurred()) {
590583
goto exit;
591584
}
@@ -691,4 +684,4 @@ readline_redisplay(PyObject *module, PyObject *Py_UNUSED(ignored))
691684
#ifndef READLINE_CLEAR_HISTORY_METHODDEF
692685
#define READLINE_CLEAR_HISTORY_METHODDEF
693686
#endif /* !defined(READLINE_CLEAR_HISTORY_METHODDEF) */
694-
/*[clinic end generated code: output=9097fcb749c19e27 input=a9049054013a1b77]*/
687+
/*[clinic end generated code: output=358ab465285c7949 input=a9049054013a1b77]*/

0 commit comments

Comments
 (0)