[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2020-02-19 Thread Tal Einat


Tal Einat  added the comment:

Please do, Ananthakrishnan!

--

___
Python tracker 

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



[issue39660] Contextvars: Optional callbacks on state change

2020-02-19 Thread Yury Selivanov


Yury Selivanov  added the comment:

> Unfortunately, if Python is used as a frontend for a native libray (eg 
> accessed via ctypes), and in case that the state of interest is managed in 
> the native library, contextvar API is insufficient.

Please elaborate with a clearer example.

--

___
Python tracker 

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



[issue35943] PyImport_GetModule() can return partially-initialized module

2020-02-19 Thread Geoffrey Bache


Geoffrey Bache  added the comment:

I have been experiencing what I thought was this issue in my embedded Python 
code. We have been using Python 3.7, so I thought upgrading to 3.8.1 would fix 
it, but it doesn't seem to have made any difference.

My C++ code essentially can call PyImport_GetModule() from two threads 
simultaneously on the same module A. The symptoms I see are that one of them 
then gets a stacktrace in module B (imported by A), saying that some symbol 
defined near the end of B does not exist.

I've also noticed that this happens far more often on deployed code (where 
Python modules end up in a zip file) than when run directly in development 
(where the modules are just normal files). I can't see any difference in the 
frequency between 3.7.5 and 3.8.1.

Any ideas? Should I reopen this?

--
nosy: +gjb1002

___
Python tracker 

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



[issue39693] tarfile's extractfile documentation is misleading

2020-02-19 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +ethan.furman

___
Python tracker 

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



[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2020-02-19 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

I want to do a PR,if this is still needeed.

--
nosy: +Ananthakrishnan

___
Python tracker 

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



[issue39693] tarfile's extractfile documentation is misleading

2020-02-19 Thread Josh Rosenberg


New submission from Josh Rosenberg :

The documentation for extractfile ( 
https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractfile ) 
says:

"Extract a member from the archive as a file object. member may be a filename 
or a TarInfo object. If member is a regular file or a link, an 
io.BufferedReader object is returned. Otherwise, None is returned."

Before reading further, answer for yourself: What do you think happens when a 
provided filename doesn't exist, based on that documentation?

In teaching a Python class that uses tarfile in the final project, and expects 
students to catch predictable errors (e.g. a random tarball being provided, 
rather than one produced by a different mode of the program with specific 
expected files) and convert them to user-friendly error messages, I've found 
this documentation to confuse students repeatedly (if they actually read it, 
rather than just guessing and checking interactively).

Specifically, the documentation:

1. Says nothing about what happens if member doesn't exist (TarFile.getmember 
does mention KeyError, but extractfile doesn't describe itself in terms of 
getmember)
2. Loosely implies that it should return None in such a scenario "If member is 
a regular file or a link, an io.BufferedReader object is returned. Otherwise, 
None is returned." The intent is likely to mean "all other member types are 
None, and we're saying nothing about non-existent members", but everyone I've 
taught who has read the docs came away with a different impression until they 
tested it.

Perhaps just reword from:

"If member is a regular file or a link, an io.BufferedReader object is 
returned. Otherwise, None is returned."

to:

"If member is a regular file or a link, an io.BufferedReader object is 
returned. For all other existing members, None is returned. If member does not 
appear in the archive, KeyError is raised."

Similar adjustments may be needed for extract, and/or both of them could be 
adjusted to explicitly refer to getmember by stating that filenames are 
converted to TarInfo objects via getmember.

--
assignee: docs@python
components: Documentation, Library (Lib)
keywords: easy, newcomer friendly
messages: 362298
nosy: docs@python, josh.r
priority: normal
severity: normal
status: open
title: tarfile's extractfile documentation is misleading
versions: Python 3.7, 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



[issue38872] Document exec symbol for codeop.compile_command

2020-02-19 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

code.compile_command takes _exec_
as symbol.As it is not documented or mentioned anywhere I can't find any 
details about that.Can anyone please tell me what it does?

--
nosy: +Ananthakrishnan

___
Python tracker 

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



[issue26532] build fails with address sanitizer

2020-02-19 Thread Henry Royal


Change by Henry Royal :


--
title: sanitizer -> build fails with address sanitizer
versions: +Python 3.6, Python 3.7 -Python 3.9

___
Python tracker 

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



[issue26532] build fails with address sanitizer

2020-02-19 Thread Henry Royal


Change by Henry Royal :


--
versions: +Python 3.5 -Python 3.7

___
Python tracker 

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



[issue26532] sanitizer

2020-02-19 Thread Henry Royal


Change by Henry Royal :


--
title: build fails with address sanitizer -> sanitizer
versions: +Python 3.9 -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



[issue39684] PyUnicode_IsIdentifier has two if/thens that can be combined

2020-02-19 Thread Andy Lester


Change by Andy Lester :


--
pull_requests:  -17937

___
Python tracker 

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



[issue39684] PyUnicode_IsIdentifier has two if/thens that can be combined

2020-02-19 Thread Andy Lester


Change by Andy Lester :


--
pull_requests: +17947
pull_request: https://github.com/python/cpython/pull/18565

___
Python tracker 

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



[issue29298] argparse fails with required subparsers, un-named dest, and empty argv

2020-02-19 Thread Ben Sokol


Change by Ben Sokol :


--
type: behavior -> crash
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



[issue39622] KeyboardInterrupt is ignored when await asyncio.sleep(0)

2020-02-19 Thread Zhibin Dong


Zhibin Dong  added the comment:

Ubuntu 18.04.4 with kernel 5.3.0-28-generic. Additionally Python version is 
3.7.3.

--

___
Python tracker 

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



[issue29298] argparse fails with required subparsers, un-named dest, and empty argv

2020-02-19 Thread Roundup Robot


Change by Roundup Robot :


--
pull_requests: +17945
pull_request: https://github.com/python/cpython/pull/18564

___
Python tracker 

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



[issue39692] Subprocess using list vs string

2020-02-19 Thread Niklas Smedemark-Margulies


New submission from Niklas Smedemark-Margulies :

Most (all?) of the functions in subprocess (run, Popen, etc) are supposed to 
accept either list or string, but the behavior when passing a list differs (and 
appears to be wrong).

For example, see below - invoking the command "exit 1" should give a return 
code of 1, but when using a list, the return code is 0.


```
>>> import subprocess


>>> # Example using run
>>> res1 = subprocess.run('exit 1', shell=True)
>>> res1.returncode
1
>>> res2 = subprocess.run('exit 1'.split(), shell=True)
>>> res2.returncode
0


>>> # Example using Popen
>>> p1 = subprocess.Popen('exit 1', shell=True)
>>> p1.communicate()
(None, None)
>>> p1.returncode
1
>>> p2 = subprocess.Popen('exit 1'.split(), shell=True)
>>> p2.communicate()
(None, None)
>>> p2.returncode
0
```

--
messages: 362294
nosy: nik-sm
priority: normal
severity: normal
status: open
title: Subprocess using list vs string
type: behavior
versions: Python 3.7, Python 3.8

___
Python tracker 

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



[issue39298] add BLAKE3 to hashlib

2020-02-19 Thread Maor Kleinberger


Change by Maor Kleinberger :


--
nosy: +kmaork

___
Python tracker 

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



[issue39517] runpy calls open_code with Path object

2020-02-19 Thread Maor Kleinberger


Maor Kleinberger  added the comment:

Not a direct solution, but I have offered that io.open_code should be changed 
to support pathlike objects: https://bugs.python.org/issue39691

--
nosy: +kmaork

___
Python tracker 

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



[issue39691] Allow passing Pathlike objects to io.open_code

2020-02-19 Thread Maor Kleinberger


New submission from Maor Kleinberger :

As in many functions in python3, io.open_code should probably accept pathlike 
objects and not just path strings.

Below is  open_code's docstring:
> Opens the provided file with the intent to import the contents.
> This may perform extra validation beyond open(), but is otherwise 
> interchangeable with calling open(path, 'rb').

The second bit is not entirely true, as open accepts pathlike objects and 
open_code doesn't.
Fixing this will help solve future bugs and existing bugs like 
https://bugs.python.org/issue39517

I'd be happy to open a pull request if it is agreed that this should be changed.

--
components: Library (Lib)
messages: 362292
nosy: kmaork
priority: normal
severity: normal
status: open
title: Allow passing Pathlike objects to io.open_code
type: enhancement
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



[issue39681] pickle.load expects an object that implements readinto

2020-02-19 Thread Nathan Goldbaum


Nathan Goldbaum  added the comment:

So I *think* I've pieced together what caused the user crash that originated in 
the flair library. It turns out that pickle.load, via torch.load, is getting 
passed an mmap.mmap. 

https://github.com/flairNLP/flair/blob/1d44abf35f1122d1e146c9a219b2cb5f98b41b40/flair/file_utils.py#L25-L36

https://github.com/flairNLP/flair/blob/1d44abf35f1122d1e146c9a219b2cb5f98b41b40/flair/nn.py#L85-L86

Since mmap doesn't implement readinto, pickle.load objects as of Python 3.8. 
This is new behavior in Python3.8, it used to be possible to load a 
memory-mapped pickle file.

Short repro script:

import pickle
import mmap
data = "some data"

with open('my_data.pkl', 'wb') as f:
pickle.dump(data, f)

with open("my_data.pkl", "r+b") as f_in:
mm = mmap.mmap(f_in.fileno(), 0)

print(pickle.load(mm))

On Python3.8, this script prints an error, on Python3.7 it prints "some data".

--

___
Python tracker 

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



[issue38691] importlib: PYTHONCASEOK should be ignored when using python3 -E

2020-02-19 Thread Andy Lester


Change by Andy Lester :


--
nosy: +petdance

___
Python tracker 

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



[issue39589] Logging QueueListener should support context manager

2020-02-19 Thread Vinay Sajip


Vinay Sajip  added the comment:

See my comments on the PR. I think this issue and the PR should be closed.

--

___
Python tracker 

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



[issue39540] Logging docs don't address the creation of multiple loggers when a hierarchy is provided

2020-02-19 Thread Vinay Sajip


Change by Vinay Sajip :


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



[issue39686] add dump_json to ast module

2020-02-19 Thread Richard K


Richard K  added the comment:

> I don't think the clang argument holds because clang is a command-line tool 
> after all and it makes sense that it can produce several outputs while the 
> ast module is exposes APIs that you can further process inside the language. 
> Having json from the clang output will require more than one tool if clang 
> does not support it while doing it in Python only requires Python.

I see what you mean. I was just trying to illustrate that such a feature is 
desired by some. 

Perhaps 'Python only requires Python' means that Python _could_ be the first 
widely used language with such a superior meta-programming feature with respect 
to AST analysis/code generation. 


> > it appears that they do so in non-standard ways.

> Can you clarify what do you mean with that? 

By non-standard I mean that the resulting json does not follow the structure of 
the tree explicitly. For example with ast2json, '"_type": "Print"' includes a 
(somewhat misleading) key that is not represented in the actual AST. 

Example of ast2json output (example found here, 
https://github.com/YoloSwagTeam/ast2json#example),

{
"body": [
{
"_type": "Print",
"nl": true,
"col_offset": 0,
"dest": null,
"values": [
{
"s": "Hello World!",
"_type": "Str",
"lineno": 1,
"col_offset": 6
}
],
"lineno": 1
}
],
"_type": "Module"
}


> Just to clarify: ast.dump *will* fail with a more deph object as well, I am 
> not claiming that ast.dump will parse everything because of course suffers 
> the same problem.

Makes sense. As you mentioned, these are edge cases which I assume will not be 
an issue for those seeking to gain the benefits of 'ast.dump_json'

--

___
Python tracker 

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



[issue39690] Compiler warnings in unicodeobject.c

2020-02-19 Thread Serhiy Storchaka

New submission from Serhiy Storchaka :

Objects/clinic/unicodeobject.c.h: In function ‘unicode_isidentifier’:
Objects/unicodeobject.c:12245:22: warning: ‘wstr’ may be used uninitialized in 
this function [-Wmaybe-uninitialized]
 ch = wstr[i];
  ^~~
Objects/unicodeobject.c:12212:14: note: ‘wstr’ was declared here
 wchar_t *wstr;
  ^~~~
Objects/unicodeobject.c: In function ‘PyUnicode_IsIdentifier’:
Objects/unicodeobject.c:12245:22: warning: ‘wstr’ may be used uninitialized in 
this function [-Wmaybe-uninitialized]
 ch = wstr[i];
  ^~~

--
components: Interpreter Core
messages: 362288
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Compiler warnings in unicodeobject.c
type: behavior

___
Python tracker 

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



[issue39479] [RFE] Add math.lcm() function: Least Common Multiple

2020-02-19 Thread Mark Dickinson


Change by Mark Dickinson :


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



[issue39479] [RFE] Add math.lcm() function: Least Common Multiple

2020-02-19 Thread Mark Dickinson


Mark Dickinson  added the comment:


New changeset f2ee21d858bc03dd801b97afe60ee2ea289e2fe9 by ananthan-123 in 
branch 'master':
bpo-39479:Add math.lcm() function: Least Common Multiple (#18547)
https://github.com/python/cpython/commit/f2ee21d858bc03dd801b97afe60ee2ea289e2fe9


--

___
Python tracker 

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



[issue39686] add dump_json to ast module

2020-02-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Just to clarify: ast.dump *will* fail with a more deph object as well, I am not 
claiming that ast.dump will parse everything because of course suffers the same 
problem.

--

___
Python tracker 

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



[issue39686] add dump_json to ast module

2020-02-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> There seems to be movement towards a general usage. For instance, take a look 
> at clang, in particular the flag '-ast-dump=json'.

I don't think the clang argument holds because clang is a command-line tool 
after all and it makes sense that it can produce several outputs while the ast 
module is exposes APIs that you can further process inside the language. Having 
json from the clang output will require more than one tool if clang does not 
support it while doing it in Python only requires Python.

> it appears that they do so in non-standard ways.

Can you clarify what do you mean with that? 

> The implementation of ast.dump also uses recursion. I have tested 
> ast.dump_json on sufficiently large source files and have not run into 
> recursion depth exceeded issues.

This is not the primary argumet as by itself is weaker because this is an edge 
case but for instance, here is an example of ast.dump succeeding and your tool 
failing:


>>> x = ast.List()
>>> for _ in range(1010):
...: x = ast.List(x)
...:

>>> ast.dump(x)
'List(elts=List(elts=List(elts=List(elts=List(elts=L..

>>> dump_json(x)
---
RecursionErrorTraceback (most recent call last)
 in 
RecursionError: maximum recursion depth exceeded while calling a Python object

--

___
Python tracker 

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



[issue39686] add dump_json to ast module

2020-02-19 Thread Richard K


Richard K  added the comment:

Batuhan & Pablo thank you for your thoughts! Just wanted to reply to a few of 
the comments to clarify my position on the issue.


> IMHO this is not a feature that has a general usage. If you want, as far as I 
> can see, there are some packages for doing that in PyPI already. Also, the 
> patch looks small so you can just add this to the required project.


There seems to be movement towards a general usage. For instance, take a look 
at clang, in particular the flag '-ast-dump=json'.

$ clang -cc1 -ast-dump=json foo.cc


> ast.dump now can dump in pretty-printed way.

Indeed however, there is not much one can do further with the output of 
ast.dump. With ast.dump_json one would benefit from programmer-centric 
functionality.

-- 

> Thanks, Richard for your proposal. I concur with Batuhan: I am -1 as well on 
> this addition. Echoing some of the same ideas, I think this is specialized 
> enough that does not make sense to have it in the standard library, 
> especially if a Pypi package already exists. 


After just browsing the the pypi package/s you may be referring to, it appears 
that they do so in non-standard ways.


> Additionally, this is straightforward to implement for very simple cases but 
> PR18558 will fail for very generic ASTs if they are deep enough (it uses 
> recursion).


The implementation of ast.dump also uses recursion. I have tested ast.dump_json 
on sufficiently large source files and have not run into recursion depth 
exceeded issues.


Thanks again for your perspective!

--

___
Python tracker 

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



[issue39589] Logging QueueListener should support context manager

2020-02-19 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue39589] Logging QueueListener should support context manager

2020-02-19 Thread Simon


Change by Simon :


--
pull_requests: +17944
pull_request: https://github.com/python/cpython/pull/18563

___
Python tracker 

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



[issue39688] tarfile: GNU sparse 1.0 pax tar header offset not properly computed

2020-02-19 Thread Valentin Samir


Change by Valentin Samir :


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

___
Python tracker 

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



[issue39379] sys.path[0] is already absolute path

2020-02-19 Thread Ananthakrishnan


Change by Ananthakrishnan :


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

___
Python tracker 

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



[issue39589] Logging QueueListener should support context manager

2020-02-19 Thread Simon


Simon  added the comment:

The QueueListener in the logging library starts a background thread to monitor 
the log event queue. The context manager support is ideal in this case, making 
the code simpler, more consistent with other classes (e.g. 
multiprocessing.Pool) and prompts stopping the thread.

Without support for the context manager we need the following code:

```
queue_listener = QueueListener(queue, handler)
queue_listener.start()
# queue messages
queue_listener.stop()
```

adding context manager support would result in the following equivalent code:

```
with QueueListener(queue, handler) as queue_listener:
# queue messages
```

--

___
Python tracker 

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



[issue39688] tarfile: GNU sparse 1.0 pax tar header offset not properly computed

2020-02-19 Thread Valentin Samir


Valentin Samir  added the comment:

hum trying to be clever and I am doing mistakes.

This commit is simpler and effectively fixes the issue 
https://github.com/nitmir/cpython/commit/682138a3544a2d7de457c88712e738938568f908

tarinfo.offset_data is where tarfile start reading the file data and thus must 
be set to the beginning of the actual data for a sparse file even if the data 
block starts before.

--

___
Python tracker 

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



[issue39681] pickle.load expects an object that implements readinto

2020-02-19 Thread Nathan Goldbaum


Nathan Goldbaum  added the comment:

In this case the tests are explicitly testing that a file-like object that does 
not implement readinto works with torch.load (which is using pickles under the 
hood). See 
https://github.com/pytorch/pytorch/blob/master/test/test_serialization.py#L416-L429,
 in particular the usage of FilelikeMock with has_readinto set to False.

This goes back to https://github.com/pytorch/pytorch/pull/5466, however I'm not 
sure offhand why it was decided to explicitly test file-like objects that don't 
implement readinto. I don't know how many consumers there are for this API in 
pytorch, but there is at least one user who has reported an error traceback 
caused by this change. I'm hoping to hear more to see whether there are any 
libraries that depend on pytorch and are implicitly depending on this 
functionality.

Googling the error message that Python3.8 emits in this situation also leads me 
to this bug report in a different library: 
https://github.com/web2py/py4web/issues/77

--

___
Python tracker 

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



[issue39560] PyUnicode_FromKindAndData kind transformation is not documented

2020-02-19 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

Can i add  a pull request for this.

--
nosy: +Ananthakrishnan

___
Python tracker 

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



[issue39688] tarfile: GNU sparse 1.0 pax tar header offset not properly computed

2020-02-19 Thread Valentin Samir


Valentin Samir  added the comment:

This commit fix the issue 
https://github.com/nitmir/cpython/commit/50c1f686054e41738f14de453ede30e942064200

I am currently unable to create pull request on github (error 500)

--

___
Python tracker 

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



[issue39689] test_struct failure on s390x Fedora Clang buildbot

2020-02-19 Thread Charalampos Stratakis


Charalampos Stratakis  added the comment:

Failed assertion here: 
https://github.com/python/cpython/blob/master/Lib/test/test_struct.py#L520

--

___
Python tracker 

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



[issue39689] test_struct failure on s390x Fedora Clang buildbot

2020-02-19 Thread Charalampos Stratakis


New submission from Charalampos Stratakis :

The clang build was recently added for that buildbot and it seems on that 
particular architecture, test_struct fails with:

==
FAIL: test_bool (test.test_struct.StructTest)
--
Traceback (most recent call last):
  File 
"/home/dje/cpython-buildarea/3.x.edelsohn-fedora-rawhide-z.clang-ubsan/build/Lib/test/test_struct.py",
 line 520, in test_bool
self.assertTrue(struct.unpack('>?', c)[0])
AssertionError: False is not true

https://buildbot.python.org/all/#/builders/488/builds/6

Fedora rawhide recently upgraded Clang to version 10. The rest of the 
architectures seem fine.

--
components: Tests
messages: 362277
nosy: cstratak, vstinner
priority: normal
severity: normal
status: open
title: test_struct failure on s390x Fedora Clang buildbot
versions: Python 3.7, 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



[issue39572] [typing] TypedDict's 'total' argument is undocumented

2020-02-19 Thread Guido van Rossum


Guido van Rossum  added the comment:

Go for it. Use the same bug number.

On Wed, Feb 19, 2020 at 02:30 Ananthakrishnan 
wrote:

>
> Ananthakrishnan  added the comment:
>
> yes,I'm interested in writing docs for the `__required_keys__` and
> `__total_keys__` attributes.
>
> --
>
> ___
> Python tracker 
> 
> ___
>
-- 
--Guido (mobile)

--

___
Python tracker 

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



[issue39632] variadic function call broken on armhf when passing a float argument

2020-02-19 Thread Nicolas Dessart


Change by Nicolas Dessart :


--
versions: +Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue39688] tarfile: GNU sparse 1.0 pax tar header offset not properly computed

2020-02-19 Thread Valentin Samir


New submission from Valentin Samir :

When tarfile open a tar containing a sparse file where actual data is bigger 
than 0o777 bytes (~8GB), it fails listing members after this file. As 
so, it is impossible to access/extract files located after a such file inside 
the archive.

A tar file presenting the issue is available at https://genua.fr/sample.tar.xz
Uncompressed the file is ~16GB.
It containes two files:
* disk.img a 50GB sparse file containing ~16GB of data
* README.txt a simple text file containing "This last file is not properly 
listed"

disk.img was generated using the folowing python script:

GB = 1024**3
buf = b"\xFF" * 1024**2
with open('disk.img', 'wb') as f:
f.seek(10 * GB)
wrotten = 0
while wrotten < 0o777:
wrotten += f.write(buf)
f.flush()
print(wrotten/0o777 * 100, '%')
f.seek(50 * GB - 1)
f.write(b'\0')

sample.tar was generated using GNU tar 1.30 on a Debian 10 with the following 
command:

tar --format pax -cvSf sample.tar disk.img README.txt

The following script expose the issue:

import tarfile
t = tarfile.open('sample.tar')
print('members', t.getmembers())
print('offset', t.offset)

Its output is:

members []
offset 17179806208

members should also list README.txt.


I think I have found the root cause of the bug: Because the file is bigger than 
0o777, it's size cannot be specified inside the tar ustar header, so a 
"size" pax extented header is generated. This header contain the full size of 
the file block in the tar.

As the file is sparse, as of sparse format 1.0, the file block contains first a 
sparse mapping, then the file data. So this block size is the size of the 
mapping added to the size of the data.

Because the file is sparse, a GNU.sparse.realsize header is also added 
containing the full expanded file size (here 50GB).

Here 
https://github.com/python/cpython/blob/4dee92b0ad9f4e3ea2f5253340801bb92dc7/Lib/tarfile.py#L1350
 tarfile set the tarinfo size to GNU.sparse.realsize  (50GB),then, in this 
block 
https://github.com/python/cpython/blob/4dee92b0ad9f4e3ea2f5253340801bb92dc7/Lib/tarfile.py#L1297
 the file offset is moved forward from GNU.sparse.realsize (50GB) instead of 
pax_headers["size"]. Moreover, the move is done from next.offset_data which is 
set at https://github.com/python/cpython/blob/master/Lib/tarfile.py#L1338 to 
after the sparse mapping.
The move forward in the sparse file should be made from next.offset + BLOCKSIZE.

--
components: Library (Lib)
messages: 362275
nosy: Nit
priority: normal
severity: normal
status: open
title: tarfile: GNU sparse 1.0 pax tar header offset not properly computed
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, 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



[issue35081] Move internal headers to Include/internal/

2020-02-19 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue39686] add dump_json to ast module

2020-02-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Thanks, Richard for your proposal. I concur with Batuhan: I am -1 as well on 
this addition. Echoing some of the same ideas, I think this is specialized 
enough that does not make sense to have it in the standard library, especially 
if a Pypi package already exists. Additionally, this is straightforward to 
implement for very simple cases but PR18558 will fail for very generic ASTs if 
they are deep enough (it uses recursion).

--

___
Python tracker 

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



[issue39686] add dump_json to ast module

2020-02-19 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

> The proposed enhancement would provide a complementary function, `dump_json` 
> as in a json representation of the ast. 

IMHO this is not a feature that has a general usage. If you want, as far as I 
can see, there are some packages for doing that in PyPI already. Also, the 
patch looks small so you can just add this to the required project.

> This would be useful for those who would like to benefit from the utilities 
> of the json module for formatting, pretty-printing, and the like.  

ast.dump now can dump in pretty-printed way.

> It would also be useful for those who want to serialize the AST or export it 
> in a form that can be consumed in an other programming language.

As I said, serializing/exporting the AST isn't a common use case. It is a very 
specific goal.

In general, I'm -1 on this.

--
nosy: +benjamin.peterson, pablogsal

___
Python tracker 

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



[issue17422] language reference should specify restrictions on class namespace

2020-02-19 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

I just addded a PR for this issue.

--
nosy: +Ananthakrishnan

___
Python tracker 

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



[issue39632] variadic function call broken on armhf when passing a float argument

2020-02-19 Thread Nicolas Dessart


Change by Nicolas Dessart :


--
pull_requests: +17940
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/18560

___
Python tracker 

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



[issue38691] importlib: PYTHONCASEOK should be ignored when using python3 -E

2020-02-19 Thread STINNER Victor


STINNER Victor  added the comment:

> Yes I saw those in the morning, thanks for patching it up. I will debug this 
> over the weekend and will update.

Ok, perfect. In the meanwhile, as announced, I reverted the change to be able 
to notify other regressions.

Once we get a fix, we can reapply the change with the fix.

--

___
Python tracker 

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



[issue39687] re.sub behaves inconsistent between versions with * repetition qualifier

2020-02-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It is correct and documented behavior. ".*" matches two substrings: the whole 
string "bc" and an empty string at the end of the string.

See https://docs.python.org/3/library/re.html#re.sub and 
https://docs.python.org/3/whatsnew/3.7.html#changes-in-the-python-api.

The behavior before 3.7 was incorrect.

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



[issue38691] importlib: PYTHONCASEOK should be ignored when using python3 -E

2020-02-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 4dee92b0ad9f4e3ea2f5253340801bb92dc7 by Victor Stinner in 
branch 'master':
Revert "bpo-38691 Added a switch to ignore PYTHONCASEOK when -E or -I flags 
passed (#18314)" (GH-18553)
https://github.com/python/cpython/commit/4dee92b0ad9f4e3ea2f5253340801bb92dc7


--

___
Python tracker 

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



[issue39676] test_shutil fails with OSError: [Errno 28] No space left on device on "PPC64LE Fedora Stable LTO + PGO 3.x" buildbot

2020-02-19 Thread Petr Viktorin


Petr Viktorin  added the comment:

Indeed, builds are green: https://buildbot.python.org/all/#/builders/449

Thanks Victor for reporting and Harris for fixing this.

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



[issue39686] add dump_json to ast module

2020-02-19 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
nosy: +BTaskaya

___
Python tracker 

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



[issue39622] KeyboardInterrupt is ignored when await asyncio.sleep(0)

2020-02-19 Thread Maor Kleinberger


Maor Kleinberger  added the comment:

On which OS did that happen?

--
nosy: +kmaork

___
Python tracker 

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



[issue39623] __str__ and __repr__ for asyncio.Task still omit arg values

2020-02-19 Thread Maor Kleinberger


Maor Kleinberger  added the comment:

> This could sometimes make the output verbose

We could limit the length of the recursive __repr__ functions, and display 
partial reprs suffixed with ..., like in numpy for example.

We can define that the maximum wanted length of a task repr would be, say, 80 
characters, get the reprs of all task arguments, and if the sum length is more 
than the maximum we can trim the longest ones and suffix with a '...'.

Maybe this restriction shouldn't be applied if python is built in debug mode.

--
nosy: +kmaork

___
Python tracker 

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



[issue9182] document “--” as a way to distinguish option w/ narg='+' from positional argument in argparse

2020-02-19 Thread hai shi


hai shi  added the comment:

It exists in master, so it still need a patch.

--
nosy: +rhettinger, shihai1991
versions: +Python 3.9 -Python 2.7, Python 3.2

___
Python tracker 

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



[issue39687] re.sub behaves inconsistent between versions with * repetition qualifier

2020-02-19 Thread Yves


New submission from Yves :

On different platforms and versions the following expression has different 
results:

  python -c 'import re; print(re.compile("(.*)", 0).sub("a\\1", "bc"))'

As far is I observed:

  Linux/Python 3.6.9   => abc
  MacOS/Python 3.7.1   => abca
  Repl.it/Python 3.8.1 => abca
  MacOS/Python 2.7.17  => abc
  Linux/Python 2.7.17  => abc

According the the documentation I would guess that "abc" is the correct return 
value.

The issues also occurs without compiling or capture group:

 re.sub(".*", "a", "cb")  a vs aa

--
components: Regular Expressions
messages: 362264
nosy: ezio.melotti, mrabarnett, slomo
priority: normal
severity: normal
status: open
title: re.sub behaves inconsistent between versions with * repetition qualifier
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



[issue39676] test_shutil fails with OSError: [Errno 28] No space left on device on "PPC64LE Fedora Stable LTO + PGO 3.x" buildbot

2020-02-19 Thread Charalampos Stratakis


Charalampos Stratakis  added the comment:

The issue has been fixed. root was 15GB, but there was still 30GB of 
un-allocated space in the volume group, so just expanded the logical volume.

--

___
Python tracker 

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



[issue17422] language reference should specify restrictions on class namespace

2020-02-19 Thread Ananthakrishnan


Change by Ananthakrishnan :


--
pull_requests: +17939
pull_request: https://github.com/python/cpython/pull/18559

___
Python tracker 

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



[issue39572] [typing] TypedDict's 'total' argument is undocumented

2020-02-19 Thread Ananthakrishnan


Ananthakrishnan  added the comment:

yes,I'm interested in writing docs for the `__required_keys__` and 
`__total_keys__` attributes.

--

___
Python tracker 

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



[issue13672] Add co_qualname attribute in code objects

2020-02-19 Thread Alex Hall


Alex Hall  added the comment:

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

--
nosy: +alexmojaki

___
Python tracker 

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



[issue22213] Make pyvenv style virtual environments easier to configure when embedding Python

2020-02-19 Thread Henning von Bargen


Henning von Bargen  added the comment:

As a side-note:
In my case I am embedding Python in a C program for several reasons:
- Added an additional module (generated with SWIG)
- This module needs a licence key, which I supply in the C program (to make it 
more difficult to extract it).
- I need a different executable name (python is too unspecific) to identify the 
running program in things like Windows TaskManager, Posix ps,  Oracle V$SESSION.

I'm using virtual environments only in the Linux version, the Windows version 
uses the embeddable ZIP distribution.

The Linux version was working with Python 2.7 and "virtualenv".
Now I'm updating to Python 3.6 and "venv" and running into this issue.

It seems like virtualenv can handle the situation, but venv can't.
Maybe it is worth looking at what virtualenv does differently?

--

___
Python tracker 

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



[issue22213] Make pyvenv style virtual environments easier to configure when embedding Python

2020-02-19 Thread Henning von Bargen


Change by Henning von Bargen :


--
nosy: +Henning.von.Bargen

___
Python tracker 

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



[issue39681] pickle.load expects an object that implements readinto

2020-02-19 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

Right, I think at some point during the PEP 574 implementation review, we 
decided that the input object had to be a proper file implementation
(for example, deriving from io.BufferedIOBase).

I think it should be easy for PyTorch to fix this internally (by deriving from 
the proper io base class), but we can also add a fix to pickle.

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