Skip to content

Commit

Permalink
Merge branch 'main' into inlinecomp2
Browse files Browse the repository at this point in the history
* main:
  pythongh-101440: fix json snippet error in logging-cookbook.rst (python#101439)
  pythongh-99276 - Updated Doc/faq/general.rst (python#101396)
  Add JOBS parameter to docs Makefile (python#101395)
  pythongh-98831: rewrite GET_LEN, GET_ITER, BEFORE_WITH and a few simple opcodes in the instruction definition DSL (python#101443)
  pythongh-77607: Improve accuracy of os.path.join docs (python#101406)
  Fixes typo in asyncio.TaskGroup context manager code example (python#101449)
  pythongh-98831: Clean up and add cache size static_assert to macro (python#101442)
  pythongh-99955: use SUCCESS/ERROR return values in optimizer and assembler. Use RETURN_IF_ERROR where appropriate. Fix a couple of bugs. (python#101412)
  • Loading branch information
carljm committed Jan 31, 2023
2 parents 43db9b8 + 20c11f2 commit ed3209b
Show file tree
Hide file tree
Showing 11 changed files with 236 additions and 272 deletions.
3 changes: 2 additions & 1 deletion Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ VENVDIR = ./venv
SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build
SPHINXLINT = PATH=$(VENVDIR)/bin:$$PATH sphinx-lint
BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
JOBS = auto
PAPER =
SOURCES =
DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
Expand All @@ -18,7 +19,7 @@ SPHINXERRORHANDLING = -W
PAPEROPT_a4 = -D latex_elements.papersize=a4paper
PAPEROPT_letter = -D latex_elements.papersize=letterpaper

ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j auto \
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) -j $(JOBS) \
$(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)

.PHONY: help
Expand Down
4 changes: 2 additions & 2 deletions Doc/faq/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ Are there any published articles about Python that I can reference?

It's probably best to cite your favorite book about Python.

The very first article about Python was written in 1991 and is now quite
outdated.
The `very first article <https://ir.cwi.nl/pub/18204>`_ about Python was
written in 1991 and is now quite outdated.

Guido van Rossum and Jelke de Boer, "Interactively Testing Remote Servers
Using the Python Programming Language", CWI Quarterly, Volume 4, Issue 4
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ Suppose you configure logging with the following JSON:
"class": "logging.StreamHandler",
"level": "INFO",
"formatter": "simple",
"stream": "ext://sys.stdout",
"stream": "ext://sys.stdout"
},
"stderr": {
"class": "logging.StreamHandler",
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ To actually run a coroutine, asyncio provides the following mechanisms:

print(f"started at {time.strftime('%X')}")

# The wait is implicit when the context manager exits.
# The await is implicit when the context manager exits.

print(f"finished at {time.strftime('%X')}")

Expand Down
10 changes: 5 additions & 5 deletions Doc/library/os.path.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ the :mod:`glob` module.)

Join one or more path segments intelligently. The return value is the
concatenation of *path* and all members of *\*paths*, with exactly one
directory separator following each non-empty part except the last. That is,
if the last part is empty, the result will end in a separator. If
a segment is an absolute path (which on Windows requires both a drive and a
root), then all previous segments are ignored and joining continues from the
absolute path segment.
directory separator following each non-empty part, except the last. That is,
the result will only end in a separator if the last part is either empty or
ends in a separator. If a segment is an absolute path (which on Windows
requires both a drive and a root), then all previous segments are ignored and
joining continues from the absolute path segment.

On Windows, the drive is not reset when a rooted path segment (e.g.,
``r'\foo'``) is encountered. If a segment is on a different drive or is an
Expand Down
57 changes: 21 additions & 36 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2058,8 +2058,7 @@ dummy_func(
}
}

// stack effect: ( -- )
inst(JUMP_BACKWARD_NO_INTERRUPT) {
inst(JUMP_BACKWARD_NO_INTERRUPT, (--)) {
/* This bytecode is used in the `yield from` or `await` loop.
* If there is an interrupt, we want it handled in the innermost
* generator or coroutine, so we deliberately do not check it here.
Expand All @@ -2068,18 +2067,12 @@ dummy_func(
JUMPBY(-oparg);
}

// stack effect: ( -- __0)
inst(GET_LEN) {
inst(GET_LEN, (obj -- obj, len_o)) {
// PUSH(len(TOS))
Py_ssize_t len_i = PyObject_Length(TOP());
if (len_i < 0) {
goto error;
}
PyObject *len_o = PyLong_FromSsize_t(len_i);
if (len_o == NULL) {
goto error;
}
PUSH(len_o);
Py_ssize_t len_i = PyObject_Length(obj);
ERROR_IF(len_i < 0, error);
len_o = PyLong_FromSsize_t(len_i);
ERROR_IF(len_o == NULL, error);
}

inst(MATCH_CLASS, (subject, type, names -- attrs)) {
Expand Down Expand Up @@ -2115,15 +2108,11 @@ dummy_func(
ERROR_IF(values_or_none == NULL, error);
}

// stack effect: ( -- )
inst(GET_ITER) {
inst(GET_ITER, (iterable -- iter)) {
/* before: [obj]; after [getiter(obj)] */
PyObject *iterable = TOP();
PyObject *iter = PyObject_GetIter(iterable);
Py_DECREF(iterable);
SET_TOP(iter);
if (iter == NULL)
goto error;
iter = PyObject_GetIter(iterable);
DECREF_INPUTS();
ERROR_IF(iter == NULL, error);
}

// stack effect: ( -- )
Expand Down Expand Up @@ -2318,10 +2307,10 @@ dummy_func(
PREDICT(GET_AWAITABLE);
}

// stack effect: ( -- __0)
inst(BEFORE_WITH) {
PyObject *mgr = TOP();
PyObject *res;
inst(BEFORE_WITH, (mgr -- exit, res)) {
/* pop the context manager, push its __exit__ and the
* value returned from calling its __enter__
*/
PyObject *enter = _PyObject_LookupSpecial(mgr, &_Py_ID(__enter__));
if (enter == NULL) {
if (!_PyErr_Occurred(tstate)) {
Expand All @@ -2332,7 +2321,7 @@ dummy_func(
}
goto error;
}
PyObject *exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
exit = _PyObject_LookupSpecial(mgr, &_Py_ID(__exit__));
if (exit == NULL) {
if (!_PyErr_Occurred(tstate)) {
_PyErr_Format(tstate, PyExc_TypeError,
Expand All @@ -2344,14 +2333,13 @@ dummy_func(
Py_DECREF(enter);
goto error;
}
SET_TOP(exit);
Py_DECREF(mgr);
DECREF_INPUTS();
res = _PyObject_CallNoArgs(enter);
Py_DECREF(enter);
if (res == NULL) {
goto error;
Py_DECREF(exit);
ERROR_IF(true, error);
}
PUSH(res);
}

inst(WITH_EXCEPT_START, (exit_func, lasti, unused, val -- exit_func, lasti, unused, val, res)) {
Expand Down Expand Up @@ -2474,8 +2462,7 @@ dummy_func(
GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS);
}

// stack effect: ( -- )
inst(KW_NAMES) {
inst(KW_NAMES, (--)) {
assert(kwnames == NULL);
assert(oparg < PyTuple_GET_SIZE(consts));
kwnames = GETITEM(consts, oparg);
Expand Down Expand Up @@ -3257,8 +3244,7 @@ dummy_func(
PEEK(oparg) = top;
}

// stack effect: ( -- )
inst(EXTENDED_ARG) {
inst(EXTENDED_ARG, (--)) {
assert(oparg);
assert(cframe.use_tracing == 0);
opcode = _Py_OPCODE(*next_instr);
Expand All @@ -3267,8 +3253,7 @@ dummy_func(
DISPATCH_GOTO();
}

// stack effect: ( -- )
inst(CACHE) {
inst(CACHE, (--)) {
Py_UNREACHABLE();
}

Expand Down
Loading

0 comments on commit ed3209b

Please sign in to comment.