[issue42889] Incorrect behavior of Python parser after ast node of test program being modified

2021-01-12 Thread Xinmeng Xia


Xinmeng Xia  added the comment:

Nice suggestion! I change the argument and I can' find segfault program in 
transforming ast.Name.  But I do find a segfault program in transforming 
ast.BinOp!

Seeing the following example, this program will cause a segmentation fault on 
Python 3.10. No error will be reported during tranforming of node, but Python 
crashes during compiling the modified AST.


import ast
class RewriteName(ast.NodeTransformer):
def visit_BinOp(self, node):
if node.left.value == 1:
node.left = node
return node

code = """
mystr  = 1 + (2+3)
"""

myast = ast.parse(code)

transformer = RewriteName()
newast = transformer.visit(myast)

c = compile(newast,'','exec')
exec(c)
===

I really think we should add a checker before compiling modified ast node or 
cancel the function of compiling AST object. An illegal AST of a program should 
not throw into "compile" function directly.

--
type: behavior -> crash

___
Python tracker 

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



[issue42880] ctypes: variadic function call still doesn't work on Apple Silicon

2021-01-12 Thread Ziqiao Kong


Ziqiao Kong  added the comment:

Hello, we do a clean reinstallation of Big Sur 11.1. The problem still exists:

with brew-installed python3.9
```
qiling@kamino /tmp % DYLD_PRINT_LIBRARIES=1 python3.9 test_main.py
[...]
dyld: loaded: <52918C9B-7E0B-3852-AB19-F74846BCAAF8> 
/Users/qiling/brew/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_heapq.cpython-39-darwin.so
dyld: loaded:  
/Users/qiling/brew/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_ctypes.cpython-39-darwin.so
dyld: loaded:  /usr/lib/libffi.dylib
dyld: loaded: <656F7BE5-2BA6-3FE9-BD31-77ED659B6194> 
/Users/qiling/brew/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_struct.cpython-39-darwin.so
dyld: loaded:  ./main.dylib
50900232
qiling@kamino /tmp % DYLD_PRINT_LIBRARIES=1 python3.9 test_main.py
[...]
dyld: loaded: <52918C9B-7E0B-3852-AB19-F74846BCAAF8> 
/Users/qiling/brew/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_heapq.cpython-39-darwin.so
dyld: loaded:  
/Users/qiling/brew/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_ctypes.cpython-39-darwin.so
dyld: loaded:  /usr/lib/libffi.dylib
dyld: loaded: <656F7BE5-2BA6-3FE9-BD31-77ED659B6194> 
/Users/qiling/brew/Cellar/python@3.9/3.9.1_6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib-dynload/_struct.cpython-39-darwin.so
dyld: loaded:  ./main.dylib
86961416
```

even the output differs between different runs...

uname -a

```
Darwin kamino.lan 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec  2 20:40:21 PST 
2020; root:xnu-7195.60.75~1/RELEASE_ARM64_T8101 arm64
```

btw, the python 3.10.0a4 built from sources:

```
qiling@kamino cpython-3.10.0a4 % DYLD_PRINT_LIBRARIES=1 ./python.exe 
test_main.py
dyld: loaded: <483C8366-9BE1-3A03-B41A-4A526F6A6F91> 
/Users/qiling/cpython-3.10.0a4/./python.exe
[...]
dyld: loaded: <97E08C95-0A13-3030-AC8D-3330CB10AD0B> 
/Users/qiling/cpython-3.10.0a4/build/lib.macosx-11.1-arm64-3.10/_ctypes.cpython-310-darwin.so
dyld: loaded:  /usr/lib/libffi.dylib
dyld: loaded: <9CA1E334-8C96-362A-B21F-9A2C43ACF58D> 
/Users/qiling/cpython-3.10.0a4/build/lib.macosx-11.1-arm64-3.10/_struct.cpython-310-darwin.so
dyld: loaded:  ./main.dylib
3
qiling@kamino cpython-3.10.0a4 % DYLD_PRINT_LIBRARIES=1 ./python.exe 
test_main.py
dyld: loaded: <483C8366-9BE1-3A03-B41A-4A526F6A6F91> 
/Users/qiling/cpython-3.10.0a4/./python.exe
[...]
dyld: loaded: <97E08C95-0A13-3030-AC8D-3330CB10AD0B> 
/Users/qiling/cpython-3.10.0a4/build/lib.macosx-11.1-arm64-3.10/_ctypes.cpython-310-darwin.so
dyld: loaded:  /usr/lib/libffi.dylib
dyld: loaded: <9CA1E334-8C96-362A-B21F-9A2C43ACF58D> 
/Users/qiling/cpython-3.10.0a4/build/lib.macosx-11.1-arm64-3.10/_struct.cpython-310-darwin.so
dyld: loaded:  ./main.dylib
3
qiling@kamino cpython-3.10.0a4 %
```

--

___
Python tracker 

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



[issue42880] ctypes: variadic function call still doesn't work on Apple Silicon

2021-01-12 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

AFAIK you should specify the types of the fixed arguments for variadic 
functions. The ABI for the M1 has a different calling convention of the 
variadic arguments, the ctypes implementation counts how many variadic 
arguments there are based on the specified number of fixed arguments.

--

___
Python tracker 

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



[issue42880] ctypes: variadic function call still doesn't work on Apple Silicon

2021-01-12 Thread Ziqiao Kong


Ziqiao Kong  added the comment:

I retry my cases with types specified and it works indeed. Maybe the documents 
should be updated for this case.

Thanks a lot!

--

___
Python tracker 

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



[issue42899] Regression __bool__ if AttributeError is raised (Possible regression introduced by bpo-42615)

2021-01-12 Thread STINNER Victor


Change by STINNER Victor :


--
title: Possible regression introduced by bpo-42615 -> Regression __bool__ if 
AttributeError is raised (Possible regression introduced by bpo-42615)

___
Python tracker 

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



[issue42903] optimize lru_cache for functions with no arguments

2021-01-12 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue42882] Restarting the interpreter causes UB on 3.10.0a4

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 44bf57aca627bd11a08b12fe4e4b6a0e1d268862 by Victor Stinner in 
branch 'master':
bpo-42882: _PyRuntimeState_Init() leaves unicode next_index unchanged (GH-24193)
https://github.com/python/cpython/commit/44bf57aca627bd11a08b12fe4e4b6a0e1d268862


--

___
Python tracker 

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



[issue42882] Restarting the interpreter causes UB on 3.10.0a4

2021-01-12 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +23024
pull_request: https://github.com/python/cpython/pull/24198

___
Python tracker 

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



[issue42882] Restarting the interpreter causes UB on 3.10.0a4

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks for your bug report, and thanks for testing alpha versions of Python! 
It's now fixed.

But I didn't feel comfortable without a regression test. So I wrote PR 24198 to 
add an unit test on _PyUnicode_FromId() with multiple Python initializations.

--

___
Python tracker 

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



[issue42902] a python embedded program may load "C:\Lib\os.py" on windows system

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

The reference documentation for the Python Path Configuration can be found at:
https://docs.python.org/dev/c-api/init_config.html#python-path-configuration

Currently, Py_SetPath(path) indirectly sets the following PyConfig members:

* prefix = ""
* exec_prefix = ""
* module_search_paths = 'path' parameter, string split at DELIM delimiter (";" 
character on Windows)
* module_search_paths_set = 1

If you want to get the current Python Path Configuration, you can use:
---
import _testinternalcapi
import pprint
pprint.pprint(_testinternalcapi.get_configs())
---

Example with Python 3.10 (extract):
---
{'config': {...
'argv': ['x.py'],
...
'base_exec_prefix': '/usr/local',
'base_executable': '/home/vstinner/python/master/python',
'base_prefix': '/usr/local',
...
'exec_prefix': '/usr/local',
'executable': '/home/vstinner/python/master/python',
...
'home': None,
...
'module_search_paths': ['/usr/local/lib/python310.zip',
'/home/vstinner/python/master/Lib',

'/home/vstinner/python/master/build/lib.linux-x86_64-3.10-pydebug'],
'module_search_paths_set': 1,
...
'orig_argv': ['./python', 'x.py'],
'parse_argv': 2,
...
'pathconfig_warnings': 1,
'platlibdir': 'lib',
'prefix': '/usr/local',
'program_name': './python',
...},
 ...,
 'path_config': {'exec_prefix': '/usr/local',
 'home': None,
 'module_search_path': 
'/usr/local/lib/python310.zip:/home/vstinner/python/master/Lib:/home/vstinner/python/master/build/lib.linux-x86_64-3.10-pydebug',
 'prefix': '/usr/local',
 'program_full_path': '/home/vstinner/python/master/python',
 'program_name': './python'},
 ...}
---

See also bpo-42260: "[C API] Add PyInterpreterState_SetConfig(): reconfigure an 
interpreter" which aims to rewrite the code to configure the Python Path 
Configuration from C to Python.

--

___
Python tracker 

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



[issue42899] Regression __bool__ if AttributeError is raised (Possible regression introduced by bpo-42615)

2021-01-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I am not sure that it should be fixed.

We already cut corners in similar cases and did this for years, and it always 
was okay. In the following example bool(a) is only called once:

if a and b:
f()

  1   0 LOAD_NAME0 (a)
  2 POP_JUMP_IF_FALSE   14
  4 LOAD_NAME1 (b)
  6 POP_JUMP_IF_FALSE   14

  2   8 LOAD_NAME2 (f)
 10 CALL_FUNCTION0
 12 POP_TOP
>>   14 LOAD_CONST   0 (None)
 16 RETURN_VALUE

It differs from the case of using temporary variable (optimization does not 
work here):

t = a and b
if t:
f()

  1   0 LOAD_NAME0 (a)
  2 JUMP_IF_FALSE_OR_POP 6
  4 LOAD_NAME1 (b)
>>6 STORE_NAME   2 (t)

  2   8 LOAD_NAME2 (t)
 10 POP_JUMP_IF_FALSE   18

  3  12 LOAD_NAME3 (f)
 14 CALL_FUNCTION0
 16 POP_TOP
>>   18 LOAD_CONST   0 (None)
 20 RETURN_VALUE

(BTW, Python 3.10 produces less optimal code for that examples)

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue42902] a python embedded program may load "C:\Lib\os.py" on windows system

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

Python has an unit test on Py_SetPath(): test_embed.test_init_setpath.

> Write following code that only call Py_Initialize(): (...)

Do you mean that on Windows Python looks for modules in C:\Lib\ just by calling 
Py_Initialize()? 


> According to https://docs.python.org/3/c-api/init.html: "Py_SetPath() set the 
> default module search path.

I don't understand. Do you have your issue with and without calling 
Py_SetPath()? Can you please provide an example of code reproducing the issue?

--

___
Python tracker 

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



[issue42902] a python embedded program may load "C:\Lib\os.py" on windows system

2021-01-12 Thread Paul Moore


Paul Moore  added the comment:

I thought that *all* versions of Python located the standard library by 
searching for os.py...

--

___
Python tracker 

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



[issue42902] a python embedded program may load "C:\Lib\os.py" on windows system

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

> I thought that *all* versions of Python located the standard library by 
> searching for os.py...

The current implementation of the Python Path Configuration can be found in:

* Windows: PC/getpathp.c
* Unix: Modules/getpath.c

It should be skipped if Py_SetPath() is used, but I recommend to only rely on 
PyConfig and its documentation:
https://docs.python.org/dev/c-api/init_config.html#python-path-configuration

If the documentation is wrong, it must be fixed ;-)

I still don't understand if the issue involves Py_SetPath() or not.

--

___
Python tracker 

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



[issue42882] Restarting the interpreter causes UB on 3.10.0a4

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 11d13e83abedabba12b28773317f1a365113e7af by Victor Stinner in 
branch 'master':
bpo-42882: Add test_embed.test_unicode_id_init() (GH-24198)
https://github.com/python/cpython/commit/11d13e83abedabba12b28773317f1a365113e7af


--

___
Python tracker 

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



[issue42762] infinite loop resulted by "yield"

2021-01-12 Thread Steve Stagg


Steve Stagg  added the comment:

I don't believe this is a bug.

You've discovered a nasty corner-case, but I think it's expected behaviour.  
There is a PEP open to make this behaviour a bit nicer:  
https://www.python.org/dev/peps/pep-0533/

The fact that older Python 3.5/6 versions don't get the infinite loop could be 
considered a bug, but this was fixed a while ago (bpo-25612), and it seems 
unlikely that this fix would be back-ported.

--

___
Python tracker 

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



[issue42882] Restarting the interpreter causes UB on 3.10.0a4

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

Ok, now I can safely close the issue ;-)

--
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



[issue42906] python3 -m doctest test.py tests the stdlib "time" module instead

2021-01-12 Thread Stijn van Drongelen


New submission from Stijn van Drongelen :

I have two files, named time.py and time_.py, with the same contents:

def foo():
"""Returns 1.

>>> foo()
1
"""
return 1

When I run

python3 -m doctest -v time_.py

I see the expected behaviour:

Trying:
foo()
Expecting:
1
ok
1 items had no tests:
time_
1 items passed all tests:
   1 tests in time_.foo
1 tests in 2 items.
1 passed and 0 failed.
Test passed.

However, when I run

python3 -m doctest -v time_.py

it seems like doctest is testing the standard library 'time' module, while I 
expected it to have similar output as seen above:

30 items had no tests:
time
time.asctime
  (... skipped 24 lines for the bug report ...)
time.time_ns
time.tzset
0 tests in 30 items.
0 passed and 0 failed.
Test passed.

The same happens when I provide a path with slashes in it.

--
components: Library (Lib)
messages: 384913
nosy: stijnvandrongelen
priority: normal
severity: normal
status: open
title: python3 -m doctest test.py tests the stdlib "time" module instead
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue42906] python3 -m doctest test.py tests the stdlib "time" module instead

2021-01-12 Thread Stijn van Drongelen


Stijn van Drongelen  added the comment:

Reproducible in Python 3.8.7 and 3.9.1.

--
versions: +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



[issue42907] Division betwen float and 100 not giving corect result

2021-01-12 Thread Dimo Yordanov


New submission from Dimo Yordanov :

To replicate what i think is a bug you need a python interpreter in any 
version. I think. When i type 2.7/100 it returns 0.027003, but it 
actually is 0.027 and 2.8/100 returns 0.027997. And i don't know why

--
components: Interpreter Core
messages: 384915
nosy: DimoY
priority: normal
severity: normal
status: open
title: Division betwen float and 100 not giving corect result
type: behavior
versions: Python 3.7

___
Python tracker 

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



[issue42907] Division betwen float and 100 not giving corect result

2021-01-12 Thread Dimo Yordanov


Dimo Yordanov  added the comment:

And it appears that these are the only numbers (2.8 and 2.7) that behave like 
this

--

___
Python tracker 

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



[issue42907] Division betwen float and 100 not giving corect result

2021-01-12 Thread Christian Heimes


Christian Heimes  added the comment:

This is the expected behavior for float. Python's floats are IEEE 754 double 
precision floats, not arbitrary preciscion floats. See 
https://docs.python.org/3/tutorial/floatingpoint.html

--
nosy: +christian.heimes
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



[issue42907] Division betwen float and 100 not giving corect result

2021-01-12 Thread Dimo Yordanov


Dimo Yordanov  added the comment:

understandable. have a great day

--
components:  -Interpreter Core
resolution: not a bug -> 
status: closed -> open
versions:  -Python 3.7

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Mark Shannon


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 
`bool(a and b)` must be False, so we skip testing `a and b`.
However, we do not know that `bool(a and b)` cannot have a side-effect, so the 
optimization could be incorrect w.r.t. side effects.

--
title: Regression __bool__ if AttributeError is raised (Possible regression 
introduced by bpo-42615) -> Is it legal to eliminate tests of a value, when 
that test has no effect on control flow?

___
Python tracker 

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



[issue42908] Incorrect line numbers at end of try-except and with statements containing if False: pass

2021-01-12 Thread Mark Shannon


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

--
assignee: Mark.Shannon
messages: 384920
nosy: Mark.Shannon
priority: high
severity: normal
status: open
title: Incorrect line numbers at end of try-except and with statements 
containing if False: pass

___
Python tracker 

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



[issue42907] Division betwen float and 100 not giving corect result

2021-01-12 Thread Christian Heimes


Change by Christian Heimes :


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

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Steve Stagg


Steve Stagg  added the comment:

To be super pedantic, as per my understanding of:

"6.11 ... The expression x and y first evaluates x; if x is false, its value is 
returned; otherwise, y is evaluated and the resulting value is returned."

The only corner that was previously cut is that in this statement:

if a and b:
...


The evalution should be roughly equivalent to:

bool(a) if bool(a) else bool(b) # <- where bool(b) is never called

instead it's more like:

_x if _x := bool(a) else bool(b) # <- where bool(b) is never called

so, the runtime is eliding a repeated call to bool(a).

This obviously causes problems if bool(a) has per-call side-effects, but this 
seems to me like a reasonable corner to cut.

Totally eliding the if clause feels to me (subjectively) like a much more risky 
proposition, and perhaps one that should be documented if kept in?

--

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Steve Stagg


Steve Stagg  added the comment:

I got my and/or logic inverted, but believe the point still stands

--

___
Python tracker 

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



[issue42862] Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module

2021-01-12 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

I can throw up the PoC branch as a draft PR after GH-24135 is merged. We can 
just close the PR if this is uninteresting or something we want to postpone.

--

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you Steve. Yes, this is what I meant. "if a and b" is so common that we 
sacrifice literal translation for the sake of performance.

"if" with an empty block looks pretty uncommon to me. It is not worth to 
optimize this case specially (especially if it changes semantic). What are real 
world examples for which it makes sense to replace POP_JUMP_IF_FALSE with 
POP_TOP?

--
nosy: +gvanrossum

___
Python tracker 

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



[issue42904] get_type_hints does not provide localns for classes

2021-01-12 Thread Ken Jin


Ken Jin  added the comment:

> Fidget-Spinner, are you interested in taking this?

Sure thing! Please give me some time to look at it - I don't really use the 
runtime type validation stuff from typing (I usually defer that to 3rd party 
libraries), so I need to familiarize myself first.

--
nosy: +kj

___
Python tracker 

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



[issue42862] Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module

2021-01-12 Thread Berker Peksag


Berker Peksag  added the comment:

I don't see any reason to merge GH-24135 if we are going to remove cache.[ch] 
in this issue.

I was -0 before but since Raymond gave his +1, you can count me as +1 too.

--

___
Python tracker 

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



[issue42862] Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module

2021-01-12 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> I don't see any reason to merge GH-24135 if we are going to remove cache.[ch] 
> in this issue.

Yes, I've thought about that myself. A small argument pro merging GH-24135 
would be that if we for some reason decide to revert this change, then 
cache.[ch] would still be prepared for module state (which is needed for 
multi-phase init).

--

___
Python tracker 

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



[issue42862] Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module

2021-01-12 Thread Berker Peksag


Berker Peksag  added the comment:

We can always reopen GH-24135 and merge it even if we revert this one for some 
reason :)

--

___
Python tracker 

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



[issue42862] Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module

2021-01-12 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

True that :) I'll close GH-24135 for now and open a PR for this later today.

--

___
Python tracker 

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



[issue41490] Update bundled pip to 20.2.1 and setuptools to 49.2.1

2021-01-12 Thread Julien Palard


Julien Palard  added the comment:

Question: Why do we keep setuptools?

According to PEP453:

> Once pip is able to run pip install --upgrade pip without needing setuptools 
> installed first, then the private copy of setuptools will be removed from 
> ensurepip in subsequent CPython releases.

Which looks like to be the fact now:

$ python3.9 -m venv .venv
$ source .venv/bin/activate
$ pip uninstall setuptools
[...]
Successfully uninstalled setuptools-49.2.1
$ pip install --upgrade pip
[...]
Successfully installed pip-20.3.3

--
nosy: +mdk

___
Python tracker 

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



[issue42909] Email header with ; ; ; ; stuffing takes very long to parse

2021-01-12 Thread robin


New submission from robin :

Attached please find a script which takes on the order of 1 minute to parse 
even though the embedded message is reasonably trivial.  The main flaw is that 
the Content-Type: header has a long string of redundant  which is something 
some spammers apparently use to bypass some content filters or analyzers.

The script is short enough to inline here for what I hope is convenience for 
most visitors.


from email import message_from_bytes
#from email.parser import BytesParser
from email.policy import default
##from cProfile import run as cprun

b = (b'''From: me 
To: you 
Subject: sample with ; stuffing in MIME Content-Type: header
Content-type: text/plain''' + b';' * 54 + b'\n' +
   36 * (b' ' + b';' * 990 + b'\n') + b'''\
Content-transfer-encoding: 7bit
MIME-Version: 1.0

Hello.
''')
## cprun('message_from_bytes(b, policy=default)', sort=1)

m = message_from_bytes(b, policy=default)
#m = BytesParser(policy=default).parsebytes(b)

print(m.as_string())


I have commented out two sets of changes; the ones with a single # demonstrate 
that the same error happens with BytesParser, and the ones with ## are for 
profiling the code.

For what it's worth, profiling consistently indicates that it gets stuck in 
builtins.sum while attempting to parse the message.  Here is a partial cProfile 
result from Python 3.7.2:

 
 2148205 function calls (2004560 primitive calls) in 34.533 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
160/4   32.3560.202   32.7288.182 {built-in method builtins.sum}
40.5600.1401.6610.415 
_header_value_parser.py:2380(parse_mime_parameters)
   1427720.2300.0000.2300.000 {method 'format' of 'str' objects}
   1429320.2030.0000.2030.000 
_header_value_parser.py:866(all_defects)
   1427720.1970.0000.2880.000 errors.py:84(__init__)
143248/240.1670.000   32.7271.364 
_header_value_parser.py:126()
   1427720.1510.0000.4560.000 
_header_value_parser.py:2126(get_attribute)
   2858480.1460.0000.1460.000 
_header_value_parser.py:109(__init__)
   1427720.1020.0000.6310.000 
_header_value_parser.py:2241(get_parameter)
   1427720.0910.0000.0910.000 errors.py:36(__init__)
   1430760.0880.0000.1530.000 
_header_value_parser.py:854(__new__)
   1430800.0650.0000.0650.000 {built-in method __new__ of type 
object at 0x101c20640}
   120.0440.0040.0860.007 
_header_value_parser.py:716(params)
   2858390.0420.0000.0420.000 {method 'endswith' of 'str' 
objects}
30.0300.010   27.5129.171 
message.py:588(get_content_maintype)
   2864820.0290.0000.0290.000 {method 'append' of 'list' 
objects}
20.0140.0070.0140.007 :914(get_data)
60.0080.001   25.3694.228 feedparser.py:218(_parsegen)
40.0010.0000.0010.000 {method 'split' of 're.Pattern' 
objects}
160/40.0010.000   32.7288.182 
_header_value_parser.py:124(all_defects)
  2880.0010.0000.0020.000 
_header_value_parser.py:1000(get_fws)
  2880.0010.0000.0030.000 
_header_value_parser.py:1217(get_cfws)



Starting the code and doing a KeyboardInterrupt after a few, or many, seconds 
tends to get a traceback like this, which also points to roughly the same 
culprit:


^CTraceback (most recent call last):
  File "repro.py", line 18, in 
m = message_from_bytes(b, policy=default)
  File "/Users/eriker/.pyenv/versions/3.7.2/lib/python3.7/email/__init__.py", 
line 46, in message_from_bytes
return BytesParser(*args, **kws).parsebytes(s)
  File "/Users/eriker/.pyenv/versions/3.7.2/lib/python3.7/email/parser.py", 
line 124, in parsebytes
return self.parser.parsestr(text, headersonly)
  File "/Users/eriker/.pyenv/versions/3.7.2/lib/python3.7/email/parser.py", 
line 68, in parsestr
return self.parse(StringIO(text), headersonly=headersonly)
  File "/Users/eriker/.pyenv/versions/3.7.2/lib/python3.7/email/parser.py", 
line 57, in parse
feedparser.feed(data)
  File "/Users/eriker/.pyenv/versions/3.7.2/lib/python3.7/email/feedparser.py", 
line 176, in feed
self._call_parse()
  File "/Users/eriker/.pyenv/versions/3.7.2/lib/python3.7/email/feedparser.py", 
line 180, in _call_parse
self._parse()
  File "/Users/eriker/.pyenv/versions/3.7.2/lib/python3.7/email/feedparser.py", 
line 256, in _parsegen
if self._cur.get_content_type() == 'message/delivery-status':
  File "/Users/eriker/.pyenv/versions/3.7.2/lib/python3.7/email/message.py", 
line 578, in get_content_type
value = self.get('content-type', missing)
  File "/Users/eriker/.pyenv/versions/3.7.2/lib/python3.7/email/message.py", 
line 471, in get
return self.policy.header_fetch_parse(k, v)
  File "/Use

[issue42905] Issue while installing numba inside fastparquet

2021-01-12 Thread Steve Stagg


Steve Stagg  added the comment:

Hi Sachit

I see you raised this issue with the numba library here:
https://github.com/numba/numba/issues/6630

I would recommend sticking with the numba issue unless they can confirm there 
is an issue with core python

--
nosy: +stestagg

___
Python tracker 

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



[issue42905] Issue while installing numba inside fastparquet

2021-01-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Neither numba nor fastparquet are parts of the standard Python library. Please 
use corresponding bug trackers.

--
nosy: +serhiy.storchaka
resolution:  -> third party
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



[issue42880] ctypes: variadic function call still doesn't work on Apple Silicon

2021-01-12 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

I agree that this should be mentioned in the documentation for ctypes.

--

___
Python tracker 

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



[issue42880] ctypes: variadic function call still doesn't work on Apple Silicon

2021-01-12 Thread Ronald Oussoren


Change by Ronald Oussoren :


--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python

___
Python tracker 

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



[issue42862] Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module

2021-01-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I do not like using _functools._lru_cache_wrapper. It is a deep implementation 
detail, private function of private module. Use functools.lru_cache. If it is 
few nanoseconds slower, that cost is only added at connection creation time. It 
is insignificant in any real application in comparison with IO and any real 
work with data. Thousands of short-living in-memory DB instances are only 
created in tests.

--

___
Python tracker 

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



[issue25235] EmailMessage.add_attachment() creates parts with spurious MIME-Version header.

2021-01-12 Thread robin


robin  added the comment:

Duplicate of https://bugs.python.org/issue11021 but this one is more current 
and has a patch.

--
nosy: +eriker

___
Python tracker 

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



[issue11021] email MIME-Version headers for each part in multipart message

2021-01-12 Thread robin


robin  added the comment:

Propose to close as duplicate of https://bugs.python.org/issue25235

--
nosy: +eriker

___
Python tracker 

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



[issue42909] Email header with ; ; ; ; stuffing takes very long to parse

2021-01-12 Thread robin


robin  added the comment:

python -mtrace -t repro.py reveals a long string of these:


 --- modulename: errors, funcname: __init__
errors.py(85): super().__init__(*args, **kw)
 --- modulename: errors, funcname: __init__
errors.py(37): if line is not None:
errors.py(38): super().__init__(line)
errors.py(39): self.line = line
_header_value_parser.py(2417): if value and value[0] != ';':
_header_value_parser.py(2426): if value:
_header_value_parser.py(2428): 
mime_parameters.append(ValueTerminal(';', 'parameter-separator'))
 --- modulename: _header_value_parser, funcname: __new__
_header_value_parser.py(855): self = super().__new__(cls, value)
_header_value_parser.py(856): self.token_type = token_type
_header_value_parser.py(857): self.defects = []
_header_value_parser.py(858): return self
_header_value_parser.py(2429): value = value[1:]
_header_value_parser.py(2394): while value:
_header_value_parser.py(2395): try:
_header_value_parser.py(2396): token, value = get_parameter(value)
 --- modulename: _header_value_parser, funcname: get_parameter
_header_value_parser.py(2252): param = Parameter()
 --- modulename: _header_value_parser, funcname: __init__
_header_value_parser.py(110): super().__init__(*args, **kw)
_header_value_parser.py(111): self.defects = []
_header_value_parser.py(2253): token, value = get_attribute(value)
 --- modulename: _header_value_parser, funcname: get_attribute
_header_value_parser.py(2135): attribute = Attribute()
 --- modulename: _header_value_parser, funcname: __init__
_header_value_parser.py(110): super().__init__(*args, **kw)
_header_value_parser.py(111): self.defects = []
_header_value_parser.py(2136): if value and value[0] in CFWS_LEADER:
_header_value_parser.py(2139): if value and value[0] in ATTRIBUTE_ENDS:
_header_value_parser.py(2140): raise errors.HeaderParseError(
_header_value_parser.py(2141): "expected token but found 
'{}'".format(value))
_header_value_parser.py(2398): except errors.HeaderParseError as err:
_header_value_parser.py(2399): leader = None
_header_value_parser.py(2400): if value[0] in CFWS_LEADER:
_header_value_parser.py(2402): if not value:
_header_value_parser.py(2405): if value[0] == ';':
_header_value_parser.py(2406): if leader is not None:
_header_value_parser.py(2408): 
mime_parameters.defects.append(errors.InvalidHeaderDefect(
_header_value_parser.py(2409): "parameter entry with no 
content"))


... which would make sense as such, except at the end, the list of defects is 
empty.  And, of course, it should not take so long.

--

___
Python tracker 

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



[issue42843] What min_sphinx for Python 3.10

2021-01-12 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10, vstinner

___
Python tracker 

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



[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-01-12 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue25077] Compiler warnings: initialization from incompatible pointer type

2021-01-12 Thread Irit Katriel


Irit Katriel  added the comment:

Issues 22038 and 23085 seem to have fixed all these warnings between them.

--
nosy: +iritkatriel
resolution:  -> out of date
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



[issue16615] gcc 4.7 unused-but-set warnings

2021-01-12 Thread Irit Katriel


Irit Katriel  added the comment:

Is this about the pre-version 3.3 warnings? If so it can be closed.

--
nosy: +iritkatriel
status: open -> pending

___
Python tracker 

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



[issue16615] gcc 4.7 unused-but-set warnings

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

We are now dealing with GCC 11 warnings, I close this issue. Moreover, the GCC 
warnings are not mentioned.

--
nosy: +vstinner
resolution:  -> out of date
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Mark Shannon


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 the second is, why?


B.T.W it is trivial to change the behavior, once we've decided what's correct.

--

___
Python tracker 

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



[issue41994] Refcount issues in import

2021-01-12 Thread Petr Viktorin


Petr Viktorin  added the comment:


New changeset 4db8988420e0a122d617df741381b0c385af032c by Serhiy Storchaka in 
branch 'master':
bpo-41994: Fix refcount issues in Python/import.c (GH-22632)
https://github.com/python/cpython/commit/4db8988420e0a122d617df741381b0c385af032c


--
nosy: +petr.viktorin

___
Python tracker 

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



[issue42910] Wrong code appears in the type alias introduction

2021-01-12 Thread Casuall

New submission from Casuall :

I learned about type aliases on the 
page(https://docs.python.org/3/library/typing.html), and I found that following 
the code (Vector = list[float])in the tutorial, an error occurred (NameError: 
name 'typing' is not defined) when running.

The following code has the same problem:
  ConnectionOptions = dict[str, str]
  Address = tuple[str, int]
  Server = tuple[Address, ConnectionOptions]

I searched through google and found the correct code:
  from typing import List
  Vector = List[float]

  from typing import Dict, Tuple, Sequence
 
  ConnectionOptions = Dict[str, str]
  Address = Tuple[str, int]
  Server = Tuple[Address, ConnectionOptions]

--
assignee: docs@python
components: Documentation
messages: 384944
nosy: Smile-zjk, docs@python
priority: normal
severity: normal
status: open
title: Wrong code appears in the type alias introduction

___
Python tracker 

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



[issue40052] Incorrect pointer alignment in _PyVectorcall_Function() of cpython/abstract.h

2021-01-12 Thread Petr Viktorin


Petr Viktorin  added the comment:


New changeset 187f76def8a5bd0af7ab512575cad30cfe624b05 by Petr Viktorin in 
branch '3.8':
[3.8] bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999) 
(GH-24120)
https://github.com/python/cpython/commit/187f76def8a5bd0af7ab512575cad30cfe624b05


--

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

For the latter, it was decided that it is legal a long time ago. It has a 
benefit and we did not have any complains for all these years. The absent of 
this optimization would encourage writing less readable code for performance.

For the former, what is the benefit?

--

___
Python tracker 

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



[issue41994] Refcount issues in import

2021-01-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you Petr!

--
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



[issue42910] Wrong code appears in the type alias introduction

2021-01-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What version of Python did you use? This is a documentation for Python 3.9.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue42911] Addition chains for pow saves 10 % time!

2021-01-12 Thread Jurjen N.E. Bos


New submission from Jurjen N.E. Bos :

When looking at the code of pow() with integer exponent, I noticed there is a 
hard boundary between the binary and "fiveary" (actually 32-ary) computations. 
Also, the fiveary wasn't really optimal.

So I wrote a proof of concept version of long_pow that dynamically uses 
addition chains!
It does save over 10 % of multiplications for exponents from 20 to a few 
hundred bits, and then the saving go down to a few percent for very long 
numbers. It does not take much more memory nor time for any argument 
combination I checked.
I tested it on 3.8rc1, but I am planning to port it to 3.10. This is a bit 
difficult, since *lots* of code around it changed, and I only have Windows 7. 
However, I'll keep you posted.
See https://github.com/jneb/cpython/tree/38_fast_pow

--
components: Interpreter Core
files: longobject.c
messages: 384949
nosy: jneb
priority: normal
severity: normal
status: open
title: Addition chains for pow saves 10 % time!
type: performance
versions: Python 3.10
Added file: https://bugs.python.org/file49737/longobject.c

___
Python tracker 

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



[issue42843] What min_sphinx for Python 3.10

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

> Some distribs may want/need to ship Python 3.10 along with Sphinx 2?

In my experience, Linux distributions prefer to only ship a single Sphinx 
version. The question is more which Linux distributions are stuck at Sphinx 2 
only?

If there is a short list of Linux distributions which cannot use Sphinx 3, even 
just to build the Python documentation, would it be acceptable for them to stop 
shipping the Python documentation?

In Fedora, the Python documentation is a separated package. For example, it 
allows us to upgrade Python while Fedora Rawhide was upgrade to Sphinx 3 but 
the Python documentation was not compatible with Sphinx 3 (fixed in bpo-40204).

If you ask *me*: I mostly care about Fedora which already uses Sphinx 3.2, so 
I'm fine with requiring Sphinx 3.2 (the Python documentation is *not* 
compatible with Sphinx 3.0 and 3.1: see bpo-40204).

If the minimum required Sphinx version changes, please document it properly at:
https://docs.python.org/dev/whatsnew/3.10.html#build-changes

--

___
Python tracker 

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



[issue42874] running configure on Solaris 10 gives grep "illegal option" errors

2021-01-12 Thread Paul Ganssle


Change by Paul Ganssle :


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

___
Python tracker 

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



[issue42874] running configure on Solaris 10 gives grep "illegal option" errors

2021-01-12 Thread Paul Ganssle


Paul Ganssle  added the comment:

This particular grep statement is used to validate the `tzpath` variable. 
Apparently it is easy enough to achieve what I was going for using vanilla grep 
with no options, so I've created GH-24200 to fix the issue.

I notice that there are other uses of `-q` and `-E` in the configure file, but 
presumably those are on more optional paths.

@martin.wheatley.home: Can you check to see if GH-24200 fixes your issue?

Also, can you clarify whether this happens with a plain `./configure` 
invocation, or are you specifying `./configure 
--with-tzpath='/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo'`
 yourself?

--
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



[issue42904] get_type_hints does not provide localns for classes

2021-01-12 Thread Ken Jin


Change by Ken Jin :


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

___
Python tracker 

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



[issue42903] optimize lru_cache for functions with no arguments

2021-01-12 Thread Eugene Toder


Eugene Toder  added the comment:

@cache does not address the problem or any of the concerns brought up in the 
thread. Thread-safe @once is a nice idea, but more work of course.

--

___
Python tracker 

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



[issue42874] running configure on Solaris 10 gives grep "illegal option" errors

2021-01-12 Thread Martin Wheatley


Martin Wheatley  added the comment:

I'll do the test

it happens with a plain ./configure

Many thanks
Martin

On Tue, 12 Jan 2021 at 15:11, Paul Ganssle  wrote:

>
> Paul Ganssle  added the comment:
>
> This particular grep statement is used to validate the `tzpath` variable.
> Apparently it is easy enough to achieve what I was going for using vanilla
> grep with no options, so I've created GH-24200 to fix the issue.
>
> I notice that there are other uses of `-q` and `-E` in the configure file,
> but presumably those are on more optional paths.
>
> @martin.wheatley.home: Can you check to see if GH-24200 fixes your issue?
>
> Also, can you clarify whether this happens with a plain `./configure`
> invocation, or are you specifying `./configure
> --with-tzpath='/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo'`
> yourself?
>
> --
> versions: +Python 3.10
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue42910] Wrong code appears in the type alias introduction

2021-01-12 Thread Casuall

Casuall  added the comment:

I am using python3.8, it turned out to be a version issue, sorry

-- 原始邮件 --
发件人:
"Python tracker"

https://bugs.python.org/issue42910>;
___

--

___
Python tracker 

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



[issue42874] running configure on Solaris 10 gives grep "illegal option" errors

2021-01-12 Thread Martin Wheatley


Martin Wheatley  added the comment:

I'll do the test

it happens with a plain ./configure

Many thanks
Martin

On Tue, 12 Jan 2021 at 15:11, Paul Ganssle  wrote:

>
> Paul Ganssle  added the comment:
>
> This particular grep statement is used to validate the `tzpath` variable.
> Apparently it is easy enough to achieve what I was going for using vanilla
> grep with no options, so I've created GH-24200 to fix the issue.
>
> I notice that there are other uses of `-q` and `-E` in the configure file,
> but presumably those are on more optional paths.
>
> @martin.wheatley.home: Can you check to see if GH-24200 fixes your issue?
>
> Also, can you clarify whether this happens with a plain `./configure`
> invocation, or are you specifying `./configure
> --with-tzpath='/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo'`
> yourself?
>
> --
> versions: +Python 3.10
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue42910] Wrong code appears in the type alias introduction

2021-01-12 Thread Casuall


Change by Casuall :


--
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



[issue42908] Incorrect line numbers at end of try-except and with statements containing if False: pass

2021-01-12 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue24650] Error in yield expression documentation

2021-01-12 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +easy
versions: +Python 3.10 -Python 3.3, Python 3.4, 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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

Can we translate 'if x: pass' into 'pass'? No, because calling its __bool__ 
method may have a side effect (as we saw at the start of this thread).

Can we eliminate a lone 'x'? Only if it's a local variable and we're *sure* 
(because of control flow analysis) that it's got a value. For globals and class 
variables we must execute the load because there could always be an exception 
(or the dict could have a trap for lookups).

Can we eliminate e.g. 'x.y'? Never, because it can have a side effect.

In general, eliminating this kind of thing seems silly -- in code that the user 
intends to be fast such things don't occur, and in test the user probably has a 
reason to write odd code.


On the other question, I don't see how there's any possible difference in 
evaluation and side effects between

if a and b: ...

and

if a:
if b:
...

so I have no problem with that (in fact that is what it *means*).

--

___
Python tracker 

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



[issue42911] Addition chains for pow saves 10 % time!

2021-01-12 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy: +mark.dickinson, tim.peters

___
Python tracker 

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



[issue42889] Incorrect behavior of Python parser after ast node of test program being modified

2021-01-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

Yeah, there's supposed to be a checker.

--
nosy: +lys.nikolaou, serhiy.storchaka

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Mark Shannon


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 between True and 
False.

If we say that such behavior is illegal, and can be ignored by the optimizer, 
then 3.10 is correct (as it stands).

My example was wrong though, as you've pointed out.
`if x: pass` it transformed to `x`. It is the test that is eliminated, not the 
evaluation of `x`.

--
priority: release blocker -> normal

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Mark Shannon


Change by Mark Shannon :


--
priority: normal -> release blocker

___
Python tracker 

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



[issue42843] What min_sphinx for Python 3.10

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

Ah, the issue is also being discussed in PR 24142 comments.

--

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Ethan Furman


Ethan Furman  added the comment:

If an optimization changes semantics it's not an optimization.

In  `if x: pass` how do we know `x` is falsely without calling `bool()` on it?

---

On a slightly different note, in the code:

if a and b:
   ...

why is `bool(a)` called twice?

--
nosy: +ethan.furman

___
Python tracker 

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



[issue41116] build on macOS 11 (beta) does not find system-supplied third-party libraries

2021-01-12 Thread seb


seb  added the comment:

I tried that before, also with your command, without success. I saw that the 
CFLAGS includes weren't forwarded to the compiler - I don't know if that is 
only an issue here on my system. So instead I modified the setup.py and added 
the directory manually. It now works. Thanks for your help!!

--

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Mark Shannon


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 being an optimization if it changes the 
semantics. But only within agreed semantics.
Optimizations are allow to make fewer calls to __hash__() in a dictionary, or 
change race conditions, because those are outside of the language specification.

--

___
Python tracker 

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



[issue42843] What min_sphinx for Python 3.10

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

* Fedora 33 (stable) ships python3-sphinx 3.2.1-1 and python3.10 version 
3.10.0~a3-1 (the alpha4 is under tests).
* Debian Buster (stable) ships python3-sphinx 1.8.4-1 and python3 version 
3.7.3-1
* Debian Sid (unstable) ships python3-sphinx 3.4.3-1 and python3 version 
3.9.1-1.
* Ubuntu Groovy (stable) ships python3-sphinx 3.2.1-1 and python3 version 
3.8.6-0ubuntu1
* Ubuntu Hirsute (dev) ships python3-sphinx 3.3.1-1 and python3 version 
3.9.0-3ubuntu1

In this list, requiring Sphinx 3.2+ to build Python 3.10 documentation would 
only be an issue on Debian Buster.

I didn't check Red Hat RHEL or SUSE SLE. If they want to ship Python 3.10 but 
only have an old Sphinx, they can either use a newer Sphinx to build the doc, 
or ship Python 3.10 with no doc (since it would not be the "system Python", it 
may be an acceptable tradeoff).

--

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Mark Shannon


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 
value of `x`.

--

___
Python tracker 

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



[issue42843] What min_sphinx for Python 3.10

2021-01-12 Thread STINNER Victor


Change by STINNER Victor :


--
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



[issue42843] What min_sphinx for Python 3.10

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

There is a PPA on Ubuntu for Python 3.10. The PPA maintainer considers the drop 
the documentation, see discussion at:
https://github.com/python/cpython/pull/23620#issuecomment-755423140

--

___
Python tracker 

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



[issue42902] a python embedded program may load "C:\Lib\os.py" on windows system

2021-01-12 Thread Eryk Sun


Eryk Sun  added the comment:

> I still don't understand if the issue involves Py_SetPath() or not.

It seems to me that this issue is concerned with the default behavior that 
looks for the "lib/os.py" landmark via search_for_prefix() in PC/getpathp.c. 
Starting at the image path, it searches for the landmark up to the root 
directory. Any authenticated user can create a "C:/Lib" directory.

That said, I don't think the normal Python distribution is intended to be a 
base installation for embedding applications, as opposed to using a private 
copy of the embedded distribution. So in practice there may be no issue here.

--
nosy: +eryksun

___
Python tracker 

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



[issue42902] a python embedded program may load "C:\Lib\os.py" on windows system

2021-01-12 Thread STINNER Victor


STINNER Victor  added the comment:

Hum. The code in Python 3.8 is complicated. When Py_SetPath() is called, Python 
starts by computing the Python Path Configuration because of:

/* Getting the program full path calls pathconfig_global_init() */
wchar_t *program_full_path = _PyMem_RawWcsdup(Py_GetProgramFullPath());

The result is stored info _Py_path_config. Then Py_SetPath() overrides 
program_full_path, prefix, exec_prefix and module_search_path of 
_Py_path_config.

When Python reachs Py_Initialize(), PyConfig_Read() does not compute the Python 
Path Configuration, but copies what comes from _Py_path_config.

--

I changed the code a lot of Python 3.10 to make it more deterministic and 
simpler. For example, Py_SetPath() no longer computes the Python Path 
Configuration.

commit ace3f9a0ce7b9fe8ae757fdd614f1e7a171f92b0
Author: Victor Stinner 
Date:   Tue Nov 10 21:10:22 2020 +0100

bpo-42260: Fix _PyConfig_Read() if compute_path_config=0 (GH-23220)

Fix _PyConfig_Read() if compute_path_config=0: use values set by
Py_SetPath(), Py_SetPythonHome() and Py_SetProgramName(). Add
compute_path_config parameter to _PyConfig_InitPathConfig().

The following functions now return NULL if called before
Py_Initialize():

* Py_GetExecPrefix()
* Py_GetPath()
* Py_GetPrefix()
* Py_GetProgramFullPath()
* Py_GetProgramName()
* Py_GetPythonHome()

These functions no longer automatically computes the Python Path
Configuration. Moreover, Py_SetPath() no longer computes
program_full_path.

This change is a little bit backward incompatible, even I would not recommend 
to call Py_GetXXX() functions before Py_Initialize() in Python 3.8 or 3.9.

--

___
Python tracker 

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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

If the body of a conditional does nothing, it seems fine to optimize the 
condition out to me.  But I see code from a low level compiled language 
perspective where that is clearly what would happen.  In reality, who ever 
meaningfully writes code where the body of a conditional does nothing?

 * Placeholder code with a # TODO perhaps.  [fine to optimize out]
 * Unit tests attempting to test the behavior of __bool__().  [an annoying 
behavior change]

Are there others?  Are we expecting this odd "not quite a no-op because we're 
so high level" pattern to ever appear in a performance critical situation?

The workaround for the latter would be to explicitly `if bool(x):` instead of 
`if x:` when the body is a no-op.  Or not make the body a no-op.  I expect 
unittest of __bool__() code owners would be fine with that so long as we call 
it out clearly in What's New docs, it's just that it could be an annoying 
change for them to make.

Ideally we'd also provide a lib2to3 fixer to detect and fixup code exhibiting 
that pattern.

The easiest answer is just not to optimize this out if it isn't actually 
providing us anything deemed important.

--

___
Python tracker 

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



[issue33066] raise an exception from multiple positions break the traceback frames

2021-01-12 Thread Irit Katriel


Irit Katriel  added the comment:

See this documentation of with_traceback() regarding an API to set the 
traceback on an exception object.
 https://docs.python.org/3/library/exceptions.html#BaseException.with_traceback

--
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



[issue42899] Is it legal to eliminate tests of a value, when that test has no effect on control flow?

2021-01-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

Hm, I hadn't realized the issue of bool(a) being evaluated once or twice.

The most important side effect that bool(a) can have is raising (as e.g. numpy 
arrays do), not producing random results. Another important side effect might 
be loading some value into a cache.

So I think dropping an *extra* call is fine, while dropping the *only* call is 
not.

--

___
Python tracker 

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



[issue41620] Python Unittest does not return results object when the test is skipped

2021-01-12 Thread Irit Katriel


Irit Katriel  added the comment:

The justification on the PR is: 

"The problem is that when I'm trying to collect test results if one of the 
tests is being skipped the error below pops up because test_result object is 
None.
AttributeError: 'NoneType' object has no attribute 'testsRun'"

which can be worked around with a simple "is not None" check. 

There will be cases where someone wants to know that a test was not executed, 
and inspecting a TestResult object to see that it actually represents Nothing 
is not as natural.

I'm -1 on this change.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue42874] running configure on Solaris 10 gives grep "illegal option" errors

2021-01-12 Thread miss-islington


miss-islington  added the comment:


New changeset 0f66498fd8ee8644be6df963b86a1523f6069ddd by Paul Ganssle in 
branch 'master':
bpo-42874: Remove grep -qE options for Solaris 10 compatibility (GH-24200)
https://github.com/python/cpython/commit/0f66498fd8ee8644be6df963b86a1523f6069ddd


--
nosy: +miss-islington

___
Python tracker 

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



[issue42906] python3 -m doctest test.py tests the stdlib "time" module instead

2021-01-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

Sorry, this is not a bug. The builtin time module takes precedence in this case 
because the current directory is not put at the front of the module search path 
(sys.path).

As a workaround you could exportPYTHONPATH=.

--
nosy: +gvanrossum
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



[issue42906] python3 -m doctest test.py tests the stdlib "time" module instead

2021-01-12 Thread Guido van Rossum


Guido van Rossum  added the comment:

Whoops, I meant

export PYTHONPATH=.

--

___
Python tracker 

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



[issue15373] copy.copy() does not properly copy os.environment

2021-01-12 Thread Irit Katriel


Change by Irit Katriel :


--
components: +Library (Lib)
versions: +Python 3.10 -Python 3.7

___
Python tracker 

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



[issue42911] Addition chains for pow saves 10 % time!

2021-01-12 Thread Jurjen N.E. Bos


Jurjen N.E. Bos  added the comment:

Some more information for the interested:
The algorithm I made tries to smoothly change the"chunk size" with growing 
length of the exponent. So the exponents that win the most (up to 14% fewer 
multiplication) are the long exponents that are just shorter than the 
FIVEARY_CUTOFF.
But, I worked hard to make an algorithm that also saves multiplications for 
shorter numbers. Numbers of up to about 20 bits will be using the optimal chunk 
size.
And, of course, the decision must be made quickly because for some frequently 
occurring parameters (e.g., 3**25), the routine doesn't take that long anyway.
This is obtained by checking two properties of the exponent that strongly 
influence the addition chain: the higher four bits, and (surprise!) the number 
of pairs of bits with distance 2: in other words, (n&n>>2).bit_count().
After days of trying out all kinds of heuristics, and days of crunching,I 
measured the optimal parameters. I added the code I used to do that.
Guido may remember that I wrote a chapter in my Ph.D. on the subject of 
addition chains. The interesting thing is that I then used Python for that too: 
that was almost 30 years ago!
When implementing, I discovered that lots of the code around it had been in 
flux, so I didn't manage to "cherry pick" it into 3.10 yet. (One example: the 
bit_length and bit_count routines were renamed and moved around). And, I don't 
have windows 10:-(
But anyway, have a look and let me hear what you think of it. I'll also want to 
test and measure it a bit more, but I am sure it is quite stable.

--
Added file: https://bugs.python.org/file49738/longobject.py

___
Python tracker 

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



[issue42911] Addition chains for pow saves 10 % time!

2021-01-12 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue42862] Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module

2021-01-12 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> I do not like using _functools._lru_cache_wrapper. It is a deep 
> implementation detail, private function of private module. Use 
> functools.lru_cache.

All right, thanks.

--

___
Python tracker 

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



[issue42912] enum.Flag ~ bitwise negation is very slow

2021-01-12 Thread Kevin Chen


Change by Kevin Chen :


--
nosy: aspin2
priority: normal
severity: normal
status: open
title: enum.Flag ~ bitwise negation is very slow
versions: Python 3.8

___
Python tracker 

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



[issue42912] enum.Flag ~ bitwise negation is very slow

2021-01-12 Thread Kevin Chen


New submission from Kevin Chen :

Ignore this, opened issue by accident

--
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



[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2021-01-12 Thread Petr Viktorin


Petr Viktorin  added the comment:

In GH-23598, PyModule_AddObjectRef was added as EXPORT_DATA. Shouldn't it be 
EXPORT_FUNC?

--

___
Python tracker 

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



[issue42913] asyncio.ProactorEventLoop mishandles signal wakeup file descriptor

2021-01-12 Thread Michel Hidalgo


New submission from Michel Hidalgo :

asyncio.ProactorEventLoop uses a socket.socketpair and signal.set_wakeup_fd to 
wake up a loop that's polling I/O. However it does so with no consideration for 
file descriptors previously set (i.e. no signal number forwarding). Either by 
user code or by another instance of asyncio.ProactorEventLoop.

The following snippet is enough for the above to cause the loop to hang forever:

import asyncio
import gc

asyncio.set_event_loop(asyncio.ProactorEventLoop())
asyncio.set_event_loop(asyncio.ProactorEventLoop())
gc.collect()
asyncio.get_event_loop().run_forever()


The first asyncio.ProactorEventLoop instance sets a signal wakeup file 
descriptor on construction (see 
https://github.com/python/cpython/blob/187f76def8a5bd0af7ab512575cad30cfe624b05/Lib/asyncio/proactor_events.py#L632).
 The second instances does the same, dropping the file descriptor set by the 
first one (not good, not necessarily bad). When the garbage collector purges 
the first instance, signal wakeups are disabled completely (see 
https://github.com/python/cpython/blob/187f76def8a5bd0af7ab512575cad30cfe624b05/Lib/asyncio/proactor_events.py#L679).
 The loop cannot be interrupted with Ctrl+C anymore (bad).

--
components: Windows, asyncio
messages: 384979
nosy: asvetlov, hidmic, paul.moore, steve.dower, tim.golden, yselivanov, 
zach.ware
priority: normal
severity: normal
status: open
title: asyncio.ProactorEventLoop mishandles signal wakeup file descriptor
type: behavior
versions: Python 3.8

___
Python tracker 

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



[issue42848] asyncio produces an unexpected traceback with recursive __getattribute__

2021-01-12 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 6dfd1734f5b230bb8fbd2a9df806c1333b6652a8 by Irit Katriel in 
branch 'master':
bpo-42848: remove recursion from TracebackException (GH-24158)
https://github.com/python/cpython/commit/6dfd1734f5b230bb8fbd2a9df806c1333b6652a8


--

___
Python tracker 

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



  1   2   >