[issue34013] Inconsistent SyntaxError for print

2021-02-19 Thread Irit Katriel

Irit Katriel  added the comment:

I agree with Terry’s point about printing long expressions in the error msg. 
Perhaps just the preamble would be useful though:

SyntaxError: Missing parentheses in call to 'print'. 

Instead of just

SyntaxError: invalid syntax.

--

___
Python tracker 

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



[issue43263] threading module unable to run

2021-02-19 Thread twoone3


New submission from twoone3 <3197653...@qq.com>:

When I use embedded Python to import and use threading module,The program will 
hang,I tested it in versions 3.6.5 and 3.9.1.

--
components: C API
messages: 387293
nosy: twoone3
priority: normal
severity: normal
status: open
title: threading module unable to run
versions: Python 3.6, Python 3.9

___
Python tracker 

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



[issue43263] threading module unable to run

2021-02-19 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

Please add more information about what you're doing.  Your report does not 
contain enough information to try to reproduce the problem.

This is supposed to work just fine, and does work for me.

--
nosy: +ronaldoussoren

___
Python tracker 

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



[issue43264] Nested EventProxy in ListProxy cause FileNotFoundError: [Errno 2] No such file or directory problem

2021-02-19 Thread Tobiichi


New submission from Tobiichi <754785...@qq.com>:

I append EventProxy into ListProxy like this:

```
l = manager.list([mp.Event() for _ in range(2)])
```

It works fine on a single node when I'm trying to get this listproxy. but when 
I trying to use multiple nodes across ethernet. it cause problem like this:

```
Traceback (most recent call last):
  File "client2.py", line 30, in 
logic(manager)
  File "client2.py", line 18, in logic
if l[i].is_set():
  File "", line 2, in __getitem__
  File 
"/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/managers.py", line 
819, in _callmethod
kind, result = conn.recv()
  File 
"/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/connection.py", 
line 251, in recv
return _ForkingPickler.loads(buf.getbuffer())
  File 
"/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/managers.py", line 
943, in RebuildProxy
return func(token, serializer, incref=incref, **kwds)
  File 
"/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/managers.py", line 
793, in __init__
self._incref()
  File 
"/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/managers.py", line 
847, in _incref
conn = self._Client(self._token.address, authkey=self._authkey)
  File 
"/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/connection.py", 
line 492, in Client
c = SocketClient(address)
  File 
"/home/think/anaconda3/envs/AC/lib/python3.7/multiprocessing/connection.py", 
line 620, in SocketClient
s.connect(address)
```

Nest ListProxy will cause same problem. like 

```
l = manager.list([manager.list([1 for _ in range(2)])for _ in range(2)])
```

Client act like this (manager in torch is SyncManager):

```
import torch.multiprocessing as mp

mp.current_process().authkey = b'abc'

def start_client(manager, host, port, key):
manager.register('get_list')
manager.__init__(address=(host, port), authkey=key)
manager.connect()
return manager

def logic(manager):
l = manager.get_list()
for i in range(len(l)):
if not l[i].is_set():
l[i].set()
print('set')

if __name__=='__main__':
manager = mp.Manager()
manager = start_client(manager, '127.0.0.1', 5000, b'abc')
logic(manager)
```

--
files: server.py
messages: 387295
nosy: show-me-code
priority: normal
severity: normal
status: open
title: Nested EventProxy in ListProxy cause FileNotFoundError: [Errno 2] No 
such file or directory problem
type: crash
versions: Python 3.6
Added file: https://bugs.python.org/file49819/server.py

___
Python tracker 

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



[issue43264] Nested EventProxy in ListProxy cause FileNotFoundError: [Errno 2] No such file or directory problem

2021-02-19 Thread Tobiichi


Change by Tobiichi <754785...@qq.com>:


Added file: https://bugs.python.org/file49820/client1.py

___
Python tracker 

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



[issue43264] ListProxy with EventProxy in caused FileNotFoundError: [Errno 2] No such file or directory problem

2021-02-19 Thread Tobiichi


Change by Tobiichi <754785...@qq.com>:


--
title: Nested EventProxy in ListProxy cause FileNotFoundError: [Errno 2] No 
such file or directory problem -> ListProxy with EventProxy in caused 
FileNotFoundError: [Errno 2] No such file or directory problem

___
Python tracker 

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



[issue43263] threading module unable to run

2021-02-19 Thread twoone3


twoone3 <3197653...@qq.com> added the comment:

I use cpython to running .py file,the file created a new thread,but the exe 
can't continue to run

--

___
Python tracker 

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



[issue43265] Improve sqlite3 backup error handling

2021-02-19 Thread Erlend Egeberg Aasland


New submission from Erlend Egeberg Aasland :

There are some issues with the error handling in 
pysqlite_connection_backup_impl():

1. ValueError is returned if the target connection equals source connection. 
Should be OperationalError, IMHO.

2. The aforementioned check is already performed by sqlite3_backup_init(), so 
we should just let SQLite take care of it and let _pysqlite_seterror() set the 
error if sqlite3_backup_init() returns NULL. This will also take care of 1.

3. The following comment seems to be wrong; errors are set on the connection 
object, not on the backup handle:
  /* We cannot use _pysqlite_seterror() here because the backup APIs do
 not set the error status on the connection object, but rather on
 the backup handle. */

After sqlite3_backup_finish(), we can just check the return code, and call 
_pysqlite_seterror() on the connection and return NULL. The mentioned comment 
can be removed.


Resolving these issues will save 18 lines of code, and make the backup function 
easier to maintain.


Berker?

--
components: Library (Lib)
messages: 387297
nosy: berker.peksag, erlendaasland
priority: normal
severity: normal
status: open
title: Improve sqlite3 backup error handling
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue43266] "String conversion and formatting" formatting messes up array subscripting

2021-02-19 Thread Erlend Egeberg Aasland


New submission from Erlend Egeberg Aasland :

str[size-1] is rendered incorrectly in 
https://docs.python.org/3.10/c-api/conversion.html

The original intent was probably to apply italics to the variables names only. 
This can be fixed by prefixing the first bracket with a backslash. However, 
that results in the italic text crashing with the bracket. I suggest to just 
use ``str[size-1]``.

Also applies to str[rv] in the same section.

--
assignee: docs@python
components: Documentation
messages: 387298
nosy: docs@python, erlendaasland
priority: normal
severity: normal
status: open
title: "String conversion and formatting" formatting messes up array 
subscripting
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue43266] "String conversion and formatting" formatting messes up array subscripting

2021-02-19 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
keywords: +patch
pull_requests: +23352
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24573

___
Python tracker 

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



[issue43260] Never release buffer when MemoryError in print()

2021-02-19 Thread Eryk Sun


Eryk Sun  added the comment:

The sys.stdout TextIOWrapper is stuck in a bad state. When the write() method 
is called with an ASCII string, it implements an optimization that stores a 
reference to the str() object in the internal pending_bytes instead of 
immediately encoding the string. Subsequently _textiowrapper_writeflush() 
attempts to create a bytes object for this ASCII string, but 
PyBytes_FromStringAndSize fails with a memory error. It's stuck in this state 
because it will never be able to flush the string. 

The first workaround I thought of was to call to detach() to rewrap 
sys.stdout.buffer with a new TextIOWrapper instance, but detach() attempts to 
flush and fails. A hacky but simple and effective workaround is to just 
re-initialize the wrapper. For example:

sys.stdout.__init__(sys.stdout.buffer, sys.stdout.encoding,
sys.stdout.errors, None, True)

This clears the internal pending_bytes.

--
components: +IO
nosy: +eryksun
priority: normal -> high
versions: +Python 3.10, Python 3.9

___
Python tracker 

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



[issue43260] Never release buffer when MemoryError in print()

2021-02-19 Thread Eryk Sun


Eryk Sun  added the comment:

Issue 36748 added the ASCII optimization in write(), so I'm adding Inada Naoki 
to the nosy list.

--
nosy: +methane

___
Python tracker 

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



[issue43251] sqlite3_column_name() failures should raise MemoryError

2021-02-19 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
title: sqlite3_column_name() failures should call PyErr_NoMemory() -> 
sqlite3_column_name() failures should raise MemoryError

___
Python tracker 

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



[issue43175] filecmp is not working for UTF-8 BOM file.

2021-02-19 Thread suresh


suresh  added the comment:

I am getting same file size and are regular files (True) as below.

Could you assist on filecmp any changes required in passing the inputs. Since 
it returns false.

Code: 

>>> os.chdir(r'C:\Users\suresh.n\Files')
>>> open('source.css', 'rb').read() == open('destination.css','rb').read()
True
>>> for f in ('source.css', 'destination.css'):
... print(f, os.path.isfile(f), os.path.getsize(f))

source.css True 37465
destination.css True 37465

--

___
Python tracker 

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



[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-02-19 Thread Erlend Egeberg Aasland


New submission from Erlend Egeberg Aasland :

The type checks at the start of pysqlite_statement_bind_parameter() are 
redundant:
We first check for exact types (*_CheckExact()), and then we check again for 
exact or subtyped versions (*_Check()).

(Adding to the redundantness: the result of this if..else "switch statement" is 
then reused as the expression in the subsequent switch statement.)

Suggesting to remove the redundant checks and merge the two switch statements.

--
components: Library (Lib)
messages: 387302
nosy: berker.peksag, erlendaasland
priority: normal
severity: normal
status: open
title: [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue43263] threading module unable to run

2021-02-19 Thread Mark Dickinson


Mark Dickinson  added the comment:

Sorry, but as Ronald says there's not nearly enough information here. Some 
questions:

- What do you mean by "embedded Python"?
- What is "the exe" that you refer to in your second mesasge? Is that 
python.exe? Is that an executable you compiled from your Python code somehow? 
If so, how?
- What operating system are you using?
- What exact version of Python are you using, and where did you get it from? 
(Conda? python.org install? OS package manager? Pre-installed?)
- What other dependencies are you using? Any 3rd party packages?
- What's the exact Python code that you're running? (Please attach all the 
Python code, preferably after first reducing to a minimal example that exhibits 
the issue.)
- What are the precise steps you used to invoke the Python code? (Are you 
running as a script from a command-line prompt? Interactively in IDLE / PyCharm 
/ VS Code / some other IDE?)
- What exactly happened?
- What did you expect to happen, and why?
- What steps have you taken to eliminate the possibility that this is a bug in 
your own code rather than in Python?

These notes may help: https://www.chiark.greenend.org.uk/~sgtatham/bugs.html

--
components: +Library (Lib) -C API
nosy: +mark.dickinson

___
Python tracker 

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



[issue42990] Improve the C code for calling Python code: _PyEval_EvalCode()

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

I rephrased PR 24564 to clarify the scope of the incompatible change: in 
practice, only the types.FunctionType constructor changes.

Defining functions in Python using "def function(...): ...", eval(code, {}) and 
exec(code, {}) are not affected. eval() and exec() already inherit the current 
builtins if globals does not contain "__builtins__" key.

--

___
Python tracker 

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



[issue43258] Prevent needless allocation of sqlite3 aggregate function context

2021-02-19 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset 979b23cbe44071b056ff524c0aa20e5d9794b5b0 by Erlend Egeberg 
Aasland in branch 'master':
bpo-43258: Don't allocate sqlite3 aggregate context for empty queries (GH-24569)
https://github.com/python/cpython/commit/979b23cbe44071b056ff524c0aa20e5d9794b5b0


--

___
Python tracker 

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



[issue43258] Prevent needless allocation of sqlite3 aggregate function context

2021-02-19 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +23353
pull_request: https://github.com/python/cpython/pull/24574

___
Python tracker 

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



[issue42990] Improve the C code for calling Python code: _PyEval_EvalCode()

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

Updated PR documentation:
---
The types.FunctionType constructor now inherits the current builtins
if the globals parameter is used and the globals dictionary has no
"__builtins__" key, rather than rather than using {"None": None} as
builtins: same behavior than eval() and exec() functions.

Defining a function with "def function(...): ..." in Python is not
affected, globals cannot be overriden with this syntax: it also
inherits the current builtins.
---

This PR makes FunctionType makes more consistent with other Python functions.

Also, it doesn't prevent people to attempt building a "sandbox", it remains 
possible to override __builtins__ in FunctionType, eval(), exec(), etc.

Usally, such sandbox pass a modified builtins namespace to eval() and exec() 
and the functions simply inherit it, functions defines with "def function(...): 
..." and functions created with types.FunctionType constructor: my PR only 
impacts a very specific case, when types.FunctionType is called with a 
different globals dictionary which has no "__builtins__" key.

--

___
Python tracker 

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



[issue40522] [subinterpreters] Get the current Python interpreter state from Thread Local Storage (autoTSSkey)

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23354
pull_request: https://github.com/python/cpython/pull/24575

___
Python tracker 

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



[issue34013] Inconsistent SyntaxError for print

2021-02-19 Thread Vedran Čačić

Vedran Čačić  added the comment:

> "It's still one of the most common beginner mistakes"

Do you have any data to back this up? I really think it's overblown.

On the other hand, if it really _is_ so, how about changing the language? It 
wouldn't be the first thing that was changed for Py3, and then changed back 
once people realized the old way was better.

It seems to me totally backwards to have a construct in the grammar, only to 
report it as an error. "I understand you, but you still have to use _this_ way 
to write what you want." I really think Python shouldn't be that kind of 
language.

--

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


New submission from STINNER Victor :

I modified many internal C functions to pass the current Python thread state 
(tstate), but in practice, only the current interpreter (interp) is needed.

--
components: Interpreter Core
messages: 387308
nosy: vstinner
priority: normal
severity: normal
status: open
title: [internals] Pass the current interpreter (interp) rather than the 
current Python thread state (state)
versions: Python 3.10

___
Python tracker 

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



[issue43258] Prevent needless allocation of sqlite3 aggregate function context

2021-02-19 Thread Berker Peksag


Berker Peksag  added the comment:


New changeset 2bb0bf4dd8c0bd4d23eb04afce1a58e07982 by Erlend Egeberg 
Aasland in branch 'master':
bpo-43258: Make sqlite3 callback functions static (GH-24574)
https://github.com/python/cpython/commit/2bb0bf4dd8c0bd4d23eb04afce1a58e07982


--

___
Python tracker 

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



[issue43258] Prevent needless allocation of sqlite3 aggregate function context

2021-02-19 Thread Berker Peksag


Change by Berker Peksag :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +23355
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24576

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23356
pull_request: https://github.com/python/cpython/pull/24577

___
Python tracker 

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



[issue43269] [sqlite3] Clean up function scoping

2021-02-19 Thread Erlend Egeberg Aasland


New submission from Erlend Egeberg Aasland :

There's a lot of file scoped functions without the static storage-class 
specifier. All file local functions should have the static storage-class 
specifier.

--
components: Library (Lib)
messages: 387310
nosy: berker.peksag, erlendaasland
priority: normal
severity: normal
status: open
title: [sqlite3] Clean up function scoping
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue43269] [sqlite3] Clean up function scoping

2021-02-19 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
keywords: +patch
pull_requests: +23357
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24578

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 5592f2b9daa24bf74cc616abcc40a29da2bdccb2 by Victor Stinner in 
branch 'master':
bpo-43268: Replace _PyThreadState_GET() with _PyInterpreterState_GET() 
(GH-24576)
https://github.com/python/cpython/commit/5592f2b9daa24bf74cc616abcc40a29da2bdccb2


--

___
Python tracker 

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



[issue40522] [subinterpreters] Get the current Python interpreter state from Thread Local Storage (autoTSSkey)

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 62078101ea1be5d2fc472a3f0d9d135e0bd5cd38 by Victor Stinner in 
branch 'master':
bpo-40522: Replace PyThreadState_GET() with PyThreadState_Get() (GH-24575)
https://github.com/python/cpython/commit/62078101ea1be5d2fc472a3f0d9d135e0bd5cd38


--

___
Python tracker 

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



[issue34013] Inconsistent SyntaxError for print

2021-02-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Let's step back a bit and focus on the issue at hand. The problem is the 
following:

* We **already** have a warning for the print statement without parens:

Python 3.9.1 (default, Dec 14 2020, 11:49:16)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print x
  File "", line 1
print x
  ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(x)?

This is achieved by inspecting the syntax error and checking some conditions, 
which I personally find it uglier than a resilient grammar rule.

* The question is if we want to make the rule more resilient or delete it 
whatsoever. The status quo doesn't seem like a good fit

--

___
Python tracker 

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



[issue43269] [sqlite3] Clean up function scoping

2021-02-19 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Ref. https://github.com/python/cpython/pull/24569#issuecomment-782014177, 
Berker.

--

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 101bf69ff18a946fed7c274f088878aaf85174cc by Victor Stinner in 
branch 'master':
bpo-43268: _Py_IsMainInterpreter() now expects interp (GH-24577)
https://github.com/python/cpython/commit/101bf69ff18a946fed7c274f088878aaf85174cc


--

___
Python tracker 

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



[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-19 Thread Christoph Anton Mitterer


Christoph Anton Mitterer  added the comment:

Okay the problem seems to be that I didn't give you the exact details on what I 
do.

Actually, the group (which then contains the mutually exclusive group) is 
contained in a "shared" parent parser, which I then use in the subparsers.

If I leave out the parent parser, then it works as you say.


I'll attach exact code (with which I can reproduce it).

--
Added file: https://bugs.python.org/file49821/test.py

___
Python tracker 

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



[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-19 Thread Christoph Anton Mitterer


Change by Christoph Anton Mitterer :


Added file: https://bugs.python.org/file49822/test-no-parent.py

___
Python tracker 

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



[issue34013] Inconsistent SyntaxError for print

2021-02-19 Thread Andre Roberge


Andre Roberge  added the comment:

+1 to the idea of adding something to the grammar, and have a simple error 
message:

SyntaxError: Missing parentheses in call to 'print'.

in *all* cases, including the first one that prompted this bug report.

I write that even though I have created a third-party package based on the idea 
that beginners (and sometimes others...) might benefit from a more detailed 
error message (which is taken care of already by friendly-traceback).

--
nosy: +aroberge

___
Python tracker 

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



[issue43270] [C API] Remove _PyErr_OCCURRED() macro

2021-02-19 Thread STINNER Victor


New submission from STINNER Victor :

The private _PyErr_OCCURRED() function was introduced to optimize 
Objects/setobject.c:

commit 5ba0cbe39221ff8985ce5a4702a3b01a17ae3248
Author: Raymond Hettinger 
Date:   Sat Aug 6 18:31:24 2005 +

* set_new() doesn't need to zero the structure a second time after tp_alloc
  has already done the job.
* Use a macro form of PyErr_Occurred() inside the set_lookkey() function.

But the usage of the macro was removed one month later:

commit 9bda1d6f645bd0f3e76c14f27bbbac919814cd38
Author: Raymond Hettinger 
Date:   Fri Sep 16 07:14:21 2005 +

No longer ignore exceptions raised by comparisons during key lookup.
Inspired by Armin Rigo's suggestion to do the same with dictionaries.

The macro is currently defined as:

#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
#define _PyErr_OCCURRED() PyErr_Occurred()
#else
#define _PyErr_OCCURRED() (PyThreadState_GET()->curexc_type)
#endif

IMO the new _PyErr_Occurred(tstate) internal function is a more reliable way 
(don't depend on Py_DEBUG and Py_LIMITED_API) to ensure that the code uses the 
most efficient way to check if an exception was raised.

I cannot find "_PyErr_OCCURRED" in the PyPI top 4000 projects, I checked with 
INADA-san's tool:
https://github.com/methane/notes/tree/master/2020/wchar-cache
(But I found many C extensiosn using "PyErr_Occurred" which is fine, this one 
stays ;-) I just wanted to check that my search was working.)

So removing _PyErr_OCCURRED() is unlikely to break PyPI top 4000 projects. If 
it breaks a third party project: well, we don't provide any backward 
compatibility warranty on the *private* C API.

--
components: C API
messages: 387318
nosy: vstinner
priority: normal
severity: normal
status: open
title: [C API] Remove _PyErr_OCCURRED() macro
versions: Python 3.10

___
Python tracker 

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



[issue43270] [C API] Remove _PyErr_OCCURRED() macro

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

> #define _PyErr_OCCURRED() (PyThreadState_GET()->curexc_type)

But this way, this macro access directly the PyThreadState.curexc_type member 
which goes against the bpo-39947 "[C API] Make the PyThreadState structure 
opaque (move it to the internal C API)" issue.

--

___
Python tracker 

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



[issue43270] [C API] Remove _PyErr_OCCURRED() macro

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
keywords: +patch
pull_requests: +23358
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24579

___
Python tracker 

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



[issue43270] [C API] Remove _PyErr_OCCURRED() macro

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

_PyErr_Occurred() is defined as:

static inline PyObject* _PyErr_Occurred(PyThreadState *tstate)
{
assert(tstate != NULL);
return tstate->curexc_type;
}

--

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23359
pull_request: https://github.com/python/cpython/pull/24580

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23360
pull_request: https://github.com/python/cpython/pull/24581

___
Python tracker 

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



[issue27646] doc: yield from expression can be any iterable

2021-02-19 Thread Irit Katriel


Change by Irit Katriel :


--
title: yield from expression can be any iterable -> doc: yield from expression 
can be any iterable
versions: +Python 3.10 -Python 3.5, Python 3.6

___
Python tracker 

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



[issue42093] Add opcode cache for LOAD_ATTR

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +vstinner
nosy_count: 4.0 -> 5.0
pull_requests: +23361
pull_request: https://github.com/python/cpython/pull/24582

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset acde3f1530f1664c9ec7f22e16a7f54c5191e4a6 by Victor Stinner in 
branch 'master':
bpo-43268: Remove abusive usage of tstate in sysmodule.c (#24581)
https://github.com/python/cpython/commit/acde3f1530f1664c9ec7f22e16a7f54c5191e4a6


--

___
Python tracker 

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



[issue43270] [C API] Remove _PyErr_OCCURRED() macro

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue43270] [C API] Remove _PyErr_OCCURRED() macro

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset a486054b24658fa623e030ddd4cc0cbfcac54ab0 by Victor Stinner in 
branch 'master':
bpo-43270: Remove private _PyErr_OCCURRED() macro (GH-24579)
https://github.com/python/cpython/commit/a486054b24658fa623e030ddd4cc0cbfcac54ab0


--

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset bcb094b41f7fe4dd1686c50891d85632fcf0d481 by Victor Stinner in 
branch 'master':
bpo-43268: Pass interp rather than tstate to internal functions (GH-24580)
https://github.com/python/cpython/commit/bcb094b41f7fe4dd1686c50891d85632fcf0d481


--

___
Python tracker 

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



[issue30425] Python 3.6.1 (32-bit)_20170522020736.log

2021-02-19 Thread Irit Katriel


Irit Katriel  added the comment:

Chakrit, what is the issue you are reporting here?

--
nosy: +iritkatriel
resolution:  -> not a bug
status: open -> pending

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23362
pull_request: https://github.com/python/cpython/pull/24583

___
Python tracker 

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



[issue43255] Ceil division with /// operator

2021-02-19 Thread Boštjan Mejak

Boštjan Mejak  added the comment:

Mr. Stinner, I really don't understand what are you hinting at.

--

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 839184f85cb2d2ad514fff9b431733d1c9607533 by Victor Stinner in 
branch 'master':
bpo-43268: local_clear() uses _PyInterpreterState_GET() (GH-24583)
https://github.com/python/cpython/commit/839184f85cb2d2ad514fff9b431733d1c9607533


--

___
Python tracker 

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



[issue43268] [internals] Pass the current interpreter (interp) rather than the current Python thread state (state)

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue35134] Add a new Include/cpython/ subdirectory for the "CPython API" with implementation details

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 4a6bf276ed3e6687394afe26b0d9a061ac06fc6b by Nicholas Sim in 
branch 'master':
bpo-35134: Move non-limited C API files to Include/cpython/ (GH-24561)
https://github.com/python/cpython/commit/4a6bf276ed3e6687394afe26b0d9a061ac06fc6b


--

___
Python tracker 

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



[issue43257] get_type_hints evaluates class variables before type hints

2021-02-19 Thread Ken Jin


Ken Jin  added the comment:

Hmm I noticed this occurs in Python 3.9 but not 3.10. If you insert ``from 
__future__ import annotations`` at the start of your code, it stops erroring.

Anyways, I don't think this is dataclass specific, the following code using a 
plain class also errors:

```
from typing import get_type_hints
class T:
str: str = 'a'

get_type_hints(T) # Error.
```

Inspecting __annotations__ tells us why:

>>> T.__annotations__
{'str': 'a'}

You can see that the annotations are wrong. Meanwhile with from __future__ 
import annotations:
>>> T.__annotations__
{'str': 'str'}

Seeing that SETUP_ANNOTATIONS in ceval.c didn't change, I suspect it's compiler 
related.

--
nosy: +gvanrossum, kj

___
Python tracker 

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



[issue43265] Improve sqlite3 backup error handling

2021-02-19 Thread Berker Peksag


Berker Peksag  added the comment:

I'm not sure about 1) because if target == source it means a user error. 
OperationalError is usually used for non-user errors.

3) sounds good to me if that part is already covered by tests and they passed.

--

___
Python tracker 

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



[issue43265] Improve sqlite3 backup error handling

2021-02-19 Thread Андрей Воропаев

Change by Андрей Воропаев :


Added file: https://bugs.python.org/file49823/DOC-20200420-WA

___
Python tracker 

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



[issue43266] "String conversion and formatting" formatting messes up array subscripting

2021-02-19 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset 2d3e463e4a5aa109d1c15c86f9631580f5ef7a7e by Erlend Egeberg 
Aasland in branch 'master':
closes bpo-43266: Improve array formatting. (GH-24573)
https://github.com/python/cpython/commit/2d3e463e4a5aa109d1c15c86f9631580f5ef7a7e


--
nosy: +benjamin.peterson
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue43266] "String conversion and formatting" formatting messes up array subscripting

2021-02-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23364
pull_request: https://github.com/python/cpython/pull/24585

___
Python tracker 

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



[issue43266] "String conversion and formatting" formatting messes up array subscripting

2021-02-19 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 2.0 -> 3.0
pull_requests: +23363
pull_request: https://github.com/python/cpython/pull/24584

___
Python tracker 

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



[issue43257] get_type_hints evaluates class variables before type hints

2021-02-19 Thread Guido van Rossum

Guido van Rossum  added the comment:

Sure looks like a compiler bug! Can you investigate whether this occurs in 
earlier Python versions? Maybe bisect if it doesn’t?

--

___
Python tracker 

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



[issue43255] Ceil division with /// operator

2021-02-19 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

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



[issue43266] "String conversion and formatting" formatting messes up array subscripting

2021-02-19 Thread miss-islington


miss-islington  added the comment:


New changeset 1cfed3d5b0ec1419c8a1d5cf8bff1a6e1483771a by Miss Islington (bot) 
in branch '3.9':
closes bpo-43266: Improve array formatting. (GH-24573)
https://github.com/python/cpython/commit/1cfed3d5b0ec1419c8a1d5cf8bff1a6e1483771a


--

___
Python tracker 

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



[issue37146] opcode cache for LOAD_GLOBAL emits false alarm in memory leak hunting

2021-02-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23365
pull_request: https://github.com/python/cpython/pull/24582

___
Python tracker 

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



[issue43259] argparse: allow add_mutually_exclusive_group on add_argument_group

2021-02-19 Thread paul j3


paul j3  added the comment:

The parents mechanism is not elaborate.  It copies groups and actions by 
reference.  The comments that I quoted actually come from that method that does 
this copying.  

>From a quick glance at that code I see that it does not preserve the group 
>nesting.  Mutually_exclusive groups are added directly the parser.

Parents is primarily a convenience tool, especially if used entirely with your 
own code.  It's most valuable when importing the parent, and you don't have 
direct access to the code that constructed it.  But it seems to be used most 
often as a way of creating a number of similar subparsers.  For that it can be 
easily replaced with your own utility function(s).  There's no virtue in trying 
to do everything with the tools that argparse provides.

--

___
Python tracker 

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



[issue43251] sqlite3_column_name() failures should raise MemoryError

2021-02-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Well, it returns NULL in case of out of memory, but is it the only cause? Can 
NULL be returned for other reasons?

--

___
Python tracker 

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



[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-02-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is a kind of optimization. We first perform few fast checks for exact types, 
and then slower subclass checks.

I do not know whether this optimization is worth, but it was written so, and 
there is nothing wrong in it.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue37146] opcode cache for LOAD_GLOBAL emits false alarm in memory leak hunting

2021-02-19 Thread Guido van Rossum


Guido van Rossum  added the comment:

Please revert this and use a separate build flag (e.g. DISABLE_INLINE_CACHES) 
for the refleaks run. (Or perhaps provide an -X flag to disable it without the 
need to recompile.)

I am developing new inline cache ideas and of course I need to run in debug 
mode, so I regularly end up wasting some time until I remember to add a patch 
that changes OPCACHE_MIN_RUNS back.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue42402] Termios module documentation is extremely lacking

2021-02-19 Thread Irit Katriel


Irit Katriel  added the comment:

Could it simply be that the link to mod:`termios` should have been to 
:manpage:`termios(3)` instead?

--
nosy: +iritkatriel

___
Python tracker 

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



[issue37146] opcode cache for LOAD_GLOBAL emits false alarm in memory leak hunting

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

I reopen the issue (but I'm not interested by trying to fix it).

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue37146] opcode cache for LOAD_GLOBAL emits false alarm in memory leak hunting

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

> (Or perhaps provide an -X flag to disable it without the need to recompile.)

Giving the ability to control the cache size, at least at Python startup, is 
one option.

Or maybe need a generic -X flag to tell Python that libregrtest is tracking 
leaks, since we might need to change other parameters than only the opcode 
cache size.

--

___
Python tracker 

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



[issue42990] Improve the C code for calling Python code: _PyEval_EvalCode()

2021-02-19 Thread Guido van Rossum


Guido van Rossum  added the comment:

Thanks, that's clearer.

I'm still worried about the change in semantics where globals["__builtins__"] 
is assigned a different dict after the function object has been created 
(similar to https://bugs.python.org/file49816/func_builtins2.py).

I.e.

def foo(): return len("abc")
code = foo.__code__
g = {"__builtins__": {"len": len}}
f = FunctionType(code, g)
f()  # Succeeds
g["__builtins__"] = {}
f()  # Fails in 3.9 and before, passes in 3.10

Assuming code uses len, does f() succeed or fail?

I realize this is a pretty esoteric, but it does show the change in semantics 
(from later to earlier binding). Should we care? I like early binding because 
it allows more optimizations[1], but traditionally Python's semantics use late 
binding.

[1] Not in this case, the user could still change the meaning of len() with e.g.

g["__builtins__"]["len"] = lambda x: return 42

--

___
Python tracker 

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



[issue42990] Improve the C code for calling Python code: _PyEval_EvalCode()

2021-02-19 Thread Mark Shannon


Mark Shannon  added the comment:

In Python 3.9 the binding is more late-ish binding, than true late binding.

Because globals['__builtins__'] is cached for each function activation, 
executing functions don't see updates.

Example:

>>> def f():
... print(len("test"))
... bltns = f.__globals__["__builtins__"]
... if hasattr(bltns, "__dict__"):
... bltns = bltns.__dict__
... new = bltns.copy()
... new["len"] = lambda x : 7
... f.__globals__["__builtins__"] = new
... print(len("test"))
... 
>>> 
>>> f()
4
4
>>> f()
7
7

True late binding would print:

>>> f()
4
7
>>> f()
7
7

--

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2021-02-19 Thread Brian Hulette


Brian Hulette  added the comment:

Hey there, I just came across this bug when looking into a problem with 
corrupted pyc files. Was the patch ever applied? I'm still seeing the original 
behavior in Python 3.7.

Thanks!

--
nosy: +hulettbh

___
Python tracker 

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



[issue43265] Improve sqlite3 backup error handling

2021-02-19 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> I'm not sure about 1) because if target == source it means a user error. 
> OperationalError is usually used for non-user errors.

Yes, my bad. ProgrammingError would be better.
target == source results in SQLITE_ERROR, BTW.

I'll throw up a PR for 3., then.

--

___
Python tracker 

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



[issue28007] Bad .pyc files prevent import of otherwise valid .py files.

2021-02-19 Thread Brett Cannon


Brett Cannon  added the comment:

Since this is still open I would assume it never made it in.

--

___
Python tracker 

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



[issue43263] threading module unable to run

2021-02-19 Thread Mark Dickinson


Change by Mark Dickinson :


--
resolution:  -> works for me
status: open -> pending

___
Python tracker 

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



[issue43265] Improve sqlite3 backup error handling

2021-02-19 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
keywords: +patch
pull_requests: +23366
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24586

___
Python tracker 

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



[issue42990] Improve the C code for calling Python code: _PyEval_EvalCode()

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

Guido: "I'm still worried about the change in semantics where 
globals["__builtins__"] is assigned a different dict after the function object 
has been created (...)"

Well, there is a semantics change of Python 3.10 documented at:
https://docs.python.org/dev/whatsnew/3.10.html#other-language-changes

"Functions have a new __builtins__ attribute which is used to look for builtin 
symbols when a function is executed, instead of looking into 
__globals__['__builtins__']. (Contributed by Mark Shannon in bpo-42990.)"

And the function __builtins__ attribute is read-only.


Your example is not affected by PR 24564 because the globals has the 
"__builtins__" key.


In Python 3.10, you can modify func.__builtins__ (new attribute):
---
def foo(s): return len(s)
code = foo.__code__
FunctionType = type(foo)
f = FunctionType(code, {"__builtins__": {"len": len}})
print(f("abc"))
f.__builtins__.clear()
print(f("abc"))
---

Output:
---
3
Traceback (most recent call last):
  (...)
NameError: name 'len' is not defined
---


Mark: "Because globals['__builtins__'] is cached for each function activation, 
executing functions don't see updates."

In Python 3.10, if someone wants to hack builtins while the function is 
running, modifying the builtins namespace in-place works as expected:
---
def f():
print(len("test"))
builtins_ns = f.__globals__['__builtins__'].__dict__
#builtins_ns = f.__builtins__
builtins_ns['len'] = lambda x: 7
print(len("test"))

f()
---

Output:
---
4
7
---

It also works with "builtins_ns = f.__builtins__".


Guido: "I realize this is a pretty esoteric, but it does show the change in 
semantics (from later to earlier binding). Should we care? I like early binding 
because it allows more optimizations[1], but traditionally Python's semantics 
use late binding."

Modifying built-in functions/types is commonly done in tests. Example:
---
import unittest.mock

def func():
with unittest.mock.patch('builtins.chr', return_value='mock'):
return chr(65)

print(func())
---

The expected output is: "mock". Overriding an attribute of the builtins module 
immediately updates func.__builtins__. It works because func.__builtins__ is 
builtins.__dict__.

In FAT Python, I implemented an optimization which copies builtin functions to 
constants, replace LOAD_GLOBAL with LOAD_CONST:
https://fatoptimizer.readthedocs.io/en/latest/optimizations.html#copy-builtin-to-constant

This optimization breaks this Python semantics, it is no longer possible to 
override builtin functions in tests:
https://fatoptimizer.readthedocs.io/en/latest/semantics.html#builtin-functions-replaced-in-the-middle-of-a-function

--

___
Python tracker 

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



[issue43267] [sqlite3] Redundant type checks in pysqlite_statement_bind_parameter()

2021-02-19 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> It is a kind of optimization.

PyLong_Check is very fast (only one comparison, AFAICS), so there is no gain in 
first doing PyLong_CheckExact and then PyLong_Check. Ditto for unicode.

PyFloat_Check is the most expensive check, but it comes before both 
PyUnicode_Check and PyObject_CheckBuffer (both a lot faster), so that's AFAICS 
the opposite of an optimisation. Correct me if I'm wrong.

If we want to optimise it we should do PyLong_Check, PyUnicode_Check, 
PyObject_CheckBuffer, and then PyFloat_Check, no?

> there is nothing wrong in it.

True. I'll argue that my suggestion will improve readability and 
maintainability, which should be worth considering.

--

___
Python tracker 

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



[issue43251] sqlite3_column_name() failures should raise MemoryError

2021-02-19 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> Well, it returns NULL in case of out of memory, but is it the only cause? Can 
> NULL be returned for other reasons?

According to the SQLite docs, no. Looking at the source code, we see that it 
also returns NULL if the second parameter (column index) is out of range, but 
we already check that. AFAICS, the only reason for a NULL in our case is OOM.

--

___
Python tracker 

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



[issue43251] [sqlite3] sqlite3_column_name() failures should raise MemoryError

2021-02-19 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
title: sqlite3_column_name() failures should raise MemoryError -> [sqlite3] 
sqlite3_column_name() failures should raise MemoryError

___
Python tracker 

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



[issue43265] [sqlite3] Improve backup error handling

2021-02-19 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
title: Improve sqlite3 backup error handling -> [sqlite3] Improve backup error 
handling

___
Python tracker 

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



[issue43271] AMD64 Windows10 3.x crash with Windows fatal exception: stack overflow

2021-02-19 Thread STINNER Victor


New submission from STINNER Victor :

AMD64 Windows10 3.x, build 856:
https://buildbot.python.org/all/#/builders/146/builds/856

17 tests failed:
test_exceptions test_fileio test_io test_isinstance test_json
test_lib2to3 test_logging test_pickle test_pickletools
test_plistlib test_richcmp test_runpy test_sys test_threading
test_traceback test_typing test_xml_etree

It may be a regression caused by:
"bpo-43166: Disable ceval.c optimisations for Windows debug builds (GH-24485)"
https://github.com/python/cpython/commit/b74396c3167cc780f01309148db02709bc37b432

The latest successful build was 11 days ago (Feb 9):
https://buildbot.python.org/all/#/builders/146/builds/819



0:01:46 load avg: 14.25 [ 61/426/1] test_xml_etree crashed (Exit code 
3221225725) -- running: test_tokenize (46.4 sec), test_largefile (1 min 10 sec)
Windows fatal exception: stack overflow

Current thread 0x110c (most recent call first):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\xml\etree\ElementTree.py", 
line 178 in __repr__
  File "D:\buildarea\3.x.bolen-windows10\build\lib\xml\etree\ElementTree.py", 
line 178 in __repr__
  File "D:\buildarea\3.x.bolen-windows10\build\lib\xml\etree\ElementTree.py", 
line 178 in __repr__
  ...

==
FAIL: test_recursion_limit (test.test_threading.ThreadingExceptionTests)
--
Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_threading.py", 
line 1203, in test_recursion_limit
self.assertEqual(p.returncode, 0, "Unexpected error: " + stderr.decode())
AssertionError: 3221225725 != 0 : Unexpected error: 

0:05:09 load avg: 29.65 [140/426/3] test_traceback crashed (Exit code 
3221225725) -- running: test_concurrent_futures (2 min 6 sec), test_mmap (2 min)
Windows fatal exception: stack overflow

Current thread 0x0118 (most recent call first):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_traceback.py", 
line 1154 in f
  File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_traceback.py", 
line 1156 in f
  File "D:\buildarea\3.x.bolen-windows10\build\lib\test\test_traceback.py", 
line 1156 in f
  ...

0:06:14 load avg: 29.15 [151/426/4] test_lib2to3 crashed (Exit code 3221225725) 
-- running: test_multiprocessing_spawn (31.7 sec), test_capi (1 min 3 sec), 
test_mmap (3 min 4 sec)
Windows fatal exception: stack overflow

Current thread 0x1b90 (most recent call first):
  File "D:\buildarea\3.x.bolen-windows10\build\lib\lib2to3\pytree.py", line 496 
in generate_matches
  File "D:\buildarea\3.x.bolen-windows10\build\lib\lib2to3\pytree.py", line 845 
in generate_matches
  ...

--
components: Windows
messages: 387348
nosy: paul.moore, steve.dower, tim.golden, vstinner, zach.ware
priority: normal
severity: normal
status: open
title: AMD64 Windows10 3.x crash with Windows fatal exception: stack overflow
versions: Python 3.10

___
Python tracker 

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



[issue43166] Unused letters in Windows-specific pragma optimize

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

Since this change, AMD64 Windows10 3.x buildbot started to crash with Windows 
fatal exception: stack overflow -> see bpo-43271.

--
nosy: +vstinner

___
Python tracker 

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



[issue43272] AMD64 Arch Linux VintageParser 3.9: test_fstring test_named_expressions test_unpack_ex failed

2021-02-19 Thread STINNER Victor


New submission from STINNER Victor :

AMD64 Arch Linux VintageParser 3.9:
https://buildbot.python.org/all/#/builders/495/builds/147

3 tests failed:
test_fstring test_named_expressions test_unpack_ex

The latest success build was 4 months ago (Nov 2):
https://buildbot.python.org/all/#/builders/495/builds/107


**
File 
"/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py",
 line ?, in test.test_unpack_ex.__test__.doctests
Failed example:
(*x),y = 1, 2 # doctest:+ELLIPSIS
Expected:
Traceback (most recent call last):
  ...
SyntaxError: can't use starred expression here
Got nothing
**
File 
"/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py",
 line ?, in test.test_unpack_ex.__test__.doctests
Failed example:
(((*x))),y = 1, 2 # doctest:+ELLIPSIS
Expected:
Traceback (most recent call last):
  ...
SyntaxError: can't use starred expression here
Got nothing
**
File 
"/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py",
 line ?, in test.test_unpack_ex.__test__.doctests
Failed example:
z,(*x),y = 1, 2, 4 # doctest:+ELLIPSIS
Expected:
Traceback (most recent call last):
  ...
SyntaxError: can't use starred expression here
Got nothing
**
File 
"/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py",
 line ?, in test.test_unpack_ex.__test__.doctests
Failed example:
z,(*x) = 1, 2 # doctest:+ELLIPSIS
Expected:
Traceback (most recent call last):
  ...
SyntaxError: can't use starred expression here
Got nothing
**
File 
"/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_unpack_ex.py",
 line ?, in test.test_unpack_ex.__test__.doctests
Failed example:
((*x),y) = 1, 2 # doctest:+ELLIPSIS
Expected:
Traceback (most recent call last):
  ...
SyntaxError: can't use starred expression here
Got nothing
**
1 items had failures:
   5 of  91 in test.test_unpack_ex.__test__.doctests


==
FAIL: 
test_named_expression_invalid_rebinding_set_comprehension_iteration_variable 
(test.test_named_expressions.NamedExpressionInvalidTest) (case='Local reuse')
--
  File "", line 1
{i := 0 for i in range(5)}
   ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_named_expressions.py",
 line 185, in 
test_named_expression_invalid_rebinding_set_comprehension_iteration_variable
exec(code, {}, {})
AssertionError: "assignment expression cannot rebind comprehension iteration 
variable 'i'" does not match "invalid syntax (, line 1)"

==
FAIL: 
test_named_expression_invalid_rebinding_set_comprehension_iteration_variable 
(test.test_named_expressions.NamedExpressionInvalidTest) (case='Unpacking 
reuse')
--
  File "", line 1
{i := 0 for i, j in {(0, 1)}}
   ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_named_expressions.py",
 line 185, in 
test_named_expression_invalid_rebinding_set_comprehension_iteration_variable
exec(code, {}, {})
AssertionError: "assignment expression cannot rebind comprehension iteration 
variable 'i'" does not match "invalid syntax (, line 1)"

==
FAIL: test_named_expression_invalid_set_comprehension_iterable_expression 
(test.test_named_expressions.NamedExpressionInvalidTest) (case='Inside list')
--
  File "", line 1
{i for i in {2, 3, i := range(5)}}
 ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File 
"/buildbot/buildarea/3.9.pablogsal-arch-x86_64.oldparser/build/Lib/test/test_named_expressions.py",
 line 218, in 
test_named_expression_invalid_set_comprehension_iterable_expression
exec(code, {}) # Module scope
AssertionError: "assignment expression cannot be used in a comprehension 
iterable expressio

[issue43271] AMD64 Windows10 3.x crash with Windows fatal exception: stack overflow

2021-02-19 Thread Steve Dower


Steve Dower  added the comment:

Looks like someone increased the size of locals in the ceval functions.

If any new buffers have been added recently, moving the processing into a 
helper function or using a single buffer instead of allocating them in separate 
if/case blocks can help reduce it.

--

___
Python tracker 

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



[issue43271] AMD64 Windows10 3.x crash with Windows fatal exception: stack overflow

2021-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

If someone wants to measure the stack memory usage per function call, 
_testcapi.stack_pointer() can be used: see bpo-30866.

--

___
Python tracker 

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



[issue41837] Upgrade installers to OpenSSL 1.1.1i

2021-02-19 Thread Steve Dower


Steve Dower  added the comment:

Looks like we missed Christian's last message...

Have OpenSSL made an updated release? If this issue is as bad as the short 
description above sounds, I expect they would have.

It's possible to rebuild with the patch, but easier if it's a release.

(Also, Christian, should this have been a release blocker? We just made fast 
releases for a security concern...)

--

___
Python tracker 

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



[issue30480] samefile and sameopenfile fail for WebDAV mapped drives

2021-02-19 Thread Steve Dower


Steve Dower  added the comment:

Same as issue33935, but since the newer issue has proposed solutions on it 
already, I'm preferring to keep that one open.

--
resolution:  -> duplicate
stage: test needed -> resolved
status: open -> closed

___
Python tracker 

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



[issue42405] Add distutils mvsccompiler support for Windows ARM64 build

2021-02-19 Thread Steve Dower


Steve Dower  added the comment:

Closed due to PEP 632 (distutils is now deprecated).

Changes to support this should go into setuptools or another build backend. I'm 
already trying to get some resources together to help these other projects 
build/test on ARM64, so that should help. If someone wants to make a start on 
developing the cross-compilation support (though I'm not 100% sure we'll need 
it...), that would be great.

--
resolution:  -> out of date
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue42338] Enable Debug Build For Python Native Modules in Windows, with Visual Studio Toolchain

2021-02-19 Thread Steve Dower


Steve Dower  added the comment:

That's the best solution.

Alternatively, you can install the debug binaries of CPython using the option 
in the installer, recompile 3rd party packages from source, and use true debug 
builds that way.

Unfortunately, there's not much we can do about 3rd party packages being 
complicated to compile. You'll have to work with those projects.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue41837] Upgrade installers to OpenSSL 1.1.1i

2021-02-19 Thread Ned Deily


Change by Ned Deily :


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue43265] [sqlite3] Improve backup error handling

2021-02-19 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

The unit test suite shows one case of improved "exception text". I'd say it's 
an improvement.

$ ./python.exe  # with GH-24586 applied
>>> import sqlite3
>>> c1 = sqlite3.connect(":memory:")
>>> c2 = sqlite3.connect(":memory:")
>>> c1.backup(c2, name="non-existing")
Traceback (most recent call last):
  File "", line 1, in 
sqlite3.OperationalError: unknown database non-existing

$ python3.10  # latest alpha from python.org
>>> import sqlite3
>>> c1 = sqlite3.connect(":memory:")
>>> c2 = sqlite3.connect(":memory:")
>>> c1.backup(c2, name="non-existing")
Traceback (most recent call last):
  File "", line 1, in 
sqlite3.OperationalError: SQL logic error

--

___
Python tracker 

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



[issue42825] Build libraries with "/OPT:REF" linker optimization on Windows

2021-02-19 Thread Austin Lamb


Austin Lamb  added the comment:

What are the next steps for this - anything else I can provide, or is someone 
able to take a look at the Pull Request?

Thanks!

--

___
Python tracker 

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



[issue42027] /passive run of Windows installer fail silently on Win7

2021-02-19 Thread Steve Dower


Steve Dower  added the comment:

Probably an easy fix, if someone has a Win7 machine around to test on (which I 
don't these days). There are some UI level comparisons in the bootstrapper C++ 
file under Tools/msi that probably need fixing.

Not urgent. Won't be long until Win10 is the only one we have to worry about.

--
priority: normal -> low
stage:  -> needs patch
type:  -> enhancement
versions: +Python 3.10 -Python 3.9

___
Python tracker 

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



[issue43181] Python macros don’t shield arguments

2021-02-19 Thread Vitaliy

Vitaliy  added the comment:

Thanks for the fix, it works for my use case. (btw that was
#define U(...) __VA_ARGS__
and not what I wrote).

> I don't think that PR 24533 should be backported to Python 3.8 and Python 
> 3.9. I prefer to avoid any risk of regression, and so only change Python 3.10.

> For Python 3.9 and older, a workaround is to wrap the call to 
> PyObject_TypeCheck() with your own static inline function.

For Python 3.8 that fix wouldn’t be needed as the `tp` argument was 
parenthesised in the macro.

Yet... the first argument is still unshielded, passed to a macro that expects 
one single macro argument. That’s not a regression, it wasn’t shielded in 3.8 
either, but why not just parenthesise each macro argument that denotes an 
expression (as opposed to e.g. name)?

--

___
Python tracker 

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



[issue43271] AMD64 Windows10 3.x crash with Windows fatal exception: stack overflow

2021-02-19 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy: +Mark.Shannon, gvanrossum

___
Python tracker 

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



[issue37146] opcode cache for LOAD_GLOBAL emits false alarm in memory leak hunting

2021-02-19 Thread Yury Selivanov


Yury Selivanov  added the comment:

> Giving the ability to control the cache size, at least at Python startup, is 
> one option.

I'd really prefer not to allow users to control cache sizes. There's basically 
no point in that; the only practically useful thing is to enable or disable it.

--

___
Python tracker 

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



  1   2   >