mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Merged revisions 58939-58946 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r58940 | martin.v.loewis | 2007-11-12 05:53:02 +0100 (Mon, 12 Nov 2007) | 3 lines Only set rl_completion_display_matches_hook if there is a Python hook function. Fixes #1425. ........ r58941 | martin.v.loewis | 2007-11-12 06:14:05 +0100 (Mon, 12 Nov 2007) | 2 lines Patch #1418: Make the AC_REPLACE_FUNCS object files actually work. ........ r58942 | walter.doerwald | 2007-11-12 11:01:33 +0100 (Mon, 12 Nov 2007) | 2 lines Fix TextCalendar.prweek(). This closes issue #1427. ........
This commit is contained in:
parent
96f31636f4
commit
32fbe59978
4 changed files with 49 additions and 41 deletions
|
@ -263,7 +263,7 @@ class TextCalendar(Calendar):
|
||||||
"""
|
"""
|
||||||
Print a single week (no newline).
|
Print a single week (no newline).
|
||||||
"""
|
"""
|
||||||
print(self.week(theweek, width), end=' ')
|
print(self.formatweek(theweek, width), end=' ')
|
||||||
|
|
||||||
def formatday(self, day, weekday, width):
|
def formatday(self, day, weekday, width):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -169,6 +169,8 @@ THREADOBJ= @THREADOBJ@
|
||||||
DLINCLDIR= @DLINCLDIR@
|
DLINCLDIR= @DLINCLDIR@
|
||||||
DYNLOADFILE= @DYNLOADFILE@
|
DYNLOADFILE= @DYNLOADFILE@
|
||||||
MACHDEP_OBJS= @MACHDEP_OBJS@
|
MACHDEP_OBJS= @MACHDEP_OBJS@
|
||||||
|
LIBOBJDIR= Python/
|
||||||
|
LIBOBJS= @LIBOBJS@
|
||||||
UNICODE_OBJS= @UNICODE_OBJS@
|
UNICODE_OBJS= @UNICODE_OBJS@
|
||||||
|
|
||||||
PYTHON= python$(EXE)
|
PYTHON= python$(EXE)
|
||||||
|
@ -276,6 +278,7 @@ PYTHON_OBJS= \
|
||||||
Python/pystrtod.o \
|
Python/pystrtod.o \
|
||||||
Python/formatter_unicode.o \
|
Python/formatter_unicode.o \
|
||||||
Python/$(DYNLOADFILE) \
|
Python/$(DYNLOADFILE) \
|
||||||
|
$(LIBOBJS) \
|
||||||
$(MACHDEP_OBJS) \
|
$(MACHDEP_OBJS) \
|
||||||
$(THREADOBJ)
|
$(THREADOBJ)
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,10 @@
|
||||||
extern char **completion_matches(char *, rl_compentry_func_t *);
|
extern char **completion_matches(char *, rl_compentry_func_t *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_completion_display_matches_hook(char **matches,
|
||||||
|
int num_matches, int max_length);
|
||||||
|
|
||||||
|
|
||||||
/* Exported function to send one line to readline's init file parser */
|
/* Exported function to send one line to readline's init file parser */
|
||||||
|
|
||||||
|
@ -208,8 +212,17 @@ static PyObject *pre_input_hook = NULL;
|
||||||
static PyObject *
|
static PyObject *
|
||||||
set_completion_display_matches_hook(PyObject *self, PyObject *args)
|
set_completion_display_matches_hook(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
return set_hook("completion_display_matches_hook",
|
PyObject *result = set_hook("completion_display_matches_hook",
|
||||||
&completion_display_matches_hook, args);
|
&completion_display_matches_hook, args);
|
||||||
|
#ifdef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK
|
||||||
|
/* We cannot set this hook globally, since it replaces the
|
||||||
|
default completion display. */
|
||||||
|
rl_completion_display_matches_hook =
|
||||||
|
completion_display_matches_hook ?
|
||||||
|
(rl_compdisp_func_t *)on_completion_display_matches_hook : 0;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(doc_set_completion_display_matches_hook,
|
PyDoc_STRVAR(doc_set_completion_display_matches_hook,
|
||||||
|
@ -668,44 +681,41 @@ static void
|
||||||
on_completion_display_matches_hook(char **matches,
|
on_completion_display_matches_hook(char **matches,
|
||||||
int num_matches, int max_length)
|
int num_matches, int max_length)
|
||||||
{
|
{
|
||||||
if (completion_display_matches_hook != NULL) {
|
int i;
|
||||||
int i;
|
PyObject *m, *s;
|
||||||
PyObject *m, *s, *match;
|
PyObject *r;
|
||||||
PyObject *r;
|
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
PyGILState_STATE gilstate = PyGILState_Ensure();
|
PyGILState_STATE gilstate = PyGILState_Ensure();
|
||||||
#endif
|
#endif
|
||||||
m = PyList_New(num_matches);
|
m = PyList_New(num_matches);
|
||||||
for (i = 0; i < num_matches; i++) {
|
for (i = 0; i < num_matches; i++) {
|
||||||
s = PyUnicode_FromString(matches[i+1]);
|
s = PyUnicode_FromString(matches[i+1]);
|
||||||
if (s) {
|
if (s) {
|
||||||
PyList_SetItem(m, i, s);
|
PyList_SetItem(m, i, s);
|
||||||
}
|
|
||||||
else {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
r = PyObject_CallFunction(completion_display_matches_hook,
|
else {
|
||||||
"sOi", matches[0], m, max_length);
|
goto error;
|
||||||
|
|
||||||
Py_DECREF(m), m=NULL;
|
|
||||||
|
|
||||||
if (r == NULL ||
|
|
||||||
(r != Py_None && PyInt_AsLong(r) == -1 && PyErr_Occurred())) {
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_DECREF(r);
|
|
||||||
goto done;
|
|
||||||
error:
|
|
||||||
PyErr_Clear();
|
|
||||||
Py_XDECREF(m);
|
|
||||||
Py_XDECREF(r);
|
|
||||||
done:
|
|
||||||
#ifdef WITH_THREAD
|
|
||||||
PyGILState_Release(gilstate);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
r = PyObject_CallFunction(completion_display_matches_hook,
|
||||||
|
"sOi", matches[0], m, max_length);
|
||||||
|
|
||||||
|
Py_DECREF(m), m=NULL;
|
||||||
|
|
||||||
|
if (r == NULL ||
|
||||||
|
(r != Py_None && PyInt_AsLong(r) == -1 && PyErr_Occurred())) {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_DECREF(r);
|
||||||
|
goto done;
|
||||||
|
error:
|
||||||
|
PyErr_Clear();
|
||||||
|
Py_XDECREF(r);
|
||||||
|
done:
|
||||||
|
#ifdef WITH_THREAD
|
||||||
|
PyGILState_Release(gilstate);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -786,10 +796,6 @@ setup_readline(void)
|
||||||
rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap);
|
rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap);
|
||||||
rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap);
|
rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap);
|
||||||
/* Set our hook functions */
|
/* Set our hook functions */
|
||||||
#ifdef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK
|
|
||||||
rl_completion_display_matches_hook =
|
|
||||||
(rl_compdisp_func_t *)on_completion_display_matches_hook;
|
|
||||||
#endif
|
|
||||||
rl_startup_hook = (Function *)on_startup_hook;
|
rl_startup_hook = (Function *)on_startup_hook;
|
||||||
#ifdef HAVE_RL_PRE_INPUT_HOOK
|
#ifdef HAVE_RL_PRE_INPUT_HOOK
|
||||||
rl_pre_input_hook = (Function *)on_pre_input_hook;
|
rl_pre_input_hook = (Function *)on_pre_input_hook;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* hypot() replacement */
|
/* hypot() replacement */
|
||||||
|
|
||||||
#include "pyconfig.h"
|
#include "Python.h"
|
||||||
#include "pyport.h"
|
|
||||||
|
|
||||||
double hypot(double x, double y)
|
double hypot(double x, double y)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue