Mark Shannon added the comment:
It won't solve the problem.
Maybe make it would make it easier to avoid the segfault, but some sort of
recursion/overflow check is needed.
It might make the use of the trashcan cheaper, as it only need be used when
stack space is running low.
Ultim
Mark Shannon added the comment:
Try setting the recursion limit to 10 or so and it should terminate.
The reason ctrl-C doesn't work is that you are catching the KeyboardInterrupt.
Never use a plain `except:`, use `except Exception:`
--
nosy: +Mark.Sh
Mark Shannon added the comment:
Draft PEP here
https://github.com/markshannon/peps/blob/annotation-syntax-errors/pep-.rst
Guido, would you like to be co-author as it was your idea to make these things
a syntax error?
--
___
Python tracker
Mark Shannon added the comment:
Please leave the issue open. This is a real bug.
It may not be fixed right now, but that doesn't mean it won't ever be fixed.
--
nosy: +Mark.Shannon
___
Python tracker
<https://bugs.python.o
Mark Shannon added the comment:
If you make calls in an exception handler that is handling a RecursionError,
without unwinding first, then it is likely that another RecursionError may
occur.
What is strange is that the second RecursionError is raised after
`print(str(e))` has printed the
Change by Mark Shannon :
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue42693>
___
___
Mark Shannon added the comment:
Reducing the size of the frame object seems like a worthwhile goal, but what's
the point in increasing the maximum block stack?
--
nosy: +Mark.Shannon
___
Python tracker
<https://bugs.python.org/is
Change by Mark Shannon :
--
keywords: +patch
pull_requests: +23047
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/24222
___
Python tracker
<https://bugs.python.org/issu
Mark Shannon added the comment:
It's a bug.
--
assignee: -> Mark.Shannon
___
Python tracker
<https://bugs.python.org/issue42925>
___
___
Python-bugs-lis
Mark Shannon added the comment:
I missed a "no" in the above, which somewhat changed the meaning!
It should have read:
"The implementation is allowed to skip any boolean test of a value, when it has
*no* effect on the flow of the program and at least one test has already bee
Mark Shannon added the comment:
The problem with using a specific syntax example, is that the optimizer doesn't
work that way. It works on the CFG.
Any specification needs to be phrased in terms of general control flow, as
other optimizations can enable this transformation.
e.g.
if
Change by Mark Shannon :
--
nosy: +lukasz.langa
___
Python tracker
<https://bugs.python.org/issue39934>
___
___
Python-bugs-list mailing list
Unsubscribe:
Mark Shannon added the comment:
In master, the sequence of events is:
1 call
2 line
3 line
returning
4 line
6 line
finally
6 return
which is the same as 3.7.
I now believe this is the correct trace, as the language spec states:
When a return, break or continue statement is executed in the
Mark Shannon added the comment:
In general, it is hard to define what is an optimization, and what is part of
the compiler.
The original request was to disable optimizations that changed observable
behavior w.r.t. line numbers.
All optimizations now respect line numbers, so proposed
Mark Shannon added the comment:
Unless anyone objects, I'm going to close this issue.
--
___
Python tracker
<https://bugs.python.org/issue42693>
___
___
Mark Shannon added the comment:
Pablo, are you OK closing this without a 3.8 backport?
--
___
Python tracker
<https://bugs.python.org/issue39934>
___
___
Pytho
Change by Mark Shannon :
--
title: Is it legal to eliminate tests of a value, when that test has no effect
on control flow -> Is it legal to eliminate tests of a value, when that test
has no effect on control flow?
___
Python tracker
<
Mark Shannon added the comment:
Steve,
Please don't change the title of the issue.
Sure, the optimizer is "inconsistent".
Optimizations are applied in some cases, and not in others.
That's just how compilers work.
The issue here is whether the optimizer is allowed
Mark Shannon added the comment:
Does this need backporting to 3.8, or is 3.9 sufficient?
--
___
Python tracker
<https://bugs.python.org/issue39934>
___
___
Pytho
New submission from Mark Shannon :
Currently the compiler operates in three main passes:
Code-gen
Optimize
Assemble
The problem is that these passes use the same basic-block based CFG, leading to
unnecessary coupling and inefficiencies.
A basic block CFG is awkward and error-prone for the
Change by Mark Shannon :
--
pull_requests: +23036
pull_request: https://github.com/python/cpython/pull/24209
___
Python tracker
<https://bugs.python.org/issue42
Change by Mark Shannon :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Mark Shannon added the comment:
New changeset 3bd6035b6baf1a7d51b7cc2c6bb2c81886236b67 by Mark Shannon in
branch 'master':
bpo-42908: Mark cleanup code at end of try-except and with artificial (#24202)
https://github.com/python/cpython/commit/3bd6035b6baf1a7d51b7cc2c6bb2c8
Mark Shannon added the comment:
> How do we know `x` is falsey without calling `bool()` on it?
We don't, but in `if x: pass`, it doesn't matter.
Discounting side-effects in __bool__, the code does nothing regardless of the
Mark Shannon added the comment:
It's clearer if you rewrite
if a and b:
...
as
tmp = a and b
if tmp:
...
if a is falsey then bool(a) gets called in `tmp = a and b` and `a` is assigned
to `tmp`. Then in `if tmp`, bool(a) is called again.
I agree with you about it not bei
Change by Mark Shannon :
--
priority: normal -> release blocker
___
Python tracker
<https://bugs.python.org/issue42899>
___
___
Python-bugs-list mai
Mark Shannon added the comment:
They aren't quite the same. If `a` is falsey, and bool(a) has a side-effect,
then that side-effect should occur twice in:
if a and b:
...
but only once in
if a:
if b:
...
It gets more interesting (silly), if `a.__bool__()` alternated be
Change by Mark Shannon :
--
keywords: +patch
pull_requests: +23027
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/24202
___
Python tracker
<https://bugs.python.org/issu
Mark Shannon added the comment:
The question still stands.
Is converting `if x: pass` to `pass` legal?
And, if it is not, is converting
if a and b:
body
to
if a:
if b:
body
a legal transformation?
(ignoring line numbers)
If the first transformation is not allowed but
New submission from Mark Shannon :
The following examples produce incorrect line numbers, due to cleanup code not
being marked as artificial
def f():
try:
if False:
pass
except:
X
def g(a):
with a:
if False:
pass
Mark Shannon added the comment:
The issue here is:
Is it legal to convert
if x: pass
into
pass
?
The explicit effect of the code is unchanged, BUT the implicit effect (of
calling x.__bool__) is changed.
The examples Serhiy gives are similar. If `bool(a)` evaluates to False, then
Change by Mark Shannon :
--
assignee: -> Mark.Shannon
___
Python tracker
<https://bugs.python.org/issue42899>
___
___
Python-bugs-list mailing list
Unsubscrib
Mark Shannon added the comment:
I don't see what the problem is here.
People just don't write code like that, at least not if they do code review ;)
And even, in the *extremely* rare case that they do, the code executes
correctly and reasonably quickly. It just uses a bit of ex
Mark Shannon added the comment:
What's the process for making a decision on whether to make 'yield' in an
annotation a syntax error?
As a language change it should have a PEP, IMO.
The PEP will be short, and shouldn't need a long-winded acceptance process.
I just thin
Change by Mark Shannon :
--
pull_requests: +22978
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/24150
___
Python tracker
<https://bugs.python.org/issu
Mark Shannon added the comment:
It looks like you are accessing the c field "f_lineno" directly.
That was never guaranteed to work, it just happened to.
You should use PyFrame_GetLineNumber()
If "f_lineno" is up to date, then it will be almost efficient as the direc
Mark Shannon added the comment:
OK, I won't merge anything yet.
--
___
Python tracker
<https://bugs.python.org/issue42837>
___
___
Python-bugs-list m
Mark Shannon added the comment:
The aim is to change the behavior of the symbol table to match the compiler.
The behavior has already changed at module scope.
Python 3.9.0+
>>> x:(yield None)
File "", line 1
SyntaxError: 'yield' outside function
>>>
Change by Mark Shannon :
--
keywords: +patch
pull_requests: +22967
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/24138
___
Python tracker
<https://bugs.python.org/issu
Mark Shannon added the comment:
I've also opened #42837 which is about fixing the symbol table, so that it is
correct w.r.t. to current behavior.
I'd like to fix it ASAP as the compiler should be able to rely on the symbol
table being correct.
Of course, once we have decide
Mark Shannon added the comment:
No this is not a duplicate.
This is about making the symbol table correct for current semantics.
#42725 is about changing the behavior
--
resolution: duplicate ->
status: closed -> open
superseder: PEP 563: Should the behavior change for yield
New submission from Mark Shannon :
This is an internal inconsistency. I have not identified any surface level
bugs, but it is a trap for future compiler work.
--
assignee: Mark.Shannon
messages: 384479
nosy: Mark.Shannon, larry
priority: normal
severity: normal
status: open
title
Change by Mark Shannon :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Mark Shannon added the comment:
New changeset ee9f98d9f4b881ee15868a836a2b99271df1bc0e by Mark Shannon in
branch 'master':
bpo-42823: Fix frame lineno when frame.f_trace is set (GH-24099)
https://github.com/python/cpython/commit/ee9f98d9f4b881ee15868a836a2b99
Mark Shannon added the comment:
I don't think we want to backport it
--
stage: patch review -> resolved
status: pending -> closed
___
Python tracker
<https://bugs.python.
Change by Mark Shannon :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Mark Shannon :
--
resolution: -> fixed
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue42803>
___
Change by Mark Shannon :
--
keywords: +patch
pull_requests: +22930
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/24099
___
Python tracker
<https://bugs.python.org/issu
Mark Shannon added the comment:
New changeset 127dde591686816e379d1add015304e6b9fb6954 by Mark Shannon in
branch 'master':
bpo-42810: Mark jumps at end of if and try statements as artificial. (GH-24091)
https://github.com/python/cpython/commit/127dde591686816e379d1add015304
New submission from Mark Shannon :
The logic for frame.f_lineno assumes that the internal C field will be updated
when f_trace is set, but that is incorrect.
Consequently, the following code
import sys
def print_line():
print(sys._getframe(1).f_lineno)
def test():
print_line
Mark Shannon added the comment:
dis is able to handle code with no line numbers.
>>> def f(): pass
...
>>> co = f.__code__.replace(co_linetable=b'\xff')
>>> list(co.co_lines())
[]
>>> import dis
>>> dis.dis(co)
0 LOAD_CON
Change by Mark Shannon :
--
pull_requests: +22923
pull_request: https://github.com/python/cpython/pull/24094
___
Python tracker
<https://bugs.python.org/issue42
Change by Mark Shannon :
--
keywords: +patch
pull_requests: +22922
stage: -> patch review
pull_request: https://github.com/python/cpython/pull/24091
___
Python tracker
<https://bugs.python.org/issu
Mark Shannon added the comment:
New changeset 28b75c80dcc1e17ed3ac1c69362bf8dc164b760a by Mark Shannon in
branch 'master':
bpo-42246: Don't eliminate jumps to jumps, if it will break PEP 626. (GH-23896)
https://github.com/python/cpython/commit/28b75c80dcc1e17ed3ac1c693
Mark Shannon added the comment:
I'll briefly answer the above questions, but we could we close this issue?
If there are specific issues regarding PEP 626, please make a new issue. Feel
free to +nosy me on those issues.
I intend to review all the recent changes to the compiler in th
Mark Shannon added the comment:
There isn't much of a plan.
https://github.com/python/cpython/pull/23896 makes the optimizer respect PEP
626 w.r.t. jumps-to-jumps.
>From the point of view of optimization, there is nothing special about
>jumps-to-jumps.
Any optimization that off
Mark Shannon added the comment:
Are you interested in the "what" or the "how"?
The "what":
PEP 626 defines what CPython must do in terms of tracing lines executed.
The "how":
Obviously, we want to execute Python as efficiently as possible
Mark Shannon added the comment:
I think this can finally be closed.
A mere 12 years after it was opened :)
PEP 626 specifies what the correct behavior is, regardless of whether
optimizations are turned on or off, so there is no point in a no-optimize
option.
The compiler is fast enough that
Mark Shannon added the comment:
The fix, which explains the bug:
https://github.com/python/cpython/pull/23896
--
___
Python tracker
<https://bugs.python.org/issue42
Mark Shannon added the comment:
In what way is it "kludgy"?
There is a mathematical theorem that states that generated code will be
imperfect,
so we will have to live with that :)
https://en.wikipedia.org/wiki/Full_employment_theorem
3.10a produces more efficient bytecode than
Change by Mark Shannon :
--
pull_requests: +22751
pull_request: https://github.com/python/cpython/pull/23896
___
Python tracker
<https://bugs.python.org/issue42
Mark Shannon added the comment:
Ned, I agree that up until 3.9, it is wasn't that simple.
But from 3.10 onward, it should be that simple.
That's the point of PEP 626.
If a transformation changes observable behavior within the scope of language
specification, then it is not an op
New submission from Mark Shannon :
This will require a change to the internal line number table format.
PEP 626 requires all lines are traced, which makes handling of 'continue' and
other jump-to-jumps inefficient if spread across multiple lines.
In 3.9 many jump-to-jumps were
Change by Mark Shannon :
--
resolution: -> fixed
stage: needs patch -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
New submission from Mark Shannon :
While the impact of making `if 0` and `while True` appear when tracing can be
mitigated, the impact of `continue` is more of a concern.
The following loop:
while True:
if test:
continue
rest
PEP 626 requires that the `continue` is traced
Mark Shannon added the comment:
What is the problem with NOPs?
If there are performance regressions in real code, then that needs to be
addressed.
If only in a few toy examples, then that is (IMO) a price worth paying for
predictable debugging and profiling.
Raymond:
Effectively it does
Mark Shannon added the comment:
You should never have to disable optimizations.
Let's be clear about what an optimization is.
An optimization (CS not math) is a change to the program such that it has the
same effect, according to the language spec, but improves some aspect of the
beh
Mark Shannon added the comment:
New changeset f2dbfd7e20431f0bcf2b655aa876afec7fe03c6f by Mark Shannon in
branch 'master':
bpo-42634: Mark reraise after except blocks as artificial. (GH-23877)
https://github.com/python/cpython/commit/f2dbfd7e20431f0bcf2b655aa876af
Mark Shannon added the comment:
Our reachability analysis is correct (in this case at least).
There is no unreachable code here.
In theory we could merge the two basic blocks at the end, but searching for
identical blocks and merging them is potentially quite expensive (and fiddly).
What
Change by Mark Shannon :
--
pull_requests: +22740
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/23877
___
Python tracker
<https://bugs.python.org/issu
Mark Shannon added the comment:
My guess is that we are changing the CFG after computing reachability leaving
unreachable blocks marked as reachable.
--
assignee: -> Mark.Shannon
___
Python tracker
<https://bugs.python.org/issu
Mark Shannon added the comment:
But why remove it? It is in the source code.
Do we want tracing and profiling to depend on what transformations the
optimizer does or does not make?
What lines are to be traced here? What is the last line executed?
def no_code():
if 0:
some_code
Change by Mark Shannon :
--
resolution: fixed ->
___
Python tracker
<https://bugs.python.org/issue42634>
___
___
Python-bugs-list mailing list
Unsubscrib
Mark Shannon added the comment:
Yes, this is change is deliberate.
PEP 626 states that *all* executed code gets traced.
Occasionally that will result in NOPs in the code, that are necessary
for correctness, but cannot be removed by the optimizer.
Is this a problem in practice?
In fact this
Change by Mark Shannon :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Mark Shannon added the comment:
New changeset bf353f3c2d937772a8cf30b15fd8eb7b82665ccb by Mark Shannon in
branch 'master':
bpo-42246: Make sure that `f_lasti`, and thus `f_lineno`, is set correctly
after raising or reraising an exception (GH-23803)
https://github.com/python/cpyt
Change by Mark Shannon :
--
pull_requests: +22663
pull_request: https://github.com/python/cpython/pull/23803
___
Python tracker
<https://bugs.python.org/issue42
Mark Shannon added the comment:
New changeset 5274b682bc93a04da8a69742528ac7f64633a96e by Mark Shannon in
branch 'master':
bpo-42645: Make sure that return/break/continue are only traced once when
exiting via a finally block. (GH-23780)
https://github.com/python/cpyt
Mark Shannon added the comment:
https://github.com/python/cpython/pull/23780 fixes the finally handling.
The if-break case was fixed by earlier changes.
--
___
Python tracker
<https://bugs.python.org/issue42
Mark Shannon added the comment:
New changeset c71581c7a4192e6ba9a79eccc583aaadab300efa by Om G in branch
'master':
bpo-42615: Delete redundant jump instructions that only bypass empty blocks
(GH-23733)
https://github.com/python/cpython/commit/c71581c7a4192e6ba9a79eccc583aa
Change by Mark Shannon :
--
keywords: +patch
pull_requests: +22638
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23780
___
Python tracker
<https://bugs.python.org/issu
New submission from Mark Shannon :
This function
def f():
try:
return 2
finally:
4
would generate a try of [1, 2, 4, 2]. It should generate [1, 2, 4]
and not trace the return twice.
--
assignee: Mark.Shannon
messages: 383044
nosy: Mark.Shannon, nedbat
Mark Shannon added the comment:
New changeset 8473cf89bdbf2cb292b39c972db540504669b9cd by Mark Shannon in
branch 'master':
bpo-42246: Remove DO_NOT_EMIT_BYTECODE macros, so that while loops and if
statements conform to PEP 626. (GH-23743)
https://github.com/python/cpyt
Change by Mark Shannon :
--
resolution: -> fixed
stage: patch review -> needs patch
status: open -> closed
___
Python tracker
<https://bugs.python.or
Change by Mark Shannon :
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Mark Shannon added the comment:
Thanks Ned, that's really helpful. I'll go through those points:
Code after break/continue is no longer compiled.
Expected
First line number of modules
Expected
Except clause when no exception
https://bugs.python.org/issue42634
Double l
Mark Shannon added the comment:
New changeset f5e97b72fecff9b9ced35704ec5e6cad29e2825d by Mark Shannon in
branch 'master':
bpo-42635: Mark JUMP_ABSOLUTE at end of 'for' loop as artificial to avoid
spurious line events. (GH-23761)
https://github.com/p
Change by Mark Shannon :
--
keywords: +patch
pull_requests: +22617
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23761
___
Python tracker
<https://bugs.python.org/issu
New submission from Mark Shannon :
The following code, when traced, produces a spurious line events at the end of
the inner loop.
def dloop():
for i in range(3):
for j in range(3):
a = i + j
assert a == 4
Bug reported by Ned Batchelder
https://gist.github.com
Change by Mark Shannon :
--
keywords: +patch
pull_requests: +22616
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/23760
___
Python tracker
<https://bugs.python.org/issu
New submission from Mark Shannon :
The following code, when traced, produces a spurious line event for line 5:
a, b, c = 1, 1, 1
try:
a = 3
except:
b = 5
finally:
c = 7
assert a == 3 and b == 1 and c == 7
Bug reported by Ned Batchelder
https://gist.github.com/nedbat
Mark Shannon added the comment:
Ned,
What are the failures?
I'd like to take a look, to see if things are as expected, and if there are any
tests we can add to CPython.
--
___
Python tracker
<https://bugs.python.org/is
Change by Mark Shannon :
--
pull_requests: +22601
pull_request: https://github.com/python/cpython/pull/23743
___
Python tracker
<https://bugs.python.org/issue42
Mark Shannon added the comment:
What's blocking this?
It is a real pain not to be able to install packages for 3.10.
I don't much care what the format is, but since there seems to be some
difficulty in changing it, why not leave the output as `310`?
It isn't ambiguous, as lon
Change by Mark Shannon :
--
resolution: -> fixed
stage: -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.org/issue42373>
___
Mark Shannon added the comment:
Thanks Yurii
--
resolution: -> fixed
stage: patch review -> resolved
status: open -> closed
___
Python tracker
<https://bugs.python.or
Mark Shannon added the comment:
New changeset eaccc12aa986f92ea05f3f0a63cedbff78dd67f1 by Mark Shannon in
branch 'master':
bpo-42246: Don't forget the entry block when ensuring that all exits have a
line number (GH-23636)
https://github.com/python
Mark Shannon added the comment:
New changeset f24b8101a01fa98b1e3ec042ba896aeb4c24d4bc by Yurii Karabas in
branch 'master':
bpo-42562: Fix issue when dis failed to parse function that has no line numbers
(GH-23632)
https://github.com/python/cpyt
Mark Shannon added the comment:
There are two issues here.
1. The compiler is not following PEP 626 for functions with no executable code
2. dis is not robust in the case that there are no line numbers.
I want to fix 1. first, then 2
Change by Mark Shannon :
--
pull_requests: +22504
pull_request: https://github.com/python/cpython/pull/23636
___
Python tracker
<https://bugs.python.org/issue42
701 - 800 of 1194 matches
Mail list logo