[issue44692] Const folding in parser with negative numbers doesn't match float/int behaviour

2021-07-20 Thread anthony shaw


anthony shaw  added the comment:

Thanks! I didn't realise it applied the negative operator instead of loading 
the constant value.

--

___
Python tracker 

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



[issue44692] Const folding in parser with negative numbers doesn't match float/int behaviour

2021-07-20 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Not a bug, this is due to operator precedence.

It is documented under the power operator:

https://docs.python.org/3/reference/expressions.html#the-power-operator

and in the operator precedence table:

https://docs.python.org/3/reference/expressions.html#operator-precedence

If you want to raise a negative literal to a power, you need parentheses:

(-2)**2

--
nosy: +steven.daprano
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



[issue44692] Const folding in parser with negative numbers doesn't match float/int behaviour

2021-07-20 Thread Tim Peters


Tim Peters  added the comment:

The binary power operator (`**`) has higher precedence than the unary negation 
operator (`-`).

That is, -x**y groups as -(x**y).

Not a bug - that's how it was designed and how it's documented.

Note that this isn't novel, either. For example, to give just one example of 
many, that's how Maxima does it too:

(%i1) -2**3;
(%o1) -8

--
nosy: +tim.peters

___
Python tracker 

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



[issue44692] Const folding in parser with negative numbers doesn't match float/int behaviour

2021-07-20 Thread anthony shaw


Change by anthony shaw :


--
title: Const unfolding in parser with negative numbers doesn't match float/int 
behaviour -> Const folding in parser with negative numbers doesn't match 
float/int behaviour

___
Python tracker 

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



[issue44692] Const unfolding in parser with negative numbers doesn't match float/int behaviour

2021-07-20 Thread anthony shaw


New submission from anthony shaw :

Powers with negative bases do not observe the same rules that 
float_pow/long_pow do when it comes to returning negative results/

Example:

> -2 ** 2
-4

>>> x = -2
>>> y = 2
>>> x ** y
4

>>> -2. ** 2.
-4.0
>>> x = -2.
>>> y = 2.
>>> x ** y
4.0

Tested on 3.8, 3.9 and 3.10, they all have the same bug.

--
components: Parser
messages: 397922
nosy: anthonypjshaw, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: Const unfolding in parser with negative numbers doesn't match float/int 
behaviour
type: behavior
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



[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-20 Thread Ziyue Jiang


Ziyue Jiang  added the comment:

Thanks for replying.
I did fix my code by adding Py_TPFLAGS_DEFAULT. It's okay. I just think the 
behavior is a little strange when I don't set the default flag, thus adding 
this issue.

--

___
Python tracker 

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



[issue44611] CPython uses deprecated randomness API

2021-07-20 Thread Dong-hee Na


Dong-hee Na  added the comment:

@tim.peters

Can you please take a look at GH-27168?
I would like to get your review before merging this PR :)

--

___
Python tracker 

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



[issue44691] bug in interactions between argparse and random

2021-07-20 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

args.seed if args.seed else SEED is not doing what you think it is doing.

SEED is an *int* but args.seed is a *str*:

>>> random.seed(6385845682483836956)
>>> random.randint(10, 500)
92
>>> random.seed('6385845682483836956')
>>> random.randint(10, 500)
347

--
nosy: +steven.daprano
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



[issue44691] bug in interactions between argparse and random

2021-07-20 Thread pierpaolo paolucci


New submission from pierpaolo paolucci :

Python 3.9.6 (default, Jun 28 2021, 11:30:47) 
[GCC 10.3.0] on linux

I tried to run the first time a prg and successively reproduce eventals error

see the attachment

--
components: Library (Lib)
files: testRandom.py
messages: 397918
nosy: peeble111
priority: normal
severity: normal
status: open
title: bug in interactions between argparse and random
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50168/testRandom.py

___
Python tracker 

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



[issue42064] Convert sqlite3 to multi-phase initialisation (PEP 489)

2021-07-20 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests: +25818
pull_request: https://github.com/python/cpython/pull/27273

___
Python tracker 

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



[issue44690] Adopt binacii.a2b_base64's strict mode in base64.b64decode

2021-07-20 Thread Idan Moral


Change by Idan Moral :


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

___
Python tracker 

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



[issue44689] MacOS: Python binaries not portable between Catalina and Big Sur

2021-07-20 Thread Zachary Ware


Change by Zachary Ware :


--
components: +macOS
nosy: +ned.deily, ronaldoussoren

___
Python tracker 

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



[issue44690] Adopt binacii.a2b_base64's strict mode in base64.b64decode

2021-07-20 Thread Idan Moral


New submission from Idan Moral :

This is a follow-up PR to GH-24402.

Currently, *base64.b64decode* uses a generic regex to validate *s* (when 
*validate* is true),
which sometimes results in unexpected behavior and exception messages.

Example:

(1)base64.b64decode('ab==',  validate=True) # b'i'
(2)base64.b64decode('ab3==', validate=True) # b'i\xbd'
(3)base64.b64decode('ab=3=', validate=True) # raises binascii.Error: 
Non-base64 digit found
(4)base64.b64decode('ab==3', validate=True) # raises binascii.Error: 
Non-base64 digit found
(5)base64.b64decode('ab===', validate=True) # raises binascii.Error: 
Non-base64 digit found
(6)base64.b64decode('=ab==', validate=True) # raises binascii.Error: 
Non-base64 digit found

The only strict-base64 valid example here is (1).
(2), (4) and (5) should raise 'Excess data after padding',
(3) should raise 'Discontinuous padding not allowed',
and (6) should raise 'Leading padding not allowed'.

To get this behavior, we can use the new (at the time of creating this PR) 
*binascii.a2b_base64* functionality of strict mode.

I have one (not so big) concern - efficiency.
I'm not that experienced with how fast regex-es are (in Python or in general) 
compared to the implementation of *binascii.a2b_base64* in C.
So, I've no idea what would be the impact of migrating from regex 
pre-validation to input parsing.
Let me know if you find it inefficient.

-

Referenced issue (GH-24402): https://bugs.python.org/issue43086

--
components: Library (Lib)
messages: 397917
nosy: idan22moral
priority: normal
severity: normal
status: open
title: Adopt binacii.a2b_base64's strict mode in base64.b64decode
type: behavior
versions: Python 3.11

___
Python tracker 

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



[issue44689] MacOS: Python binaries not portable between Catalina and Big Sur

2021-07-20 Thread Tobias Bergkvist


New submission from Tobias Bergkvist :

Python-binaries compiled on either Big Sur or Catalina - and moved to the other 
MacOS-version will not work as expected when code depends on 
ctypes.util.find_library.

Example symptom of this issue: 
https://github.com/jupyterlab/jupyterlab/issues/9863
I have personally faced this when using Python from nixpkgs - since nixpkgs 
Python has been built on Catalina - and I'm using Big Sur.


Scenario 1: Compile on Catalina, copy binaries to BigSur, and call 
ctypes.util.find_library('c')
Python 3.11.0a0 (heads/main:635bfe8162, Jul 19 2021, 08:09:05) [Clang 12.0.0 
(clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes.util import find_library; print(find_library('c'))
None

Scenario 2: Compile on Big Sur, copy binaries to Catalina, and call 
ctypes.util.find_library('c'):
Python 3.11.0a0 (heads/main:635bfe8162, Jul 19 2021, 08:28:48) [Clang 12.0.5 
(clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes.util import find_library; print(find_library('c'))
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.11/ctypes/__init__.py", line 8, in 
from _ctypes import Union, Structure, Array
^^^
ImportError: 
dlopen(/usr/local/lib/python3.11/lib-dynload/_ctypes.cpython-311-darwin.so, 2): 
Symbol not found: __dyld_shared_cache_contains_path
  Referenced from: 
/usr/local/lib/python3.11/lib-dynload/_ctypes.cpython-311-darwin.so (which was 
built for Mac OS X 11.4)
  Expected in: /usr/lib/libSystem.B.dylib
 in /usr/local/lib/python3.11/lib-dynload/_ctypes.cpython-311-darwin.so

--
components: ctypes
messages: 397916
nosy: bergkvist
priority: normal
pull_requests: 25816
severity: normal
status: open
title: MacOS: Python binaries not portable between Catalina and Big Sur
type: behavior
versions: Python 3.10, Python 3.11, 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



[issue43950] Include column offsets for bytecode instructions

2021-07-20 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Even if this doesn't cover all cases it seems that everyone else is going with 
this solution for what I can see, and currently this looks suboptimal on python 
because we get this wrong on the vast majority of cases so my suggestion is to 
try to fix this the same way rust on others are doing it even if there is some 
subset of cases where it won't fully work

--

___
Python tracker 

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



[issue43950] Include column offsets for bytecode instructions

2021-07-20 Thread Ammar Askar


Ammar Askar  added the comment:

Indeed, and the unicode_width package seems to implement the wcwidth algorithm:

* https://github.com/unicode-rs/unicode-width/blob/master/src/tables.rs#L39-L48
* https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c

https://bugs.python.org/issue12568 is an issue from the past that proposed 
adding wcwidth to the standard library.

--

___
Python tracker 

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



[issue42414] unable to document fields of dataclass

2021-07-20 Thread Eric V. Smith


Eric V. Smith  added the comment:

I think we'd be better off adding a doc parameter to dataclasses.field, and 
then as @terry.reedy says, modify inspect.getdoc and maybe_finddoc to look in 
__dataclass_fields__, if it exists.

--
versions: +Python 3.11 -Python 3.10

___
Python tracker 

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



[issue44688] [sqlite3] Remove ASCII limitation from sqlite3.Connection.create_collation()

2021-07-20 Thread Erlend E. Aasland


New submission from Erlend E. Aasland :

The sqlite3.Connection.create_collation() function limits collation names to 
ASCII characters only. As sqlite3_create_collation_v2() (and 
sqlite3_create_collation()) support UTF8, there is no need for this limitation 
anymore.

See https://github.com/python/cpython/pull/27156#issuecomment-883694653

--
assignee: erlendaasland
components: Extension Modules
messages: 397912
nosy: erlendaasland, petr.viktorin
priority: normal
severity: normal
status: open
title: [sqlite3] Remove ASCII limitation from 
sqlite3.Connection.create_collation()
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue43950] Include column offsets for bytecode instructions

2021-07-20 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

They seem to be checking the unicode width as we are proposing here. Check the 
calls to unicode_width::UnicodeWidthChar::width:

https://github.com/rust-lang/rust/blob/master/compiler/rustc_errors/src/emitter.rs#L729-L733

--

___
Python tracker 

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



[issue43950] Include column offsets for bytecode instructions

2021-07-20 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

In bpo this looks bad, but test this small program yourself and check the error 
in your terminal:


fn test(number: String) -> () {
println!("Hello, world: {}", number);
}

fn main() {
test("hellooo: 拾     some emojis");
}

--

___
Python tracker 

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



[issue43950] Include column offsets for bytecode instructions

2021-07-20 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

I don't know, seems that rust can deal with this just fine:

❯ cargo run
   Compiling rtest v0.1.0 (/home/pablogsal/rtest)
error[E0308]: mismatched types
 --> src/main.rs:7:10
  |
7 | test("hellooo: 拾     some emojis");
  |  ^
  |  |
  |  expected struct `String`, found ``
  |  help: try using a conversion method: `"hellooo: 拾     some 
emojis".to_string()`

--

___
Python tracker 

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



[issue42854] OpenSSL 1.1.1: use SSL_write_ex() and SSL_read_ex()

2021-07-20 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +25815
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/27271

___
Python tracker 

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



[issue42414] unable to document fields of dataclass

2021-07-20 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

John-Mark: yep, it's just a draft patch for now.

It doesn't need to be two lines; it can be updated to start with an empty dict 
and perhaps use a shorter special name for the doc dict and then you can do:

f1:int = 1
FDOC['f1'] = 'foo'

f2:str = 'a'
FDOC['f2'] = 'bar'

... the nice thing is that you have the flexibility to either group all docs 
into one place or set them after each field, I can imagine many users will 
prefer the former.

--

___
Python tracker 

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



[issue44687] io.BufferedReader:peek() closes underlying file, breaking peek/read expectations

2021-07-20 Thread liquidpele


New submission from liquidpele :

reecepeg@3c22fb7d6b37 Pulpmill % python3 --version
Python 3.9.1


When buffering a small file, calling peek() can read in the entire underlying 
thing and close it, so then following with a read() throws an error about the 
file being closed already even though peek should not have that effect. 

Reproducible Steps:

>>> r = BufferedReader(requests.get("https://google.com;, stream=True).raw)
>>> r.peek(2)[:2]
b'\x1f\x8b'
>>> r.peek()
Traceback (most recent call last):
  File "", line 1, in 
ValueError: peek of closed file
>>> r.read()
Traceback (most recent call last):
  File "", line 1, in 
ValueError: read of closed file


However, in the case of a larger stream it appears to work since the underlying 
stream isn't closed yet:

>>> r = BufferedReader(requests.get("https://amazon.com;, stream=True).raw)
>>> r.peek(2)[:2]
b'\x1f\x8b'
>>> r.peek(2)[:2]
b'\x1f\x8b'


This seems inconsistent at best. Best I can tell, the issue is here and needs 
to take the current buffer offset into account. 
https://github.com/python/cpython/blob/main/Modules/_io/bufferedio.c#L845

--
components: IO
messages: 397907
nosy: liquidpele
priority: normal
severity: normal
status: open
title: io.BufferedReader:peek() closes underlying file, breaking peek/read 
expectations
versions: Python 3.9

___
Python tracker 

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



[issue42854] OpenSSL 1.1.1: use SSL_write_ex() and SSL_read_ex()

2021-07-20 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I will push a fix today

--

___
Python tracker 

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



[issue42854] OpenSSL 1.1.1: use SSL_write_ex() and SSL_read_ex()

2021-07-20 Thread Ned Deily


Change by Ned Deily :


--
nosy: +pablogsal
stage: resolved -> needs patch

___
Python tracker 

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



[issue44686] use pkgutil.resolve_name in unittest.mock

2021-07-20 Thread Thomas Grainger


New submission from Thomas Grainger :

per https://bugs.python.org/issue12915 pkgutil.resolve_name was added for use 
in mock and other stdlib modules:

> pydoc has locate and resolve, packaging has util.resolve_name, unittest has 
> something else, etc.

--
messages: 397905
nosy: graingert
priority: normal
pull_requests: 25814
severity: normal
status: open
title: use pkgutil.resolve_name in unittest.mock
versions: Python 3.11

___
Python tracker 

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



[issue44566] StopIteration subclass suppressed by contextlib.contextmanager

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks! ✨  ✨

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



[issue44566] StopIteration subclass suppressed by contextlib.contextmanager

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 1c5c9c89ffc36875afaf4c3cc6a716d4bd089bbf by Łukasz Langa in 
branch '3.9':
[3.9] bpo-44566: resolve differences between asynccontextmanager and 
contextmanager (GH-27024). (#27269)
https://github.com/python/cpython/commit/1c5c9c89ffc36875afaf4c3cc6a716d4bd089bbf


--

___
Python tracker 

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



[issue44566] StopIteration subclass suppressed by contextlib.contextmanager

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 68b4690b010d0006e9b0235903afd367191f3c51 by Miss Islington (bot) 
in branch '3.10':
bpo-44566: resolve differences between asynccontextmanager and contextmanager 
(GH-27024) (#27266)
https://github.com/python/cpython/commit/68b4690b010d0006e9b0235903afd367191f3c51


--

___
Python tracker 

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



[issue43219] shutil.copy raises IsADirectoryError when the directory does not actually exist

2021-07-20 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Thanks for reporting Jakub, and for patching Gregory!

--

___
Python tracker 

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



[issue44539] Support recognizing JPEG files without JFIF or Exif markers

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:

Thanks, Mohamad! ✨  ✨

--

___
Python tracker 

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



[issue44539] Support recognizing JPEG files without JFIF or Exif markers

2021-07-20 Thread Łukasz Langa

Change by Łukasz Langa :


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



[issue44539] Support recognizing JPEG files without JFIF or Exif markers

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 3b56b3b97d91e2b412ce1b2bcaddcd43ef3d223b by Mohamad Mansour in 
branch 'main':
bpo-44539: Support recognizing JPEG files without JFIF or Exif markers 
(GH-26964)
https://github.com/python/cpython/commit/3b56b3b97d91e2b412ce1b2bcaddcd43ef3d223b


--

___
Python tracker 

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



[issue43219] shutil.copy raises IsADirectoryError when the directory does not actually exist

2021-07-20 Thread miss-islington


miss-islington  added the comment:


New changeset 574da4633b44b4048f74c93da496ed2a3ead99dd by Miss Islington (bot) 
in branch '3.10':
[3.10] bpo-43219: skip Solaris in the test as well (GH-27257) (GH-27268)
https://github.com/python/cpython/commit/574da4633b44b4048f74c93da496ed2a3ead99dd


--

___
Python tracker 

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



[issue43219] shutil.copy raises IsADirectoryError when the directory does not actually exist

2021-07-20 Thread miss-islington


miss-islington  added the comment:


New changeset dae4928dd07109db69e090b1c8193a023ce695cd by Miss Islington (bot) 
in branch '3.9':
[3.9] bpo-43219: skip Solaris in the test as well (GH-27257) (GH-27267)
https://github.com/python/cpython/commit/dae4928dd07109db69e090b1c8193a023ce695cd


--

___
Python tracker 

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



[issue42414] unable to document fields of dataclass

2021-07-20 Thread John-Mark Gurney


John-Mark Gurney  added the comment:

So, just looked at the patch, but it's missing the documentation part of it.

Also, yes, you can add the doc as another line, but now that's two lines (yes, 
you can add semicolons to make it one line, but that might surprise some 
people).

I do request that any examples USE this approach (multiline) and not the  
example that was provided here which will lead the issues.

Note: These are only suggestions, and as with all free software, you're free to 
take them or leave them.

--

___
Python tracker 

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



[issue44566] StopIteration subclass suppressed by contextlib.contextmanager

2021-07-20 Thread Łukasz Langa

Change by Łukasz Langa :


--
pull_requests: +25813
pull_request: https://github.com/python/cpython/pull/27269

___
Python tracker 

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



[issue42414] unable to document fields of dataclass

2021-07-20 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

John-Mark: each fields doc can be added to the dictionary separately
though..

--

___
Python tracker 

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



[issue42414] unable to document fields of dataclass

2021-07-20 Thread John-Mark Gurney


John-Mark Gurney  added the comment:

Though this suggestion does work, I am not a fan of this solution.

The issue is that it separates the doc from the definition.  This works well if 
you have only a field fields in the class, But if you get 10-20+ fields, it 
moves away the docs and makes it easier for people to forget to add 
documentation to the field when they add additional fields, where w/ my 
suggestion, it's less likely that it will be forgotten.

Note: I would look at making a patch, but as I don't plan on signing the 
contributor's agreement, any patch I make will not be usable.

--

___
Python tracker 

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



[issue43219] shutil.copy raises IsADirectoryError when the directory does not actually exist

2021-07-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25812
pull_request: https://github.com/python/cpython/pull/27268

___
Python tracker 

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



[issue43219] shutil.copy raises IsADirectoryError when the directory does not actually exist

2021-07-20 Thread Gregory P. Smith

Gregory P. Smith  added the comment:


New changeset 6564656495d456a1bcc1aaa06abfc696209f37b2 by Jakub Kulík in branch 
'main':
bpo-43219: skip Solaris in the test as well (GH-27257)
https://github.com/python/cpython/commit/6564656495d456a1bcc1aaa06abfc696209f37b2


--

___
Python tracker 

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



[issue43219] shutil.copy raises IsADirectoryError when the directory does not actually exist

2021-07-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25811
pull_request: https://github.com/python/cpython/pull/27267

___
Python tracker 

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



[issue44566] StopIteration subclass suppressed by contextlib.contextmanager

2021-07-20 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +25810
pull_request: https://github.com/python/cpython/pull/27266

___
Python tracker 

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



[issue44566] StopIteration subclass suppressed by contextlib.contextmanager

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 7f1c330da31c54e028dceaf3610877914c2a4497 by Thomas Grainger in 
branch 'main':
bpo-44566: resolve differences between asynccontextmanager and contextmanager 
(#27024)
https://github.com/python/cpython/commit/7f1c330da31c54e028dceaf3610877914c2a4497


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue44539] Support recognizing JPEG files without JFIF or Exif markers

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:

When JFIF and Exif markers are removed, what we're left with is a "raw" JPEG 
file.

I added a raw equivalent of Lib/test/imghdrdata/python.jpg by running:

$ exiftool -all= python.jpg -o python-raw.jpg

Mohamad's patch correctly adds support for such files. In fact, browsing 
through how other languages do this, it seems like the FF D8 FF DB sequence is 
a relatively popular "magic sequence". It's even listed in this Wikipedia page:

https://en.wikipedia.org/wiki/List_of_file_signatures

--
nosy: +lukasz.langa
title: Imghdr JPG Quantized -> Support recognizing JPEG files without JFIF or 
Exif markers

___
Python tracker 

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



[issue44683] Can't subscript objects with the string "1" using str.format()

2021-07-20 Thread Eric V. Smith


Eric V. Smith  added the comment:

Yes, this is a "feature" of str.format. If it looks like a number, it's 
converted to a number, else it's used as a string. It's generally the most 
useful way to interpret subscripts, but as you note it doesn't handle all cases.

--
nosy: +eric.smith
resolution:  -> wont fix
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



[issue42414] unable to document fields of dataclass

2021-07-20 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I've put up a simple PoC PR adding a __field_doc__ optional dict attr to 
dataclass, which would add the docs to class docstring:

@dataclass
class A:
__field_doc__ = dict(num='number of widgets', total='total widgets')
total: int
num: int = 5
print(A.__doc__)

OUTPUT
---

A(total: int, num: int = 5)

num: int [5] -- number of widgets

total: int  -- total widgets

--

___
Python tracker 

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



[issue42414] unable to document fields of dataclass

2021-07-20 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
keywords: +patch
nosy: +andrei.avk
nosy_count: 4.0 -> 5.0
pull_requests: +25809
stage: test needed -> patch review
pull_request: https://github.com/python/cpython/pull/27265

___
Python tracker 

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



[issue44631] Refactoring the repr() of the _Environ class (os module)

2021-07-20 Thread Łukasz Langa

Change by Łukasz Langa :


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



[issue44631] Refactoring the repr() of the _Environ class (os module)

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 85fa3b6b7c11897732fedc443db0e4e8e380c8f8 by Leonardo Freua in 
branch 'main':
bpo-44631: Make the repr() of the _Environ class more readable. (#27128)
https://github.com/python/cpython/commit/85fa3b6b7c11897732fedc443db0e4e8e380c8f8


--

___
Python tracker 

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



[issue44684] Docs for mock.call

2021-07-20 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

> A call object is either a tuple of (positional args, keyword args) or (name, 
> positional args, keyword args) depending on how it was constructed

https://github.com/python/cpython/pull/11807 added support for args and kwargs 
from python 3.9. So I guess you want to do call_object.kwargs["foo"] == "bar"

--
nosy: +xtreak

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 9ae5ba7dbf08d56a1b30d67fcde75532fe136d77 by Miss Islington (bot) 
in branch '3.10':
bpo-44353: Add test to cover __or__ of two NewType (GH-27259) (#27261)
https://github.com/python/cpython/commit/9ae5ba7dbf08d56a1b30d67fcde75532fe136d77


--

___
Python tracker 

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



[issue44683] Can't subscript objects with the string "1" using str.format()

2021-07-20 Thread Dennis Sweeney


Change by Dennis Sweeney :


--
title: String formatting -> Can't subscript objects with the string "1" using 
str.format()

___
Python tracker 

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



[issue44685] Email package issue with Outlook msg files

2021-07-20 Thread Heghine


New submission from Heghine :

The email package has an issue with extracting the attachments from the email 
if the email is sent with the Outlook application with .msg files.

When I'm sending an email from the Outlook app by attaching .msg files to the 
email, the recipient receives the email but instead of .msg files, the email 
contains .eml files. So Outlook auto transforms the attached .msg to .eml.
When I'm trying to read and extract attachments with the email package by using 
the Message class "get_payload" method, the extracted data for the mentioned 
attachment doesn't contain necessary information like "content-disposition" or 
"filename", so working with that attachment is impossible.

For all other .eml files everything works fine. The issue exists only in the 
case of transformed .eml files. However, that .eml looks like any other eml 
file in the received mail.

--
components: email
files: msg file.msg
messages: 397885
nosy: barry, heghine, r.david.murray
priority: normal
severity: normal
status: open
title: Email package issue with Outlook msg files
versions: Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file50167/msg file.msg

___
Python tracker 

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



[issue38091] Import deadlock detection causes deadlock

2021-07-20 Thread Victor Zhestkov


Victor Zhestkov  added the comment:

I ported the fix from 
https://github.com/python/cpython/commit/6daa37fd42c5d5300172728e8b4de74fe0b319fc
 for 3.6 and 3.8 shipped with SLE 15SP2 and openSUSE Tumbleweed, but it seems 
that this fix doesn't help.
I have a deadlocks on running `salt-api` process managing `salt-ssh` systems 
with high workload. The service can get the deadlock in first 5 minutes or 
after 3-60 minutes of running the service with the same workload with almost 
equal chances.

Here is the part of py-bt I see each time:

(gdb) py-bt
Traceback (most recent call first):
  File "", line 107, in acquire
  File "", line 158, in __enter__
  File "", line 595, in _exec
  File "", line 271, in _load_module_shim
  File "", line 852, in load_module
  File "", line 1027, in load_module
  File "", line 1034, in 
_check_name_wrapper
  File "/usr/lib/python3.8/site-packages/salt/loader.py", line 4779, in 
_load_module
  File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1926, in 
_inner_load
if self._load_module(name) and key in self._dict:
  File "/usr/lib/python3.8/site-packages/salt/loader.py", line 2193, in _load
  File "/usr/lib/python3.8/site-packages/salt/utils/lazy.py", line 99, in 
__getitem__
if self._load(key):
  File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1283, in 
__getitem__
func = super().__getitem__(item)
  File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1139, in 
__getitem__
return self._dict[key + self.suffix]
  File "/usr/lib/python3.8/site-packages/salt/template.py", line 495, in 
check_render_pipe_str
  File "/usr/lib/python3.8/site-packages/salt/loader.py", line 1428, in render
f_noext,
  File "/usr/lib/python3.8/site-packages/salt/pillar/__init__.py", line 781, in 
__init__
...

--
nosy: +vzhestkov

___
Python tracker 

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



[issue44683] String formatting

2021-07-20 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

If I understand correctly, this shows the behavior you're objecting to:

>>> class A:
... def __getitem__(self, key):
... print(f"{key = }")
... return "apple"
... 
... 
>>> '{0[1]}'.format(A()) # passes an integer
key = 1
'apple'
>>> '{0[apple]}'.format(A()) # passes a string
key = 'apple'
'apple'
>>> '{0["1"]}'.format(A()) # passes the length-3 string including double-quotes
key = '"1"'
'apple'

There's no clear way to use str.format() to get the value for the string key 
"1". However, I don't think it makes sense to backwards-incompatibly change the 
behavior to pass the string "1" instead of the integer 1, since a common use is 
indexing with integers like

>>> "{0[0]}{0[2]}{0[4]}".format(("a", "b", "c, "d", "e"))
'ace'

This is an edge case, but it is aligned with the specification: according to 
https://docs.python.org/3/library/string.html#format-string-syntax,

"""Because arg_name is not quote-delimited, it is not possible to specify 
arbitrary dictionary keys (e.g., the strings '10' or ':-]') within a format 
string."""

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-20 Thread Petr Viktorin


Change by Petr Viktorin :


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

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
pull_requests: +25807
pull_request: https://github.com/python/cpython/pull/27262

___
Python tracker 

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



[issue43950] Include column offsets for bytecode instructions

2021-07-20 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset fbc349ff790c21f1a59af939d42033470790c530 by Batuhan Taskaya in 
branch 'main':
bpo-43950: Distinguish errors happening on character offset decoding (GH-27217)
https://github.com/python/cpython/commit/fbc349ff790c21f1a59af939d42033470790c530


--

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +25806
pull_request: https://github.com/python/cpython/pull/27261

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset c2f33dfc83ab270412bf243fb21f724037effa1a by Miss Islington (bot) 
in branch '3.10':
bpo-44353: Refactor typing.NewType into callable class (GH-27250) (#27258)
https://github.com/python/cpython/commit/c2f33dfc83ab270412bf243fb21f724037effa1a


--

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Yurii Karabas


Yurii Karabas <1998uri...@gmail.com> added the comment:

Jelle thanks for pointing this out, I will implement helper function in C and 
use it as a __call__ method for NewType

--

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Jelle Zijlstra

Jelle Zijlstra  added the comment:

I found that replacing __call__ on the NewType class with an identity function 
written in C makes things faster instead:

In [54]: %timeit ntc2(1)
79 ns ± 0.37 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [55]: %timeit ntc(1)
126 ns ± 0.315 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)

In [56]: %timeit nt(1)
103 ns ± 4.23 ns per loop (mean ± std. dev. of 7 runs, 1000 loops each)

Here ntc2 has __call__ implemented in C, ntc is the previous class-based 
version and nt is the current function-based version.

So perhaps we could just stick a private `._idfunc` in some C-implemented 
module (functools? types?) and use it as the __call__ for our NewType class.

--

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Guido van Rossum


Guido van Rossum  added the comment:

OTOH, for 3.10 the clock is ticking. Let's go for it. (If it's deemed too slow, 
we could eventually add an accelerator just for this.)

--

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:

> Hm, 20% isn't so bad, but one of the arguments for NewType was that it 
> "disappears" at runtime -- which the current version does, but the 
> class-based version doesn't quite.

NewType was described originally in https://github.com/python/typing/issues/189 
and the resulting PEP text landed in 
https://github.com/python/typing/pull/226/files.

I find the 20% performance impact non-ideal but ultimately worth it because:
- it solves the issue described in this bug;
- it allows us to implement issubclass/isinstance in the future if we so choose;
- it also potentially allows us to chain NewType.

Since we can't fully rely on `from __future__ import annotations` to side-step 
the performance cost, we don't really have a different option than to change 
it. The alternative is to leave it as is which makes it a non-composable 
pseudo-type unlike the others.

Currently adoption of NewType is relatively low, in part due to the feature's 
obscurity and partially because of its limits. Slower instantiation performance 
will at worst keep the adoption low, but it can potentially bring more users to 
NewType since it becomes less hacky.

I'm +1 to converting to a class as done by the PR.


> Right now I don't have the cycles to think about this deeply. Maybe a few 
> weeks after I'm back from vacation (~August 8) I will have more time.

Sorry, I overeagerly already merged the change to `main`. Let's hold off with 
the 3.10 backport until you had time to think about it. If we decide against 
the change after all, reverting on `main` should have no negative impact since 
we're pre-alpha 1.

--

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 4868b94c6089d457673b1ba5b5b64c2f38c435af by Yurii Karabas in 
branch 'main':
bpo-44353: Add test to cover __or__ of two NewType (#27259)
https://github.com/python/cpython/commit/4868b94c6089d457673b1ba5b5b64c2f38c435af


--

___
Python tracker 

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



[issue44588] Possible double Py_XDECREF in cpython typeobject.c

2021-07-20 Thread Petr Viktorin


Petr Viktorin  added the comment:

Please use Py_TPFLAGS_DEFAULT when creating objects. Do you have a reason to 
not do it?


The flag Py_TPFLAGS_HAVE_VERSION_TAG is unneeded and Python should not check 
for it. There's bpo-42747 open for that already; I sent a PR for it.

--
nosy: +petr.viktorin

___
Python tracker 

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



[issue42747] Remove Py_TPFLAGS_HAVE_VERSION_TAG flag?

2021-07-20 Thread Petr Viktorin


Change by Petr Viktorin :


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

___
Python tracker 

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



[issue44684] Docs for mock.call

2021-07-20 Thread Thomas Guettler


New submission from Thomas Guettler :

The docs for `mock.call` could get improved:

https://docs.python.org/3/library/unittest.mock.html#call

Up to now it is not clear how to access individual members of the call.

Example: I want to check if the call used the kwarg "foo" with the value of 
"bar".

Usually you don't need this, since you check for the whole call (all args and 
all kwargs).

But sometimes you jus twant to check for a single arg/kwarg.

Then it would be nice to have more detailed docs for the class "call".

BTW: Why has this class a lower-case name? Looks a bit strange.

--
assignee: docs@python
components: Documentation
messages: 397874
nosy: docs@python, guettli
priority: normal
severity: normal
status: open
title: Docs for mock.call
versions: Python 3.9

___
Python tracker 

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



[issue42747] Remove Py_TPFLAGS_HAVE_VERSION_TAG flag?

2021-07-20 Thread Petr Viktorin


Petr Viktorin  added the comment:

The bit cannot be repurposed, since older extensions using the stable ABI might 
set it.
It doesn't make much sense to remove the Py_TPFLAGS_HAVE_VERSION_TAG or 
Py_TPFLAGS_HAVE_FINALIZE defines; I'd let them stay to document that the bits 
are reserved.

--

___
Python tracker 

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



[issue42085] Add dedicated slot for sending values

2021-07-20 Thread Petr Viktorin


Petr Viktorin  added the comment:

Py_TPFLAGS_HAVE_AM_SEND is unnecessary and I'd like to remove it.

It is not possible for type objects to have a different layout than the 
interpreter:
- extensions using the regular ABI must be recompiled for each feature version 
of Python
- extensions using the stable ABI can only create types dynamically

Or is there a different reason for Py_TPFLAGS_HAVE_AM_SEND? Checking it may be 
faster than ((Py_TYPE(x)->tp_as_async != NULL) && 
(Py_TYPE(x)->tp_as_async->am_send != NULL)), but I don't think the speedup is 
relevant.

See bpo-42747

--
nosy: +petr.viktorin

___
Python tracker 

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



[issue40263] ValueError exception on _winapi.WaitForMultipleObjects

2021-07-20 Thread Christian Fersch


Christian Fersch  added the comment:

This is still an issue in python3.9. It just hit us while using the default 
config on a Threadripper 3990X that has 128 logical cores:

  with concurrent.futures.ProcessPoolExecutor() as executor:

--
nosy: +Chronial
versions: +Python 3.9

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Yurii Karabas


Change by Yurii Karabas <1998uri...@gmail.com>:


--
pull_requests: +25804
pull_request: https://github.com/python/cpython/pull/27259

___
Python tracker 

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



[issue44663] Possible bug in datetime utc

2021-07-20 Thread Petr Viktorin


Change by Petr Viktorin :


--
components: +Library (Lib) -C API

___
Python tracker 

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



[issue43334] venv does not install libpython

2021-07-20 Thread Petr Viktorin


Petr Viktorin  added the comment:

A venv does *not* create a replica of a python installation directory. Files 
shared with the main Python installation are not copied nor linked. This goes 
for the standard library, as well as the libraries and headers.
(*Executables* are an exception; they're copied, since a venv needs them on the 
PATH.)

Copies would take up unnecessary space, and not all operating systems support 
symbolic links (and we don't want another platform-specific difference), so the 
shared files are only referenced using pyvenv.cfg


If you point to the macros you're using, I can take a look at how they could be 
improved.

--
nosy: +petr.viktorin
status: open -> closed

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 8.0 -> 9.0
pull_requests: +25803
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/27258

___
Python tracker 

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



[issue44353] PEP 604 NewType

2021-07-20 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 965dd76e9060e27e2253ba8c8d21a142b178720d by Yurii Karabas in 
branch 'main':
bpo-44353: Refactor typing.NewType into callable class (GH-27250)
https://github.com/python/cpython/commit/965dd76e9060e27e2253ba8c8d21a142b178720d


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue44683] String formatting

2021-07-20 Thread Mykyta


Change by Mykyta :


Removed file: https://bugs.python.org/file50166/1.png

___
Python tracker 

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



[issue43629] fix _PyRun_SimpleFileObject create __main__ module and cache. Call this function multiple times, the attributes stored in the module dict will affect eachother.

2021-07-20 Thread Petr Viktorin


Petr Viktorin  added the comment:

The public function that calls _PyRun_SimpleFileObject is 
PyRun_SimpleStringFlags, and the behavior is as specified in its documentation: 
"Executes the Python source code from command in the __main__ module according 
to the flags argument. If __main__ does not already exist, it is created."

https://docs.python.org/3.8/c-api/veryhigh.html?highlight=pyrun_simplefileexflags#c.PyRun_SimpleStringFlags

--
nosy: +petr.viktorin
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



[issue44683] String formatting

2021-07-20 Thread Mykyta


New submission from Mykyta :

The formatting does not work correctly.

I have a dict with string representations of integers as keys, such as {'1': 
'a'} and trying to format it this way: '{0[1]}' and KeyError occurs. But I 
think it should not as '{0[a]}'.format(a) works properly with a = {'a': '1'} 
and '{0[1]}'.format(a) works properly with a = {1: 'a'}. Adding quotation marks 
does not help, KeyError occurs with '"1"'.

--
components: Unicode
files: 1.png
messages: 397867
nosy: NickP, ezio.melotti, vstinner
priority: normal
severity: normal
status: open
title: String formatting
type: behavior
versions: Python 3.9
Added file: https://bugs.python.org/file50166/1.png

___
Python tracker 

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



[issue42064] Convert sqlite3 to multi-phase initialisation (PEP 489)

2021-07-20 Thread Petr Viktorin


Petr Viktorin  added the comment:


New changeset 4c0deb25ac899fbe4da626ce3cb21f204cdd3aa9 by Erlend Egeberg 
Aasland in branch 'main':
bpo-42064: Finalise establishing sqlite3 global state (GH-27155)
https://github.com/python/cpython/commit/4c0deb25ac899fbe4da626ce3cb21f204cdd3aa9


--

___
Python tracker 

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



[issue43219] shutil.copy raises IsADirectoryError when the directory does not actually exist

2021-07-20 Thread Jakub Kulik


Change by Jakub Kulik :


--
pull_requests: +25802
pull_request: https://github.com/python/cpython/pull/27257

___
Python tracker 

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



[issue43219] shutil.copy raises IsADirectoryError when the directory does not actually exist

2021-07-20 Thread Jakub Kulik


Jakub Kulik  added the comment:

On Solaris (I checked this on Oracle and SmartOS), the error is:

  NotADirectoryError: [Errno 20] Not a directory: 'not_a_dir/'

which I think belongs to the 'errors are not confusing' category with Windows 
and macOS.

--
nosy: +kulikjak

___
Python tracker 

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



[issue44621] Python 3.9 traces async for/else incorrectly

2021-07-20 Thread Łukasz Langa

Change by Łukasz Langa :


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



[issue44677] CSV sniffing falsely detects space as a delimiter

2021-07-20 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 1.0 -> 2.0
pull_requests: +25801
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/27256

___
Python tracker 

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



[issue44621] Python 3.9 traces async for/else incorrectly

2021-07-20 Thread Mark Shannon


Mark Shannon  added the comment:

Not quite trivial, but simple enough :)

--

___
Python tracker 

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



[issue44621] Python 3.9 traces async for/else incorrectly

2021-07-20 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue44681] time.sleep(0.001) not working properly

2021-07-20 Thread Eryk Sun


Eryk Sun  added the comment:

The implementation of time.sleep() uses WaitForSingleObjectEx() on the main 
thread. It waits for an event object that gets signaled by Ctrl+C. On other 
threads it simply calls Sleep(). 

Thread wait functions such as WaitForSingleObjectEx() and Sleep() are based on 
the system interrupt time. By default the clock interrupt runs at 64 cycles per 
second, i.e. the interrupt time is about 15.6 ms. The interrupt time can be 
programmatically lowered to about 0.5 ms, but this should only be changed 
temporarily for timing critical applications. Lowering the interrupt time for 
general use can shorten the battery life on portable devices, since servicing 
the interrupt prevents the CPU from entering a low-power state. 

Even with a lowered interrupt time, in my experience thread dispatching in 
Windows simply is not implemented to support precise timing. If the wait time 
needs to be precise, I suggest using a loop based on time.perf_counter_ns(). 
Calculate a deadline based on the current counter value plus the desired wait 
time in nanoseconds, and loop until the current value equals or exceeds the 
deadline. Maybe it would be useful to implement something like this in 
time.sleep() itself, but I don't know whether the need in a few cases warrants 
the increased complexity and cost in general.

--
nosy: +eryksun
resolution:  -> third party
type:  -> behavior

___
Python tracker 

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



[issue31426] [3.5] crash in gen_traverse(): gi_frame.ob_type=NULL, called by subtract_refs() during a GC collection

2021-07-20 Thread Matej Cepl


Change by Matej Cepl :


--
nosy: +mcepl
versions: +Python 3.6

___
Python tracker 

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



[issue44621] Python 3.9 traces async for/else incorrectly

2021-07-20 Thread Mark Shannon


Mark Shannon  added the comment:

We can fix this for 3.9. The fix to 3.10 was trivial and should port easily.

--

___
Python tracker 

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



[issue14739] Add PyArg_Parse format unit like O& but providing context

2021-07-20 Thread Irit Katriel


Irit Katriel  added the comment:

Now we have exception chaining, so Serhiy's pattern is even simpler to 
implement than with exception wrappers.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue44677] CSV sniffing falsely detects space as a delimiter

2021-07-20 Thread Piotr Tokarski


Piotr Tokarski  added the comment:

I think changing `(?P["\']).*?(?P=quote)` to 
`(?P["\'])[^\n]*?(?P=quote)` in all regexes does the trick, doesn't it?

--

___
Python tracker 

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



[issue44677] CSV sniffing falsely detects space as a delimiter

2021-07-20 Thread Piotr Tokarski


Piotr Tokarski  added the comment:

Test sample:

```
import csv
from io import StringIO


def csv_text():
return StringIO("a|b\nc| 'd\ne|' f")


with csv_text() as input_file:
print('The following text is going to be parsed:')
print(input_file.read())
print()


with csv_text() as input_file:
dialect_params = [
'delimiter',
'quotechar',
'escapechar',
'lineterminator',
'quoting',
'doublequote',
'skipinitialspace'
]
dialect = csv.Sniffer().sniff(input_file.read())
print('The following dialect has been detected:')
for dialect_param in dialect_params:
print(f'- {dialect_param}: {repr(getattr(dialect, dialect_param))}')
print()


with csv_text() as input_file:
print('Parsed csv text:')
for entry in csv.reader(input_file, dialect=dialect):
print(f'- {entry}')
print()
```

Actual output:

```
The following text is going to be parsed:
a|b
c| 'd
e|' f

The following dialect has been detected:
- delimiter: ' '
- quotechar: "'"
- escapechar: None
- lineterminator: '\r\n'
- quoting: 0
- doublequote: False
- skipinitialspace: False

Parsed csv text:
- ['a|b']
- ['c|', 'd\ne|', 'f']

```

Expected output:

```
The following text is going to be parsed:
a|b
c| 'd
e|' f

The following dialect has been detected:
- delimiter: '|'
- quotechar: '"'
- escapechar: None
- lineterminator: '\r\n'
- quoting: 0
- doublequote: False
- skipinitialspace: False

Parsed csv text:
- ['a', 'b']
- ['c', " 'd"]
- ['e', "' f"]

```

--

___
Python tracker 

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



[issue31426] [3.5] crash in gen_traverse(): gi_frame.ob_type=NULL, called by subtract_refs() during a GC collection

2021-07-20 Thread Victor Zhestkov


Change by Victor Zhestkov :


Added file: https://bugs.python.org/file50165/gbd-bt-brief.txt

___
Python tracker 

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



[issue31426] [3.5] crash in gen_traverse(): gi_frame.ob_type=NULL, called by subtract_refs() during a GC collection

2021-07-20 Thread Victor Zhestkov


Change by Victor Zhestkov :


Added file: https://bugs.python.org/file50164/py-bt.txt

___
Python tracker 

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



[issue31426] [3.5] crash in gen_traverse(): gi_frame.ob_type=NULL, called by subtract_refs() during a GC collection

2021-07-20 Thread Victor Zhestkov


Victor Zhestkov  added the comment:

It seems I have the same segfault, but with 3.6.13 python shipped with 
SLE15SP2. It's salt-api process under intensive usage. I'm able to reproduce 
it, but can't isolate due to the service complexity. In some cases it takes 
about 5 minutes to be crashed, but in others it could run with no crash for 
about an hour or more (I keep the workload on this service with a kind of 
stress test).

--
nosy: +vzhestkov
Added file: https://bugs.python.org/file50163/gdb-bt-full.txt

___
Python tracker 

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



[issue44681] time.sleep(0.001) not working properly

2021-07-20 Thread Thereisfood


Thereisfood  added the comment:

I think this is Windows 10 issue after build 1909. Because I tested on Windows 
10 build 1909 is about 0.001 - 0.002 and tested on 20H2 is the attached results.

--

___
Python tracker 

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



[issue44681] time.sleep(0.001) not working properly

2021-07-20 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Jack, Thereisfood is using Windows, which I understand has a clock with  
millisecond accuracy. So a sleep of a millisecond should, I think, work on 
Windows even if it doesn't work on Linux.

Could a Windows expert clarify please?

--
nosy: +steven.daprano

___
Python tracker 

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



[issue44340] Add support for building cpython with clang thin lto

2021-07-20 Thread Dong-hee Na


Dong-hee Na  added the comment:

@ned.deily

Can we use the thin-lto option for next macOS Python distribution?
In my local environment, it passes all tests :)

https://github.com/python/cpython/blob/366fcbac18e3adc41e3901580dbedb6a91e41a10/Mac/BuildScript/build-installer.py#L1199

FYI, Gentoo already recommends using the thin LTO instead of the full LTO.
https://wiki.gentoo.org/wiki/Clang#Link-time_optimizations_with_Clang

--
nosy: +ned.deily

___
Python tracker 

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



  1   2   >