[issue45108] frame.f_lasti points at DICT_MERGE instead of CALL_FUNCTION_EX in Windows only

2021-09-05 Thread Alex Hall


New submission from Alex Hall :

In this script:

import inspect
import dis

def foo(**_):
frame = inspect.currentframe().f_back
print(frame.f_lasti)
dis.dis(frame.f_code)

d = {'a': 1, 'b': 2}
foo(**d)

dis shows these instructions for `foo(**d)`:

 10  34 LOAD_NAME2 (foo)
 36 BUILD_TUPLE  0
 38 BUILD_MAP0
 40 LOAD_NAME3 (d)
 42 DICT_MERGE   1
 44 CALL_FUNCTION_EX 1
 46 POP_TOP
 48 LOAD_CONST   1 (None)
 50 RETURN_VALUE

On Linux/OSX, frame.f_lasti is 44, pointing to the CALL_FUNCTION_EX as I'd 
expect.

But on Windows it's 42, which is the preceding instruction DICT_MERGE.

The bytecode itself is identical on the different systems, it's just the frame 
offset that differs.

This manifested as a test failure in a debugging tool here: 
https://github.com/samuelcolvin/python-devtools/pull/93

--
components: Interpreter Core, Windows
messages: 401098
nosy: alexmojaki, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: frame.f_lasti points at DICT_MERGE instead of CALL_FUNCTION_EX in 
Windows only
type: behavior
versions: Python 3.10, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue45108>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44576] AttributeError: incorrect line identified in Python 3.10

2021-07-07 Thread Alex Hall


Alex Hall  added the comment:

(meant to say "so I'm pulling in @Mark.Shannon)

--

___
Python tracker 
<https://bugs.python.org/issue44576>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44576] AttributeError: incorrect line identified in Python 3.10

2021-07-07 Thread Alex Hall


Alex Hall  added the comment:

I believe this is the outcome of https://bugs.python.org/issue39316 which I 
filed, so I'm pulling in . Naturally I think the new behaviour is not a bug but 
a feature.

I think it's more important for the traceback to show the attribute access 
(`two`) than the value (`one`). That's what the frame was doing at the time 
which led to the error.

The difference becomes even more important when calling a method with no 
arguments. Given this script:

class A:
def b(self):
1 / 0


x = (
A()
.b()
)


The 3.9 traceback points to the line with `A()` in the `` frame, while 
3.10 correctly points to `.b()`, which makes the following line 'in b' make 
more sense.

Where the old behaviour has really gotten to me is when I run the pycharm 
debugger and put a breakpoint on the .b() line and it never gets hit. Not being 
sure what lines 'count', I sometimes defensively put breakpoints on a cluster 
of lines, then spend more time removing them later. Having that fixed in 3.10 
is great.

--
components: +Interpreter Core
nosy: +Mark.Shannon, alexmojaki
type:  -> behavior

___
Python tracker 
<https://bugs.python.org/issue44576>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44393] segfault with sys.setrecursionlimit

2021-06-11 Thread Alex Hall


New submission from Alex Hall :

Found on:
Python 3.9.5
GCC 11.1 on Linux (x86_64)
Reproduced on:
Python 3.9.5
Clang 9.0.8 Linux (arm)

When setting the recursion limit to a high enough amount, trying to reach that 
recursion limit ends in a segmentation fault (stack overflow?)

code:
```py
import sys

def recurse(n: int) -> int:
recurse(n)

sys.setrecursionlimit(2**16-1)

recurse(100)
```

--
components: Library (Lib)
files: segpy.png
messages: 395626
nosy: ultrabear
priority: normal
severity: normal
status: open
title: segfault with sys.setrecursionlimit
type: crash
versions: Python 3.9
Added file: https://bugs.python.org/file50104/segpy.png

___
Python tracker 
<https://bugs.python.org/issue44393>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43121] Incorrect SyntaxError message for missing comma (3.10.a5)

2021-05-04 Thread Alex Hall


Alex Hall  added the comment:

Pablo, check out https://github.com/aroberge/friendly/discussions/197, 
particularly the second bullet point which has a dataset of syntax errors.

--
nosy: +alexmojaki

___
Python tracker 
<https://bugs.python.org/issue43121>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39316] settrace skips lines when chaining methods without arguments

2021-03-14 Thread Alex Hall

Alex Hall  added the comment:

I just came across https://www.python.org/dev/peps/pep-0626/, seems like this 
would need to be fixed to satisfy the PEP, but on the latest CPython it's not:

```
➜  ~ python3.10 ~/Downloads/trace_skipping_lines_bug.py
14 slug = "doing_the_thing"
15 print(slug
16   .replace("_", " ")
15 print(slug
19   .replace("a", "b")
15 print(slug
21   .replace("The ", "the "))
15 print(slug
doing the thing
➜  ~ python3.10 --version  
Python 3.10.0a6+
➜  ~ python3.10  
Python 3.10.0a6+ (heads/master:cd8dcbc, Mar 14 2021, 11:58:23) [GCC 7.5.0] on 
linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
```

--
type:  -> behavior
versions: +Python 3.10

___
Python tracker 
<https://bugs.python.org/issue39316>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39316] settrace skips lines when chaining methods without arguments

2021-03-14 Thread Alex Hall


Change by Alex Hall :


--
nosy: +Mark.Shannon

___
Python tracker 
<https://bugs.python.org/issue39316>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41614] Items put on Queue in thread in child process sometimes not seen by parent process

2020-08-22 Thread Alex Hall


New submission from Alex Hall :

See attached file. The summary is that I start a Process, which starts a 
Thread, which puts some values on a Queue which was originally created by the 
parent process and passed down. Usually this works but occasionally the parent 
process doesn't see the items on the queue: queue.get() times out and 
queue.empty() is True, although queue.qsize() is accurate.

I can reproduce this on master:

Python 3.10.0a0 (heads/master:802726a, Aug 22 2020, 12:56:09) 
[GCC 7.5.0] on linux

as well as other versions I have installed which I've selected. On 3.6 it seems 
like the problem is even worse and some of my comments don't apply.

I've tested the script on Ubuntu 18.04.4, but the general problem seems to also 
happen on OSX although I can't confirm that now.

--
files: queue_bug.py
messages: 375795
nosy: alexmojaki
priority: normal
severity: normal
status: open
title: Items put on Queue in thread in child process sometimes not seen by 
parent process
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file49422/queue_bug.py

___
Python tracker 
<https://bugs.python.org/issue41614>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39816] More descriptive error message than "too many values to unpack"

2020-03-01 Thread Alex Hall


New submission from Alex Hall :

Based on the discussion in 
https://mail.python.org/archives/list/python-id...@python.org/thread/C6QEAEEAELUHMLB23OBRSQK2UYU3AF5O/

When unpacking fails with an error such as:

ValueError: too many values to unpack (expected 2)

the name of the type of the unpacked object should be included, e.g.

ValueError: too many values to unpack (expected 2) from object of type 'str'

and if the type is exactly list or tuple, which are already special cased: 
https://github.com/python/cpython/blob/baf29b221682be0f4fde53a05ea3f57c3c79f431/Python/ceval.c#L2243-L2252

then the length can also be included:

ValueError: too many values to unpack (expected 2, got 3) from object of type 
'tuple'

--
components: Interpreter Core
messages: 363083
nosy: alexmojaki
priority: normal
severity: normal
status: open
title: More descriptive error message than "too many values to unpack"
type: enhancement
versions: Python 3.9

___
Python tracker 
<https://bugs.python.org/issue39816>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39810] Generic script for finding bugs in get_source_segment

2020-03-01 Thread Alex Hall


New submission from Alex Hall :

Attached is a script which:

- Gets all the source code it can find from sys.modules
- Looks at every node in the parsed source
- Gets source text for that node using ast.get_source_segment
- Parses the source text again
- Compares the original node with the newly parsed node
- Points out if the nodes don't match

I ran this on Python 3.8.0, and it found several issues which have now been 
solved. So if there was a test like this then many bugs would have been caught 
earlier. I haven't tried it on a build of master, so I'm actually not sure 
which bugs have been fixed and what new bugs have been introduced.

The script partly relies on [asttokens](https://github.com/gristlabs/asttokens) 
which is another way to get the source code of a node. This helps to skip some 
known issues and to show what the output from get_source_segment should 
probably be. You don't strictly need to install asttokens to run the script but 
it's helpful.

--
components: Interpreter Core
files: get_source_segment_test.py
messages: 363056
nosy: alexmojaki
priority: normal
severity: normal
status: open
title: Generic script for finding bugs in get_source_segment
type: behavior
versions: Python 3.8, Python 3.9
Added file: https://bugs.python.org/file48940/get_source_segment_test.py

___
Python tracker 
<https://bugs.python.org/issue39810>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13672] Add co_qualname attribute in code objects

2020-02-19 Thread Alex Hall


Alex Hall  added the comment:

I think this would be very useful in tracebacks. If a traceback line had a more 
useful name like `MyClass.__init__` instead of just `__init__` or 
`my_decorator..wrapper` instead of just `wrapper` it would provide 
useful context to the frame.

--
nosy: +alexmojaki

___
Python tracker 
<https://bugs.python.org/issue13672>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33997] multiprocessing Pool hangs in terminate()

2020-01-27 Thread Alex Hall


Alex Hall  added the comment:

Sorry, I should have looked around more, I think my problem is 
https://bugs.python.org/issue22393

--

___
Python tracker 
<https://bugs.python.org/issue33997>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33997] multiprocessing Pool hangs in terminate()

2020-01-27 Thread Alex Hall


Alex Hall  added the comment:

I'm also experiencing hanging on terminate. I haven't made a debug build or 
anything but it's happening to me consistently on 3.8, although I haven't 
managed to create a small example to reproduce. Replacing pool.py with 
https://raw.githubusercontent.com/python/cpython/5f6a05bf5b3f7e3c1d805b3bbd8c5ad18f26d933/Lib/multiprocessing/pool.py
 (from the PR) did not help. So maybe what I'm experiencing is unrelated.

It gets stuck on `inqueue._rlock.acquire()` in `Pool._help_stuff_finish`. I've 
attached debugging info from snoop, maybe that will help.

--
nosy: +alexmojaki
Added file: https://bugs.python.org/file48867/pool_terminate_snoop.txt

___
Python tracker 
<https://bugs.python.org/issue33997>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39316] settrace skips lines when chaining methods without arguments

2020-01-12 Thread Alex Hall


New submission from Alex Hall :

When stepping through a multiline expression like this:

```
print(slug
  .replace("_", " ")
  .title()
  .upper()
  .replace("a", "b")
  .lower()
  .replace("The ", "the "))
```

only these lines are hit by the tracer function:

15 print(slug
16   .replace("_", " ")
19   .replace("a", "b")
21   .replace("The ", "the "))

I'm guessing the problem is that there are no expressions on the other lines, 
as the attributes and calls all start with slug.

--
components: Interpreter Core
files: trace_skipping_lines_bug.py
messages: 359878
nosy: alexmojaki
priority: normal
severity: normal
status: open
title: settrace skips lines when chaining methods without arguments
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file48837/trace_skipping_lines_bug.py

___
Python tracker 
<https://bugs.python.org/issue39316>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38535] Incorrect col_offset for decorators with zero arguments (empty parentheses)

2019-10-20 Thread Alex Hall


Alex Hall  added the comment:

I assume this also happens on 3.9, it's just a bit hard for me to test that now.

--

___
Python tracker 
<https://bugs.python.org/issue38535>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38535] Incorrect col_offset for decorators with zero arguments (empty parentheses)

2019-10-20 Thread Alex Hall


New submission from Alex Hall :

In a decorator such as `@a()`, the ast.Call node has a col_offset starting from 
the @ symbol. This doesn't happen for decorators without arguments (e.g. `@a`) 
or with some arguments (e.g. `@a(x)`).

--
components: Interpreter Core
files: decorator_python_bug.py
messages: 354987
nosy: alexmojaki
priority: normal
severity: normal
status: open
title: Incorrect col_offset for decorators with zero arguments (empty 
parentheses)
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file48669/decorator_python_bug.py

___
Python tracker 
<https://bugs.python.org/issue38535>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com