Merge remote-tracking branch 'upstream/main'

This commit is contained in:
Pablo Galindo 2022-02-03 22:56:59 +00:00
commit bd8b05395a
No known key found for this signature in database
GPG Key ID: FFE87404168BD847
14 changed files with 46 additions and 35 deletions

View File

@ -87,12 +87,12 @@ static inline void _PyFrame_StackPush(InterpreterFrame *f, PyObject *value) {
void _PyFrame_Copy(InterpreterFrame *src, InterpreterFrame *dest);
/* Consumes reference to func */
static inline void
_PyFrame_InitializeSpecials(
InterpreterFrame *frame, PyFunctionObject *func,
PyObject *locals, int nlocalsplus)
{
Py_INCREF(func);
frame->f_func = func;
frame->f_code = (PyCodeObject *)Py_NewRef(func->func_code);
frame->f_builtins = func->func_builtins;
@ -166,9 +166,6 @@ _PyFrame_FastToLocalsWithError(InterpreterFrame *frame);
void
_PyFrame_LocalsToFast(InterpreterFrame *frame, int clear);
InterpreterFrame *_PyThreadState_PushFrame(
PyThreadState *tstate, PyFunctionObject *func, PyObject *locals);
extern InterpreterFrame *
_PyThreadState_BumpFramePointerSlow(PyThreadState *tstate, size_t size);
@ -189,6 +186,7 @@ _PyThreadState_BumpFramePointer(PyThreadState *tstate, size_t size)
void _PyThreadState_PopFrame(PyThreadState *tstate, InterpreterFrame *frame);
/* Consume reference to func */
InterpreterFrame *
_PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func);

View File

@ -4,6 +4,9 @@ Released on 2022-10-03
=========================
bpo-46630: Make query dialogs on Windows start with a cursor in the
entry box.
bpo-46591: Make the IDLE doc URL on the About IDLE dialog clickable.
bpo-45296: Clarify close, quit, and exit in IDLE. In the File menu,

View File

@ -179,7 +179,7 @@ class Parser:
# Peeking back worked; look forward until _synchre no longer
# matches.
i = pos + 1
while (m := _synchre(code, i)):
while m := _synchre(code, i):
s, i = m.span()
if not is_char_in_string(s):
pos = s

View File

@ -83,6 +83,7 @@ class Query(Toplevel):
if not _utest:
self.deiconify() # Unhide now that geometry set.
self.entry.focus_set()
self.wait_window()
def create_widgets(self, ok_text='OK'): # Do not replace.
@ -100,7 +101,6 @@ class Query(Toplevel):
text=self.message)
self.entryvar = StringVar(self, self.text0)
self.entry = Entry(frame, width=30, textvariable=self.entryvar)
self.entry.focus_set()
self.error_font = Font(name='TkCaptionFont',
exists=True, root=self.parent)
self.entry_error = Label(frame, text=' ', foreground='red',

View File

@ -158,8 +158,8 @@ class ReplaceDialog(SearchDialogBase):
first = last = None
# XXX ought to replace circular instead of top-to-bottom when wrapping
text.undo_block_start()
while (res := self.engine.search_forward(
text, prog, line, col, wrap=False, ok=ok)):
while res := self.engine.search_forward(
text, prog, line, col, wrap=False, ok=ok):
line, m = res
chars = text.get("%d.0" % line, "%d.0" % (line+1))
orig = m.group()

View File

@ -482,7 +482,7 @@ class StdInputFile(StdioFile):
result = self._line_buffer
self._line_buffer = ''
if size < 0:
while (line := self.shell.readline()):
while line := self.shell.readline():
result += line
else:
while len(result) < size:

View File

@ -0,0 +1 @@
Make query dialogs on Windows start with a cursor in the entry box.

View File

@ -0,0 +1 @@
Expose Linux's ``IP_BIND_ADDRESS_NO_PORT`` option in :mod:`socket`.

View File

@ -8072,6 +8072,9 @@ PyInit__socket(void)
#ifdef IP_TRANSPARENT
PyModule_AddIntMacro(m, IP_TRANSPARENT);
#endif
#ifdef IP_BIND_ADDRESS_NO_PORT
PyModule_AddIntMacro(m, IP_BIND_ADDRESS_NO_PORT);
#endif
/* IPv6 [gs]etsockopt options, defined in RFC2553 */
#ifdef IPV6_JOIN_GROUP

View File

@ -784,6 +784,8 @@ _Py_IDENTIFIER(__builtins__);
static void
init_frame(InterpreterFrame *frame, PyFunctionObject *func, PyObject *locals)
{
/* _PyFrame_InitializeSpecials consumes reference to func */
Py_INCREF(func);
PyCodeObject *code = (PyCodeObject *)func->func_code;
_PyFrame_InitializeSpecials(frame, func, locals, code->co_nlocalsplus);
for (Py_ssize_t i = 0; i < code->co_nlocalsplus; i++) {

View File

@ -2243,6 +2243,7 @@ handle_eval_breaker:
goto error;
}
CALL_STAT_INC(frames_pushed);
Py_INCREF(getitem);
_PyFrame_InitializeSpecials(new_frame, getitem,
NULL, code->co_nlocalsplus);
STACK_SHRINK(2);
@ -2791,6 +2792,12 @@ handle_eval_breaker:
TARGET(UNPACK_SEQUENCE) {
PREDICTED(UNPACK_SEQUENCE);
PyObject *seq = POP(), *item, **items;
#ifdef Py_STATS
extern int _PySpecialization_ClassifySequence(PyObject *);
_py_stats.opcode_stats[UNPACK_SEQUENCE].specialization.failure++;
_py_stats.opcode_stats[UNPACK_SEQUENCE].specialization.
failure_kinds[_PySpecialization_ClassifySequence(seq)]++;
#endif
if (PyTuple_CheckExact(seq) &&
PyTuple_GET_SIZE(seq) == oparg) {
items = ((PyTupleObject *)seq)->ob_item;
@ -4590,7 +4597,6 @@ handle_eval_breaker:
STACK_SHRINK(call_shape.postcall_shrink);
// The frame has stolen all the arguments from the stack,
// so there is no need to clean them up.
Py_DECREF(function);
if (new_frame == NULL) {
goto error;
}
@ -4675,7 +4681,6 @@ handle_eval_breaker:
new_frame->localsplus[i] = NULL;
}
STACK_SHRINK(call_shape.postcall_shrink);
Py_DECREF(func);
_PyFrame_SetStackPointer(frame, stack_pointer);
new_frame->previous = frame;
frame = cframe.current_frame = new_frame;
@ -4712,7 +4717,6 @@ handle_eval_breaker:
new_frame->localsplus[i] = NULL;
}
STACK_SHRINK(call_shape.postcall_shrink);
Py_DECREF(func);
_PyFrame_SetStackPointer(frame, stack_pointer);
new_frame->previous = frame;
frame = cframe.current_frame = new_frame;
@ -6077,7 +6081,7 @@ fail_post_args:
return -1;
}
/* Consumes all the references to the args */
/* Consumes references to func and all the args */
static InterpreterFrame *
_PyEvalFramePushAndInit(PyThreadState *tstate, PyFunctionObject *func,
PyObject *locals, PyObject* const* args,
@ -6131,7 +6135,9 @@ _PyEval_Vector(PyThreadState *tstate, PyFunctionObject *func,
PyObject* const* args, size_t argcount,
PyObject *kwnames)
{
/* _PyEvalFramePushAndInit consumes all the references to its arguments */
/* _PyEvalFramePushAndInit consumes the references
* to func and all its arguments */
Py_INCREF(func);
for (size_t i = 0; i < argcount; i++) {
Py_INCREF(args[i]);
}

View File

@ -109,6 +109,7 @@ _PyFrame_Clear(InterpreterFrame *frame)
Py_DECREF(frame->f_code);
}
/* Consumes reference to func */
InterpreterFrame *
_PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func)
{
@ -117,6 +118,7 @@ _PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func)
CALL_STAT_INC(frames_pushed);
InterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size);
if (new_frame == NULL) {
Py_DECREF(func);
return NULL;
}
_PyFrame_InitializeSpecials(new_frame, func, NULL, code->co_nlocalsplus);

View File

@ -2212,26 +2212,6 @@ _PyThreadState_BumpFramePointerSlow(PyThreadState *tstate, size_t size)
return (InterpreterFrame *)base;
}
InterpreterFrame *
_PyThreadState_PushFrame(PyThreadState *tstate, PyFunctionObject *func, PyObject *locals)
{
PyCodeObject *code = (PyCodeObject *)func->func_code;
int nlocalsplus = code->co_nlocalsplus;
size_t size = nlocalsplus + code->co_stacksize +
FRAME_SPECIALS_SIZE;
CALL_STAT_INC(frames_pushed);
InterpreterFrame *frame = _PyThreadState_BumpFramePointer(tstate, size);
if (frame == NULL) {
return NULL;
}
_PyFrame_InitializeSpecials(frame, func, locals, nlocalsplus);
for (int i=0; i < nlocalsplus; i++) {
frame->localsplus[i] = NULL;
}
return frame;
}
void
_PyThreadState_PopFrame(PyThreadState *tstate, InterpreterFrame * frame)
{

View File

@ -572,6 +572,10 @@ initial_counter_value(void) {
#define SPEC_FAIL_ITER_DICT_VALUES 22
#define SPEC_FAIL_ITER_ENUMERATE 23
/* UNPACK_SEQUENCE */
#define SPEC_FAIL_TUPLE 10
#define SPEC_FAIL_LIST 11
static int
specialize_module_load_attr(
@ -1880,7 +1884,6 @@ success:
adaptive->counter = initial_counter_value();
}
int
_PySpecialization_ClassifyIterator(PyObject *iter)
{
@ -1930,3 +1933,15 @@ int
}
return SPEC_FAIL_OTHER;
}
int
_PySpecialization_ClassifySequence(PyObject *seq)
{
if (PyTuple_CheckExact(seq)) {
return SPEC_FAIL_TUPLE;
}
if (PyList_CheckExact(seq)) {
return SPEC_FAIL_LIST;
}
return SPEC_FAIL_OTHER;
}