Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Doc/library/dataclasses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ Module contents
:class:`object`, this means it will fall back to id-based hashing).

- *frozen*: If true (the default is ``False``), assigning to fields will
generate an exception. This emulates read-only frozen instances. If
:meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class, then
:exc:`TypeError` is raised. See the discussion below.
generate an exception. This emulates read-only frozen instances.
See the :ref:`discussion <dataclasses-frozen>` below.

If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class
and *frozen* is true, then :exc:`TypeError` is raised.

- *match_args*: If true (the default is ``True``), the
:attr:`~object.__match_args__` tuple will be created from the list of
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ Thread Safety
-------------

The logging module is intended to be thread-safe without any special work
needing to be done by its clients. It achieves this though using threading
needing to be done by its clients. It achieves this through using threading
locks; there is one lock to serialize access to the module's shared data, and
each handler also creates a lock to serialize access to its underlying I/O.

Expand Down
1 change: 0 additions & 1 deletion Doc/library/resource.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ this module for those platforms.
.. data:: RLIM_INFINITY

Constant used to represent the limit for an unlimited resource.
Its value is larger than any limited resource value.

.. versionchanged:: next
It is now always positive.
Expand Down
17 changes: 10 additions & 7 deletions Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ class BlockFinder:
"""Provide a tokeneater() method to detect the end of a code block."""
def __init__(self):
self.indent = 0
self.islambda = False
self.singleline = False
self.started = False
self.passline = False
self.indecorator = False
Expand All @@ -1065,19 +1065,22 @@ def __init__(self):

def tokeneater(self, type, token, srowcol, erowcol, line):
if not self.started and not self.indecorator:
if type == tokenize.INDENT or token == "async":
pass
# skip any decorators
if token == "@":
elif token == "@":
self.indecorator = True
# look for the first "def", "class" or "lambda"
elif token in ("def", "class", "lambda"):
if token == "lambda":
self.islambda = True
else:
# For "def" and "class" scan to the end of the block.
# For "lambda" and generator expression scan to
# the end of the logical line.
self.singleline = token not in ("def", "class")
self.started = True
self.passline = True # skip to the end of the line
elif type == tokenize.NEWLINE:
self.passline = False # stop skipping when a NEWLINE is seen
self.last = srowcol[0]
if self.islambda: # lambdas always end at the first NEWLINE
if self.singleline:
raise EndOfBlock
# hitting a NEWLINE when in a decorator without args
# ends the decorator
Expand Down
20 changes: 20 additions & 0 deletions Lib/test/test_inspect/inspect_fodder2.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,23 @@ class dc364:
# line 369
dc370 = dataclasses.make_dataclass('dc370', (('x', int), ('y', int)))
dc371 = dataclasses.make_dataclass('dc370', (('x', int), ('y', int)), module=__name__)

import inspect
import itertools

# line 376
ge377 = (
inspect.currentframe()
for i in itertools.count()
)

# line 382
def func383():
# line 384
ge385 = (
inspect.currentframe()
for i in itertools.count()
)
return ge385

pass # end of file
6 changes: 6 additions & 0 deletions Lib/test/test_inspect/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,12 +1189,18 @@ def test_nested_class_definition_inside_async_function(self):

self.assertSourceEqual(run(mod2.func225), 226, 227)
self.assertSourceEqual(mod2.cls226, 231, 235)
self.assertSourceEqual(mod2.cls226.func232, 232, 235)
self.assertSourceEqual(run(mod2.cls226().func232), 233, 234)

def test_class_definition_same_name_diff_methods(self):
self.assertSourceEqual(mod2.cls296, 296, 298)
self.assertSourceEqual(mod2.cls310, 310, 312)

def test_generator_expression(self):
self.assertSourceEqual(next(mod2.ge377), 377, 380)
self.assertSourceEqual(next(mod2.func383()), 385, 388)


class TestNoEOL(GetSourceBase):
def setUp(self):
self.tempdir = TESTFN + '_dir'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the JIT's handling of many local variables. This previously caused a segfault.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :func:`!inspect.getblock`, :func:`inspect.getsourcelines` and
:func:`inspect.getsource` for generator expressions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:data:`resource.RLIM_INFINITY` is now always a positive integer larger than
any limited resource value. This simplifies comparison of the resource
values. Previously, it could be negative, such as -1 or -3, depending on
platform.
:data:`resource.RLIM_INFINITY` is now always a positive integer.
On all supported platforms, it is larger than any limited resource value,
which simplifies comparison of the resource values.
Previously, it could be negative, such as -1 or -3, depending on platform.
5 changes: 1 addition & 4 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,10 @@ optimize_uops(
_Py_uop_abstractcontext_init(ctx);
_Py_UOpsAbstractFrame *frame = _Py_uop_frame_new(ctx, co, curr_stacklen, NULL, 0);
if (frame == NULL) {
return -1;
return 0;
}
ctx->curr_frame_depth++;
ctx->frame = frame;
ctx->done = false;
ctx->out_of_space = false;
ctx->contradiction = false;

_PyUOpInstruction *this_instr = NULL;
for (int i = 0; !ctx->done; i++) {
Expand Down
7 changes: 7 additions & 0 deletions Python/optimizer_symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,13 @@ _Py_uop_abstractcontext_init(JitOptContext *ctx)

// Frame setup
ctx->curr_frame_depth = 0;

// Ctx signals.
// Note: this must happen before frame_new, as it might override
// the result should frame_new set things to bottom.
ctx->done = false;
ctx->out_of_space = false;
ctx->contradiction = false;
}

int
Expand Down
Loading