[issue41021] ctypes callback with structure crashes in Python 3.8 on Windows x86

2020-06-19 Thread Eryk Sun


Eryk Sun  added the comment:

I can reproduce a crash with an x86 build that uses a stdcall callback with a 
32-bit argument followed by any ffi_type_sint64 argument (FILETIME, long long, 
etc). Apparently this is a bug in libffi's ffi_prep_cif. Given the 2nd argument 
has a size of 8 bytes and an alignment of 8 bytes, it sets the CIF (call 
interface) to 16 bytes instead of the correct value of 12 bytes. 

source:

import ctypes

@ctypes.WINFUNCTYPE(None, ctypes.c_int, ctypes.c_int64)
def test(i, j):
print(f"callback {i} {j}")

debugger:

0:000:x86> k 2
ChildEBP RetAddr
00bef6a0 6f1873bd _ctypes_d!_ctypes_alloc_callback+0x24c
00bef6dc 6e7ad81b _ctypes_d!PyCFuncPtr_new+0x32d

The `bytes` field should be 12, not 16:

0:000:x86> ?? p->cif
struct ffi_cif
   +0x000 abi  : 2 ( FFI_STDCALL )
   +0x004 nargs: 2
   +0x008 arg_types: 0x02dc43bc  -> 0x00742e5c _ffi_type
   +0x00c rtype: 0x6f1accec _ffi_type
   +0x010 bytes: 0x10
   +0x014 flags: 8

0:000:x86> ?? p->cif.arg_types[0]
struct _ffi_type * 0x00742e5c
   +0x000 size : 4
   +0x004 alignment: 4
   +0x006 type : 0xa
   +0x008 elements : (null)

0:000:x86> ?? p->cif.arg_types[1]
struct _ffi_type * 0x02dd635c
   +0x000 size : 8
   +0x004 alignment: 8
   +0x006 type : 0xc
   +0x008 elements : (null)

When the callback returns, it cleans 16 bytes from stack instead of the 
expected 12. With stack-allocated `systime` in the sample code, eventually 
GetSystemTimeAsFileTime() ends up overwriting the return address, and 
it tries to return to an arbitrary address. If you're lucky, this address isn't 
executable memory, and it immediately fails on an access violation.

The callback in Aravindhan's sample code works fine if I modify the CIF to use 
12 bytes instead of 16:

_ctypes_d!_ctypes_alloc_callback+0x24c:
6e9f36ec 83c414  add esp,14h
0:000:x86> ?? p->cif.bytes = 12
unsigned int 0xc

0:000:x86> bd 0; g
callback 1 477180670 30820036
callback 2 487502671 30820036
callback 3 497655140 30820036
callback 4 507801994 30820036
callback 5 517818512 30820036
callback 6 527961670 30820036

I suppose this issue should be closed as third party, with a bug report pushed 
upstream -- unless for now it would be better if ctypes implements a workaround.

--

___
Python tracker 

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



[issue41041] Multiprocesing Pool borken on macOS REPL

2020-06-19 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy:  -Digital India
title: Digital India -> Multiprocesing Pool borken on macOS REPL
type: security -> behavior

___
Python tracker 

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



[issue41041] Digital India

2020-06-19 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
Removed message: https://bugs.python.org/msg371919

___
Python tracker 

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



[issue41041] Digital India

2020-06-19 Thread Digital India

Digital India  added the comment:

Digital INDIA Common Services Centre is an online portal where citizens are 
provided access to various government services. The CSC e-Governance is a 
portal developed by the Ministry of Electronic and Information Technology, 
Government of India. 
https://www.digitalindiagov.in/
https://www.digitalindiagov.in/csc-login/
https://www.digitalindiagov.in/apna-khata-rajasthan-e-dharti-land-records/
https://www.digitalindiagov.in/apply-for-apna-csc-online-digital-seva-registration-2019/
https://www.digitalindiagov.in/digital-seva/
https://www.digitalindiagov.in/digitize-india-platform/
https://www.digitalindiagov.in/digitize-india-registration-on-digitizeindia-gov-in-sign-up-for-data-entry-job/
https://www.digitalindiagov.in/nsp/
https://www.digitalindiagov.in/pmay-pradhan-mantri-awas-yojana/
https://www.digitalindiagov.in/csc-portal/

--
nosy: +Digital India
title: Multiprocesing Pool borken on macOS REPL -> Digital India
type:  -> security

___
Python tracker 

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



[issue41041] Multiprocesing Pool borken on macOS REPL

2020-06-19 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Some related note in documentation about repl with commit : 
https://github.com/python/cpython/commit/73dd030c8b71a7080648554652912982054b1177

> Note Functionality within this package requires that the __main__ module be 
> importable by the children. This is covered in Programming guidelines however 
> it is worth pointing out here. This means that some examples, such as the 
> multiprocessing.pool.Pool examples will not work in the interactive 
> interpreter.

--

___
Python tracker 

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



[issue41041] Multiprocesing Pool borken on macOS REPL

2020-06-19 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

There is a documentation ticket already open : 
https://bugs.python.org/issue33553

--
nosy: +xtreak

___
Python tracker 

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



[issue41041] Multiprocesing Pool borken on macOS REPL

2020-06-19 Thread Matthias Bussonnier


Matthias Bussonnier  added the comment:

Thanks.

That's an annoying side effect of having spawn by default on macOS then. 

Could it be possible in `pool.map()` to detect that some of the objects are 
from main and would fail and then raise an error message in the parent process 
before starting the children ?

--

___
Python tracker 

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



[issue41047] argparse: misbehavior when combining positionals and choices

2020-06-19 Thread James Corbett


Change by James Corbett :


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

___
Python tracker 

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



[issue41047] argparse: misbehavior when combining positionals and choices

2020-06-19 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +paul.j3, rhettinger

___
Python tracker 

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



[issue41047] argparse: misbehavior when combining positionals and choices

2020-06-19 Thread James Corbett


New submission from James Corbett :

The `argparse.ArgumentParser` sometimes rejects positional arguments with no 
arguments when `choices` is set and `nargs="*"`. 

When there are no arguments and `nargs` is `"*"`, the default value is chosen, 
or `[]` if there is no default value. This value is then checked against 
`choices` and an error message is printed if the value is not in `choices`. 
However, sometimes the value is intentionally not in `choices`, and this leads 
to problems. An example will explain this much better, and show that the issue 
only occurs with the particular combination of positionals, `nargs="*"`, and 
`choices`:

```
>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument("foo", choices=["a", "b", "c"], nargs="*")
>>> parser.add_argument("--bar", choices=["d", "e", "f"], nargs="*")
>>> parser.add_argument('--baz', type=int, choices=range(5, 10), default="20")
>>> parser.parse_args("a --bar".split())
Namespace(foo=['a'], bar=[], baz=20)
>>> parser.parse_args(["a"])
Namespace(foo=['a'], bar=None, baz=20)
>>> parser.parse_args([])
usage: [-h] [--bar [{d,e,f} ...]] [--baz {5,6,7,8,9}] [{a,b,c} ...]
: error: argument foo: invalid choice: [] (choose from 'a', 'b', 'c')
```

In this case I could have got around the last error by adding `[]` to choices, 
but that pollutes the help and usage messages.

--
components: Library (Lib)
messages: 371915
nosy: jameshcorbett
priority: normal
severity: normal
status: open
title: argparse: misbehavior when combining positionals and choices
type: behavior
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



[issue41046] unittest: make skipTest a classmethod

2020-06-19 Thread James Corbett


Change by James Corbett :


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

___
Python tracker 

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



[issue41046] unittest: make skipTest a classmethod

2020-06-19 Thread James Corbett


New submission from James Corbett :

The `unittest.TestCase.skipTest` method, used to skip the current test, is 
currently an instance method. There's nothing to stop it from being a 
`classmethod` or a `staticmethod` though---it doesn't use its reference to 
`self` since it's just a wrapper around the `SkipTest` exception. Making it a 
`classmethod` or `staticmethod` would allow calling the method from 
`setUpClass`. Here's an example:

```
import unittest

class MyTestCase(unittest.TestCase):

@classmethod
def ready_for_tests(cls):
pass

@classmethod
def setUpClass(cls):
if not cls.ready_for_tests():
cls.skipTest()
```

--
components: Library (Lib)
messages: 371914
nosy: jameshcorbett
priority: normal
severity: normal
status: open
title: unittest: make skipTest a classmethod
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



[issue41045] f-string's "debug" feature is undocumented

2020-06-19 Thread Guido van Rossum


Guido van Rossum  added the comment:

Every other detail about f-strings is spelled out meticulously in the reference 
manual: 
https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals

I think it needs to be added here.

PS OT: I can't find anything about f-strings in pydoc.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue41045] f-string's "debug" feature is undocumented

2020-06-19 Thread Eric V. Smith


New submission from Eric V. Smith :

The feature of f-strings using '=' for "debugging" formatting is not documented.

>>> foo = 'bar'
>>> f'{foo=}'
"foo='bar'"


I'm not sure where this should fit in to the documentation, but it needs to be 
in there somewhere.

Basically the documentation needs to say:

1. The entire string from the opening brace { to the start of the expression 
appears in the output. This allows things like f'{foo = }' to evaluate to "foo 
= 'bar'" (notice the extra spaces).

2. If no format spec (like :20) is given, repr() is used on the expression. If 
a format spec is given, then str() is used on the expression. You can use 
repr() with a format spec by using the !r conversion, like: 

>>> f'{foo=:20}'
'foo=bar '

>>> f'{foo=!r:20}'
"foo='bar'   "

--
assignee: docs@python
components: Documentation
messages: 371912
nosy: docs@python, eric.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: f-string's "debug" feature is undocumented
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



[issue41042] import searches for package even after file was found successfully

2020-06-19 Thread Eric V. Smith


Eric V. Smith  added the comment:

You should just be using "import index". By using "import index.py", you're 
telling the interpreter to first import index, execute the code in it, then 
look for a sub-module named "py" (full name: index.py). Since no such 
sub-module exists, and index is not a package, you get the exception you're 
seeing.

It's like "import os.path": first import "os", then look for "path" inside of 
that.

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



[issue41042] import searches for package even after file was found successfully

2020-06-19 Thread Michael J.


Michael J.  added the comment:

This is a screenshot of the output I received when I ran index.py in a 
terminal. As you can see, it imports the script OK, but then it tries to find 
index as a package, and it fails and prints an error. (2/2)

--
Added file: https://bugs.python.org/file49255/Screenshot at 2020-06-19 
18-26-53.png

___
Python tracker 

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



[issue41042] import searches for package even after file was found successfully

2020-06-19 Thread Michael J.


Michael J.  added the comment:

Attached I have a file containing the script for my program. It's obviously 
incomplete, but it will work as a sample file for demonstrating the output and 
behavior of the interpreter. (1/2)

--
Added file: https://bugs.python.org/file49254/index.py

___
Python tracker 

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



[issue41044] Pegen: double trailing comma on optional+sequence rules at python generator

2020-06-19 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


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

___
Python tracker 

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



[issue41044] Pegen: double trailing comma on optional+sequence rules at python generator

2020-06-19 Thread Batuhan Taskaya


New submission from Batuhan Taskaya :

Python generator generates two trailing commas instead of one when both repeat0 
(*) + optional ([]) qualifiers used. Example failing test (raises a 
SyntaxError, since the generated parser can't be parseable / executable)

def test_opt_sequence(self) -> None:
grammar = """
start: [NAME*]
"""
# This case was failing because of double trailing comma at the end
# of the generated parser. See bpo-
make_parser(grammar)

--
messages: 371908
nosy: BTaskaya
priority: normal
severity: normal
status: open
title: Pegen: double trailing comma on optional+sequence rules at python 
generator

___
Python tracker 

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



[issue41042] import searches for package even after file was found successfully

2020-06-19 Thread Eric V. Smith


Eric V. Smith  added the comment:

Please provide a small script that demonstrates this behavior.

--
nosy: +eric.smith

___
Python tracker 

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



[issue41041] Multiprocesing Pool borken on macOS REPL

2020-06-19 Thread Eric V. Smith


Eric V. Smith  added the comment:

To be unpickle-able, the code for f needs to be imported, which it can't be 
from the repl. Windows has this same issue, due to also not using fork().

>From 
>https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled:
> "Thus the defining module must be importable in the unpickling environment, 
>and the module must contain the named object, otherwise an exception will be 
>raised."

I'll wait a while to see who else chimes in, but I think this should be closed 
as "not a bug".

--
nosy: +eric.smith

___
Python tracker 

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



[issue41040] Fix test_modulefinder

2020-06-19 Thread miss-islington


miss-islington  added the comment:


New changeset 75238869b546526ac9e18d6169f3dc87c7f94eef by Miss Islington (bot) 
in branch '3.9':
bpo-41040: Fix test_modulefinder. (GH-20991)
https://github.com/python/cpython/commit/75238869b546526ac9e18d6169f3dc87c7f94eef


--

___
Python tracker 

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



[issue41040] Fix test_modulefinder

2020-06-19 Thread miss-islington


miss-islington  added the comment:


New changeset 80651ab9e3f9d9a89e566a0b87a51b28720094f0 by Miss Islington (bot) 
in branch '3.8':
bpo-41040: Fix test_modulefinder. (GH-20991)
https://github.com/python/cpython/commit/80651ab9e3f9d9a89e566a0b87a51b28720094f0


--

___
Python tracker 

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



[issue41043] Escape the literal part of the path for glob()

2020-06-19 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue41043] Escape the literal part of the path for glob()

2020-06-19 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

It is common to use glob() as

glob.glob(os.path.join(basedir, pattern))

But it does not work correctly if the base directory contains special globbing 
characters ('*', '?', '['). It is an uncommon case, so in most cases the code 
works. But when move sources to the directory containing special characters, 
built it and run tests, some tests will fail:

test test_tokenize failed -- Traceback (most recent call last):
  File "/home/serhiy/py/[cpython]/Lib/test/test_tokenize.py", line 1615, in 
test_random_files
testfiles.remove(os.path.join(tempdir, "test_unicode_identifiers.py"))
ValueError: list.remove(x): x not in list

test test_multiprocessing_fork failed -- Traceback (most recent call last):
  File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 
4272, in test_import
modules = self.get_module_names()
  File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 
4267, in get_module_names
modules.remove('multiprocessing.__init__')
ValueError: list.remove(x): x not in list

test test_bz2 failed -- Traceback (most recent call last):
  File "/home/serhiy/py/[cpython]/Lib/test/test_bz2.py", line 740, in 
testDecompressorChunksMaxsize
self.assertFalse(bzd.needs_input)
AssertionError: True is not false

test test_multiprocessing_forkserver failed -- Traceback (most recent call 
last):
  File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 
4272, in test_import
modules = self.get_module_names()
  File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 
4267, in get_module_names
modules.remove('multiprocessing.__init__')
ValueError: list.remove(x): x not in list

test test_multiprocessing_spawn failed -- Traceback (most recent call last):
  File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 
4272, in test_import
modules = self.get_module_names()
  File "/home/serhiy/py/[cpython]/Lib/test/_test_multiprocessing.py", line 
4267, in get_module_names
modules.remove('multiprocessing.__init__')
ValueError: list.remove(x): x not in list

The proposed PR adds glob.escape() to the above code:

glob.glob(os.path.join(glob.escape(basedir), pattern))

--
components: Library (Lib)
messages: 371903
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Escape the literal part of the path for glob()
type: behavior
versions: Python 3.10, 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



[issue41040] Fix test_modulefinder

2020-06-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20168
pull_request: https://github.com/python/cpython/pull/20993

___
Python tracker 

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



[issue41042] import searches for package even after file was found successfully

2020-06-19 Thread Michael J.


New submission from Michael J. :

Hello,
Earlier today, I was developing a program and I wanted to check its variables 
after it finished running. Simply going into a terminal, entering my program's 
directory, and executing "python3 index.py" would return control to the command 
line before I would have a chance to examine the data, so I ran "python3", got 
to the shell, and then imported my file.
My script executed, but after it finished, the intepreter raised a 
"ModuleNotFoundError: No module named 'index.py'; 'index' is not a package."
Is this supposed to happen after the interpreter finishes importing a file?
Thanks,
Michael

--
components: Interpreter Core
messages: 371902
nosy: MichaelSapphire
priority: normal
severity: normal
status: open
title: import searches for package even after file was found successfully
type: behavior
versions: Python 3.8

___
Python tracker 

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



[issue41040] Fix test_modulefinder

2020-06-19 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 1.0 -> 2.0
pull_requests: +20167
pull_request: https://github.com/python/cpython/pull/20992

___
Python tracker 

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



[issue41040] Fix test_modulefinder

2020-06-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset a041e116db5f1e78222cbf2c22aae96457372680 by Serhiy Storchaka in 
branch 'master':
bpo-41040: Fix test_modulefinder. (GH-20991)
https://github.com/python/cpython/commit/a041e116db5f1e78222cbf2c22aae96457372680


--

___
Python tracker 

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



[issue41041] Multiprocesing Pool borken on macOS REPL

2020-06-19 Thread Matthias Bussonnier


New submission from Matthias Bussonnier :

$ python
Python 3.8.2 | packaged by conda-forge | (default, Apr 24 2020, 07:56:27)
[Clang 9.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from multiprocessing import Pool
>>>
>>> def f(x):
... return x*x
...
 
>>> with Pool(5) as p:
... print(p.map(f, [1, 2, 3]))
Process SpawnPoolWorker-1:
Process SpawnPoolWorker-2:
Process SpawnPoolWorker-3:
Traceback (most recent call last):
  File 
"/Users/bussonniermatthias/miniconda3/lib/python3.8/multiprocessing/process.py",
 line 315, in _bootstrap
self.run()
  File 
"/Users/bussonniermatthias/miniconda3/lib/python3.8/multiprocessing/process.py",
 line 108, in run
self._target(*self._args, **self._kwargs)
  File 
"/Users/bussonniermatthias/miniconda3/lib/python3.8/multiprocessing/pool.py", 
line 114, in worker
task = get()
  File 
"/Users/bussonniermatthias/miniconda3/lib/python3.8/multiprocessing/queues.py", 
line 358, in get
return _ForkingPickler.loads(res)
AttributeError: Can't get attribute 'f' on 
Traceback (most recent call last):
...

This is likely due to https://bugs.python.org/issue33725 (use spawn on MacOS), 
we we can't use `fork()`.

--
messages: 371900
nosy: mbussonn
priority: normal
severity: normal
status: open
title: Multiprocesing Pool borken on macOS REPL

___
Python tracker 

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



[issue40636] Provide a strict form of zip (PEP-618) requiring same length inputs

2020-06-19 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 59cf853332a82ce92875ea3dd6bba08e1305a288 by Ram Rachum in branch 
'master':
bpo-40636: Documentation for zip-strict (#20961)
https://github.com/python/cpython/commit/59cf853332a82ce92875ea3dd6bba08e1305a288


--

___
Python tracker 

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



[issue40704] PyIter_Check fails when compiling in the Limited API

2020-06-19 Thread Stefan Behnel


Stefan Behnel  added the comment:

You can see it from the tags on the commit, it was fixed in Py3.8.

Duplicate of issue 33738.

--
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.8 -Python 3.6, Python 3.7

___
Python tracker 

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



[issue41040] Fix test_modulefinder

2020-06-19 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue41040] Fix test_modulefinder

2020-06-19 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There is a bug in test_modulefinder. The bytes string literal contains \u2090.

1. Since \u is not recognized escape sequence in bytes literals, compiling the 
file emits a deprecation warning:

/home/serhiy/py/cpython/Lib/test/test_modulefinder.py:281: DeprecationWarning: 
invalid escape sequence \u
  b"""\

2. b"\u2090" is interpreted as b"\\u2090", but actually the test implies that 
it should be a bytes sequence b'\xe2\x82\x90' which is valid in UTF-8 but is 
not a valid in CP1252.

--
components: Tests
messages: 371897
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Fix test_modulefinder
type: behavior
versions: Python 3.10, 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



[issue40704] PyIter_Check fails when compiling in the Limited API

2020-06-19 Thread Maxwell Bernstein


Maxwell Bernstein  added the comment:

Oh, it looks like this has been done: 
https://github.com/python/cpython/commit/ea62ce7f4fefc66bc0adba16bcd7666d5bbd5b44

Although I am not sure what version this made it into. So maybe this does not 
affect versions 3.9/3.10. I've seen it in 3.6/6, for sure.

--
versions: +Python 3.6, Python 3.7 -Python 3.10, Python 3.9

___
Python tracker 

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



[issue40704] PyIter_Check fails when compiling in the Limited API

2020-06-19 Thread Maxwell Bernstein


Change by Maxwell Bernstein :


--
keywords: +patch
pull_requests: +20165
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/7477

___
Python tracker 

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



[issue19270] Document that sched.cancel() doesn't distinguish equal events and can break order

2020-06-19 Thread Bar Harel


Bar Harel  added the comment:

I've just encountered this bug as well.

Although this issue is old, #1 should be fixed whether we like it or not. 
Cancelling an unintended event instead of the one we wanted is a bug, and 
prevents me from using the library at all (I schedule events based on absolute 
time).

To be honest, I do not believe anyone uses scheduler.cancel(Event(time, 
priority, ...)) in order to cancel an event based on the given time and 
priority.

Even if they do so, Event itself is undocumented and is being treated mostly as 
an ID for a currently scheduled event.

A good solution would be to add a DeprecationWarning to the ordering functions, 
so people won't use them, and remove __eq__ at 3.12.

The only issue that will arise is that an event1 might be >= than event2, <= 
than event 2, and != to event 2, as the other ordering will stay. We can fix 
this by implementing a slower lookup but I believe it isn't a real issue.

--
nosy: +bar.harel

___
Python tracker 

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



[issue41026] mailbox does not support new Path object

2020-06-19 Thread శ్రీనివాస్ రెడ్డి తాటిపర్తి

Change by Srinivas  Reddy Thatiparthy(శ్రీనివాస్ రెడ్డి తాటిపర్తి) 
:


--
nosy: +thatiparthy
nosy_count: 2.0 -> 3.0
pull_requests: +20164
pull_request: https://github.com/python/cpython/pull/20990

___
Python tracker 

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



[issue41039] Simplify python3.dll build

2020-06-19 Thread Nikita Nemkin


Change by Nikita Nemkin :


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

___
Python tracker 

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



[issue41039] Simplify python3.dll build

2020-06-19 Thread Nikita Nemkin


New submission from Nikita Nemkin :

python3.dll build process can be simplified if we use linker comment #pragma 
instead of .def files. Custom build targets become unnecessary and hardcoded 
Python DLL name can be replaced with a macro.

Also, python3.dll doesn't need DllMain and can be built with /NOENTRY.

--
components: Windows
messages: 371894
nosy: nnemkin, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Simplify python3.dll build
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue38377] test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process mixin breaks in the Unix environment without working /dev/shm

2020-06-19 Thread miss-islington


miss-islington  added the comment:


New changeset 1529322ca6b7b029af65aceeb04e6d47013eeeb4 by Miss Islington (bot) 
in branch '3.9':
bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS (GH-20984)
https://github.com/python/cpython/commit/1529322ca6b7b029af65aceeb04e6d47013eeeb4


--

___
Python tracker 

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



[issue38377] test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process mixin breaks in the Unix environment without working /dev/shm

2020-06-19 Thread miss-islington


miss-islington  added the comment:


New changeset ec9bc2da421c456e416d991fd1fe79ac33344d9d by Miss Islington (bot) 
in branch '3.8':
bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS (GH-20984)
https://github.com/python/cpython/commit/ec9bc2da421c456e416d991fd1fe79ac33344d9d


--

___
Python tracker 

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



[issue38377] test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process mixin breaks in the Unix environment without working /dev/shm

2020-06-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20162
pull_request: https://github.com/python/cpython/pull/20988

___
Python tracker 

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



[issue38377] test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process mixin breaks in the Unix environment without working /dev/shm

2020-06-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 3358da4054b9b0b045eb47dc74dee3d58bfbb1d5 by Victor Stinner in 
branch 'master':
bpo-38377: Fix skip_if_broken_multiprocessing_synchronize() on macOS (GH-20984)
https://github.com/python/cpython/commit/3358da4054b9b0b045eb47dc74dee3d58bfbb1d5


--

___
Python tracker 

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



[issue38377] test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process mixin breaks in the Unix environment without working /dev/shm

2020-06-19 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue40077] Convert static types to PyType_FromSpec()

2020-06-19 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset ec689187957cc80af56b9a63251bbc295bafd781 by Dong-hee Na in branch 
'master':
bpo-40077: Convert _bz2 module to use PyType_FromSpec (GH-20960)
https://github.com/python/cpython/commit/ec689187957cc80af56b9a63251bbc295bafd781


--

___
Python tracker 

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



[issue37630] Investigate replacing SHA3 code with OpenSSL

2020-06-19 Thread Charalampos Stratakis


Change by Charalampos Stratakis :


--
pull_requests: +20160
pull_request: https://github.com/python/cpython/pull/20986

___
Python tracker 

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



[issue41034] test_builtin: PtyTests fail when run twice

2020-06-19 Thread hai shi


Change by hai shi :


--
nosy: +shihai1991

___
Python tracker 

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



[issue41036] Visit the type of instance of heap types if tp_traverse is not implemented

2020-06-19 Thread hai shi


Change by hai shi :


--
nosy: +shihai1991

___
Python tracker 

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



[issue41030] Provide toList() method on iterators/generators (`list()` is a flow killer in REPL)

2020-06-19 Thread Zachary Ware


Zachary Ware  added the comment:

Hi Julien,

Thanks for the suggestion, but I agree with Ammar and Remi that this is not 
likely to either be easily doable or actually help your case.  This would also 
be a big enough change to likely need a PEP.

If you still want to pursue this I would suggest starting a discussion on the 
python-id...@python.org mailing list, but for now I'm going to go ahead and 
close this issue.

--
nosy: +zach.ware
resolution:  -> rejected
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



[issue41038] VersionInfo string is corrupted when building on Windows with DBCS or UTF-8 locale

2020-06-19 Thread Nikita Nemkin


Change by Nikita Nemkin :


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

___
Python tracker 

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



[issue41038] VersionInfo string is corrupted when building on Windows with DBCS or UTF-8 locale

2020-06-19 Thread Nikita Nemkin

New submission from Nikita Nemkin :

In absence of explicit declaration, resource compiler uses system
codepage. When this codepage is DBCS or UTF-8, Python's copyright
string is corrupted, because it contains copyright sign encoded
as \xA9.

The fix is to explicitly declare codepage 1252.

Another possible fix is to use codepage 65001, but that will require replacing 
\xA9 with an actual ©, because it seems impossible to escape unicode characters 
in VersionInfo strings.

--
components: Windows
messages: 371888
nosy: nnemkin, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: VersionInfo string is corrupted when building on Windows with DBCS or 
UTF-8 locale
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



[issue40958] ASAN/UBSAN: heap-buffer-overflow in pegen.c

2020-06-19 Thread neonene


Change by neonene :


--
nosy: +christian.heimes -neonene

___
Python tracker 

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



[issue41037] Add (optional) threadstate to: PyOS_InterruptOccurred()

2020-06-19 Thread STINNER Victor


STINNER Victor  added the comment:

Such function already exists in the master branch, but it's only part of the 
internal C API:

PyAPI_FUNC(int) _PyOS_InterruptOccurred(PyThreadState *tstate);

Currently, the C API design is to always requires to hold the GIL.

--

___
Python tracker 

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



[issue38377] test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process mixin breaks in the Unix environment without working /dev/shm

2020-06-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +20158
pull_request: https://github.com/python/cpython/pull/20984

___
Python tracker 

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



[issue38377] test_asyncio.test_events.GetEventLoopTestsMixin.test_get_event_loop_new_process mixin breaks in the Unix environment without working /dev/shm

2020-06-19 Thread STINNER Victor


STINNER Victor  added the comment:

>From what I understood, the problem is that creating a SemLock has an impact 
>on the resource tracker.

The failing unit tests checks something about the resource tracker.

The test runs a function in a child process. The function is defined in 
_test_multiprocessing.py. _test_multiprocessing.py calls 
skip_if_broken_multiprocessing_synchronize() which creates a SemLock(). At the 
end, the child process modifies the resource tracker because it creates a 
SemLock().

There are different options to fix the issue:

* Modify skip_if_broken_multiprocessing_synchronize() only only attempt to 
create a SemLock on Linux.
* Modify skip_if_broken_multiprocessing_synchronize() to only check if the 
current user is allowed to write into /dev/shm/ directory: that would allow 
touching the resource tracker.
* Modify the test to avoid improting _test_multiprocessing in the child process.

I don't know why the test only fails on macOS.

Note: I ignored macOS failure when I merged my PR because the macOS job of 
GitHub Action is failing randomly for at least 3 months and nobody attempted to 
fix it. So I learnt to ignore this job.

--

___
Python tracker 

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



[issue41036] Visit the type of instance of heap types if tp_traverse is not implemented

2020-06-19 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue41036] Visit the type of instance of heap types if tp_traverse is not implemented

2020-06-19 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue41037] Add (optional) threadstate to: PyOS_InterruptOccurred()

2020-06-19 Thread Sebastian Berg


New submission from Sebastian Berg :

In https://bugs.python.org/issue40826 it was defined that 
`PyOS_InterruptOccurred()` can only be called with a GIL.  NumPy had a few 
places with very unsafe sigint handling (not thread-safe).  But generally when 
we are in a situation that catching sigints would be nice as an enhancement, we 
do of course not hold the GIL.

So I am wondering if we can find some kind of thread-safe solution, or even 
just recipe.  Briefly looking at the code, it seemed to me that adding a new 
function with an additional `tstate` signature:

PyOS_InterruptOccurred(PyThreadState *tstate)

Could work, and be a simple way to allow this in the future?  It is probably 
not high priority for us (NumPy had only one place where it tried to stop long 
running computations).
But right now I am unsure if the function has much use if it requires the GIL 
to be held and a `tstate=NULL` argument seemed reasonable (if it works), except 
that it adds a C-API name.

--
components: C API
messages: 371885
nosy: seberg, vstinner
priority: normal
severity: normal
status: open
title: Add (optional) threadstate to: PyOS_InterruptOccurred()
type: enhancement
versions: Python 3.10

___
Python tracker 

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



[issue41036] Visit the type of instance of heap types if tp_traverse is not implemented

2020-06-19 Thread STINNER Victor

New submission from STINNER Victor :

While reviewing changes of bpo-40077 "Convert static types to 
PyType_FromSpec()", I noticed that some static types don't implement 
tp_traverse.

The doc says:

Heap-allocated types (...) hold a reference to their type. Their traversal 
function must therefore either visit Py_TYPE(self), or delegate this 
responsibility by calling tp_traverse of another heap-allocated type (such as a 
heap-allocated superclass). If they do not, the type object may not be 
garbage-collected.

https://docs.python.org/dev/c-api/typeobj.html#c.PyTypeObject.tp_traverse

Porting to 3.9 says:

for types that have a custom tp_traverse function, ensure that all custom 
tp_traverse functions of heap-allocated types visit the object’s type

https://docs.python.org/dev/whatsnew/3.9.html#changes-in-the-c-api

--

It seems like converting a static type to a heap allocated type requires to 
*add* a new tp_traverse function, if it wasn't the case.

Maybe we can provide a base tp_traverse implementation in the base object type: 
visit the type if it's a heap type?

See attached PR.

See bpo-35810 and bpo-40217 for more information.

--
components: C API, Interpreter Core
messages: 371884
nosy: pablogsal, vstinner
priority: normal
severity: normal
status: open
title: Visit the type of instance of heap types if tp_traverse is not 
implemented
versions: Python 3.10, Python 3.9

___
Python tracker 

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



[issue40704] PyIter_Check fails when compiling in the Limited API

2020-06-19 Thread Stefan Behnel


Stefan Behnel  added the comment:

It should be replaced with an actual function, which can be inline in the 
non-limited case.

--
nosy: +scoder
stage:  -> needs patch
type:  -> compile error
versions: +Python 3.10, Python 3.9 -Python 3.6, Python 3.7

___
Python tracker 

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



[issue40637] Allow users to disable builtin hash modules on compile time

2020-06-19 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +20156
pull_request: https://github.com/python/cpython/pull/20980

___
Python tracker 

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



[issue41004] Hash collisions in IPv4Interface and IPv6Interface

2020-06-19 Thread Eric V. Smith


Eric V. Smith  added the comment:

Changing versions to where the fix would be applied.

--
versions:  -Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue40741] Upgrade to SQLite v3.32 in Windows and macOS builds

2020-06-19 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +20155
pull_request: https://github.com/python/cpython/pull/20979

___
Python tracker 

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



[issue41035] zipfile.Path does not work properly with zip archives where paths start with /

2020-06-19 Thread sorrow


New submission from sorrow :

I encountered errors when I had to work with ZPI file where path start with "/"

--
components: Library (Lib)
messages: 371880
nosy: sorrow
priority: normal
severity: normal
status: open
title: zipfile.Path does not work properly with zip archives where paths start 
with /
type: behavior
versions: Python 3.8

___
Python tracker 

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



[issue41035] zipfile.Path does not work properly with zip archives where paths start with /

2020-06-19 Thread sorrow


sorrow  added the comment:

>>> import zipfile
>>> import io
>>> data = io.BytesIO()
>>> zf = zipfile.ZipFile(data, 'w')
>>> zf.writestr('/a.txt', 'content of a')
>>> zf.filename = 'abcde.zip'
>>> root = zipfile.Path(zf)
>>> list(root.iterdir())
[]
>>> root.exists()
False

--

___
Python tracker 

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



[issue40943] PEP 353: Drop support for PyArg_ParseTuple() "#" formats when PY_SSIZE_T_CLEAN is not defined

2020-06-19 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue41026] mailbox does not support new Path object

2020-06-19 Thread Laurence


Laurence  added the comment:

I have patched the module to accept a path-like object, however it still 
follows the pre-pathlib ways of doing things elsewhere.  There's quite a bit of 
work to do to modernise the whole module, but this patch at least adds support 
to pass a Path to the classes it provides so external code can use pathlib and 
interface with it.

--

___
Python tracker 

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



[issue41026] mailbox does not support new Path object

2020-06-19 Thread Laurence


Change by Laurence :


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

___
Python tracker 

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



[issue39949] truncating match in regular expression match objects repr

2020-06-19 Thread Quentin Wenger


Quentin Wenger  added the comment:

Other pathological case: literal backslashes

```
>>> re.match(".*", r"\\")

```

--

___
Python tracker 

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



[issue41034] test_builtin: PtyTests fail when run twice

2020-06-19 Thread STINNER Victor


STINNER Victor  added the comment:

See also:

* bpo-19884: "Importing readline produces erroneous output". Worked around 
using TERM='xterm-256color env var and by calling rl_variable_bind 
("enable-meta-key", "off");
* bpo-11679 "readline interferes with characters beginning with byte \xe9".

--

___
Python tracker 

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



[issue40741] Upgrade to SQLite v3.32 in Windows and macOS builds

2020-06-19 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

FYI, 3.32.3 is out now: https://sqlite.org/releaselog/3_32_3.html
I'll update the PR and push a new PR for source deps right away.

--

___
Python tracker 

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



[issue41034] test_builtin: PtyTests fail when run twice

2020-06-19 Thread STINNER Victor


STINNER Victor  added the comment:

I also reproduce the issue on RHEL 8 with readline 7.0.

But the issue is hidden if stdout is not a TTY. I use "| cat", so Python stdout 
is a pipe:

$ ./python -m test test_readline test_builtin -v|cat
(...)
Tests result: SUCCESS

--

___
Python tracker 

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



[issue41034] test_builtin: PtyTests fail when run twice

2020-06-19 Thread STINNER Victor


STINNER Victor  added the comment:

I reproduce the issue on Fedora 32 with readline 8.0:

$ ./python -m test.pythoninfo|grep readline
readline._READLINE_LIBRARY_VERSION: 8.0
readline._READLINE_RUNTIME_VERSION: 0x800
readline._READLINE_VERSION: 0x800

--

___
Python tracker 

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



[issue41034] test_builtin: PtyTests fail when run twice

2020-06-19 Thread STINNER Victor


STINNER Victor  added the comment:

The two non-ASCII tests are very old:

commit 0d776b1ce849ff0646738b6361ef940ab6f8b9cb
Author: Antoine Pitrou 
Date:   Sun Nov 6 00:34:26 2011 +0100

Issue #13342: input() used to ignore sys.stdin's and sys.stdout's unicode
error handler in interactive mode (when calling into PyOS_Readline()).


The code was refactored later by:

commit c9a6ab56cfae90c96c1361314c3c99b32e114446
Author: Martin Panter 
Date:   Sat Oct 10 01:25:38 2015 +

Issue #24402: Fix input() when stdout.fileno() fails; diagnosed by Eryksun

Also factored out some test cases into a new PtyTests class.

--

___
Python tracker 

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



[issue41034] test_builtin: PtyTests fail when run twice

2020-06-19 Thread STINNER Victor

STINNER Victor  added the comment:

test_input_tty_non_ascii_unicode_errors() fails if readline was imported 
previously. Example:

$ ./python -m test test_readline test_builtin -v 
(...)
==
FAIL: test_input_tty_non_ascii (test.test_builtin.PtyTests)
--
Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2102, in 
test_input_tty_non_ascii
self.check_input_tty("prompté", b"quux\xe9", "utf-8")
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2093, in 
check_input_tty
self.assertEqual(input_result, expected)
AssertionError: 'quux' != 'quux\udce9'
- quux
+ quux\udce9
? +


==
FAIL: test_input_tty_non_ascii_unicode_errors (test.test_builtin.PtyTests)
--
Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2106, in 
test_input_tty_non_ascii_unicode_errors
self.check_input_tty("prompté", b"quux\xe9", "ascii")
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2093, in 
check_input_tty
self.assertEqual(input_result, expected)
AssertionError: 'quux' != 'quux\udce9'
- quux
+ quux\udce9
? +



Another example: import readline in test_builtin.

diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 40df7b606a..102b397e66 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1,3 +1,4 @@
+import readline
 # Python test set -- built-in functions
 
 import ast


$ ./python -m test test_builtin -v -m PtyTests
== CPython 3.10.0a0 (heads/master:310f6aa7db, Jun 19 2020, 12:18:54) [GCC 
10.1.1 20200507 (Red Hat 10.1.1-1)]
== Linux-5.6.18-300.fc32.x86_64-x86_64-with-glibc2.31 little-endian
== cwd: /home/vstinner/python/master/build/test_python_123487
== CPU count: 8
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 0.36 Run tests sequentially
0:00:00 load avg: 0.36 [1/1] test_builtin
test_input_no_stdout_fileno (test.test_builtin.PtyTests) ... ok
test_input_tty (test.test_builtin.PtyTests) ... ok
test_input_tty_non_ascii (test.test_builtin.PtyTests) ... FAIL
test_input_tty_non_ascii_unicode_errors (test.test_builtin.PtyTests) ... FAIL

==
FAIL: test_input_tty_non_ascii (test.test_builtin.PtyTests)
--
Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2102, in 
test_input_tty_non_ascii
self.check_input_tty("prompté", b"quux\xe9", "utf-8")
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2093, in 
check_input_tty
self.assertEqual(input_result, expected)
AssertionError: 'quux' != 'quux\udce9'
- quux
+ quux\udce9
? +


==
FAIL: test_input_tty_non_ascii_unicode_errors (test.test_builtin.PtyTests)
--
Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2106, in 
test_input_tty_non_ascii_unicode_errors
self.check_input_tty("prompté", b"quux\xe9", "ascii")
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2093, in 
check_input_tty
self.assertEqual(input_result, expected)
AssertionError: 'quux' != 'quux\udce9'
- quux
+ quux\udce9
? +


--

Ran 4 tests in 0.028s

FAILED (failures=2)
test test_builtin failed
test_builtin failed

== Tests result: FAILURE ==

1 test failed:
test_builtin

Total duration: 446 ms
Tests result: FAILURE

--

___
Python tracker 

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



[issue41034] test_builtin: PtyTests fail when run twice

2020-06-19 Thread STINNER Victor

New submission from STINNER Victor :

I tried to check for reference leaks, but running test_builtin twice fails:

$ ./python -m test -R 3:3 test_builtin 
0:00:00 load avg: 2.18 Run tests sequentially
0:00:00 load avg: 2.18 [1/1] test_builtin
beginning 6 repetitions
123456
.test test_builtin failed -- multiple errors occurred; run in verbose mode for 
details
test_builtin failed

== Tests result: FAILURE ==

1 test failed:
test_builtin

Total duration: 1.3 sec
Tests result: FAILURE



The error comes from PtyTests, but the issue is only triggered when 
builtins.float.hex is also run:

$ ./python -m test test_builtin test_builtin -m 
test.test_builtin.PtyTests.test_input_tty_non_ascii_unicode_errors -m 
builtins.float.hex   -v
== CPython 3.10.0a0 (heads/master:310f6aa7db, Jun 19 2020, 12:18:54) [GCC 
10.1.1 20200507 (Red Hat 10.1.1-1)]
== Linux-5.6.18-300.fc32.x86_64-x86_64-with-glibc2.31 little-endian
== cwd: /home/vstinner/python/master/build/test_python_122646
== CPU count: 8
== encodings: locale=UTF-8, FS=utf-8
0:00:00 load avg: 0.60 Run tests sequentially
0:00:00 load avg: 0.60 [1/2] test_builtin
test_input_tty_non_ascii_unicode_errors (test.test_builtin.PtyTests) ... ok
hex (builtins.float)
Doctest: builtins.float.hex ... ok

--

Ran 2 tests in 0.009s

OK
0:00:00 load avg: 0.63 [2/2] test_builtin
test_input_tty_non_ascii_unicode_errors (test.test_builtin.PtyTests) ... FAIL
hex (builtins.float)
Doctest: builtins.float.hex ... ok

==
FAIL: test_input_tty_non_ascii_unicode_errors (test.test_builtin.PtyTests)
--
Traceback (most recent call last):
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2105, in 
test_input_tty_non_ascii_unicode_errors
self.check_input_tty("prompté", b"quux\xe9", "ascii")
  File "/home/vstinner/python/master/Lib/test/test_builtin.py", line 2092, in 
check_input_tty
self.assertEqual(input_result, expected)
AssertionError: 'quux' != 'quux\udce9'
- quux
+ quux\udce9
? +


--

Ran 2 tests in 0.011s

FAILED (failures=1)
test test_builtin failed
test_builtin failed

== Tests result: FAILURE ==

1 test OK.

1 test failed:
test_builtin

Total duration: 762 ms
Tests result: FAILURE

--
components: Tests
messages: 371871
nosy: vstinner
priority: normal
severity: normal
status: open
title: test_builtin: PtyTests fail when run twice
versions: Python 3.10

___
Python tracker 

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



[issue40636] Provide a strict form of zip (PEP-618) requiring same length inputs

2020-06-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 310f6aa7db8dd48952ed718111ce0f016b1c8ef9 by Guido van Rossum in 
branch 'master':
bpo-40636: PEP 618: add strict parameter to zip() (GH-20921)
https://github.com/python/cpython/commit/310f6aa7db8dd48952ed718111ce0f016b1c8ef9


--
nosy: +vstinner

___
Python tracker 

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



[issue39949] truncating match in regular expression match objects repr

2020-06-19 Thread Quentin Wenger


Quentin Wenger  added the comment:

*off

--

___
Python tracker 

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



[issue39949] truncating match in regular expression match objects repr

2020-06-19 Thread Quentin Wenger


Quentin Wenger  added the comment:

(but those are one-character escapes, so that should be fine - either the 
escape is complete or the backslash is trailing and can be "peeled of")

--

___
Python tracker 

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



[issue39949] truncating match in regular expression match objects repr

2020-06-19 Thread Quentin Wenger


Quentin Wenger  added the comment:

And ascii escapes should also not be forgotten.

```
>>> re.match(b".*", b"\t")

>>> re.match(".*", "\t")

```

--

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2020-06-19 Thread Arkady


Arkady  added the comment:

I have reproduced a similar memory leak in the multiprocessing

This is the trace:

913 memory blocks: 33232 Bytes:  File "/usr/lib/python3.7/threading.py", line 
890;self._bootstrap_inner();  File "/usr/lib/python3.7/threading.py", line 
914;self._set_tstate_lock();  File "/usr/lib/python3.7/threading.py", line 
904;self._tstate_lock = _set_sentinel();

--
nosy: +Arkady M

___
Python tracker 

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



[issue41028] Move docs.python.org language and version switcher out of cpython

2020-06-19 Thread Julien Palard


Julien Palard  added the comment:

In production, this is now starting to fix links and picker for the 2.7 
version, which was stating:

Docs by version

Python 3.9 (in development)

and now displays:

Docs by version

Python 3.10 (in development)

--

___
Python tracker 

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



[issue39949] truncating match in regular expression match objects repr

2020-06-19 Thread Quentin Wenger


Quentin Wenger  added the comment:

An extraneous difficulty also exists for bytes regexes, because there non-ascii 
characters are repr'ed using escape sequences. So there's a risk of cutting one 
in the middle.

```
>>> import re
>>> re.match(b".*", b"\xce")

```

--

___
Python tracker 

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



[issue38035] shared_semaphores cannot be shared across unrelated processes

2020-06-19 Thread Vinay Sharma


Vinay Sharma  added the comment:

Hi @taleinat, I had sent a mail to the python mailing list as suggested. And 
till now it has received rather positive comments, in the sense that people who 
responded see this is a useful feature to be integrated into python.

--

___
Python tracker 

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



[issue40943] PEP 353: Drop support for PyArg_ParseTuple() "#" formats when PY_SSIZE_T_CLEAN is not defined

2020-06-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 37bb2895561d3e63a631f10875567b4e33b30c07 by Victor Stinner in 
branch 'master':
bpo-40943: PY_SSIZE_T_CLEAN required for '#' formats (GH-20784)
https://github.com/python/cpython/commit/37bb2895561d3e63a631f10875567b4e33b30c07


--

___
Python tracker 

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



[issue41033] readline.c: SEGFAULT on SIGWINCH when loaded twice

2020-06-19 Thread daniel hahler


New submission from daniel hahler :

The following will crash due to the signal handler calling itself recursively:

```
import os, readline, signal, sys

del sys.modules["readline"]
import readline

os.kill(os.getpid(), signal.SIGWINCH)
```

This fixes it:
```
diff --git a/Modules/readline.c b/Modules/readline.c
index 081657fb23..174e0117a9 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -967,6 +967,7 @@ readline_sigwinch_handler(int signum)
 {
 sigwinch_received = 1;
 if (sigwinch_ohandler &&
+sigwinch_ohandler != readline_sigwinch_handler &&
 sigwinch_ohandler != SIG_IGN && sigwinch_ohandler != SIG_DFL)
 sigwinch_ohandler(signum);

```

It gets installed/saved in 
https://github.com/python/cpython/blob/01ece63d42b830df106948db0aefa6c1ba24416a/Modules/readline.c#L-L1112.

Maybe it could also not save it in the first place if it is itself / has been 
installed already.

Or, it could be uninstalled when the module is unloaded, if there is such a 
thing?

I've seen the crash initially in a more complex setup, where it is not really 
clear why/how the readline module gets initialized twice really, but the above 
appears to simulate the situation.
(Hints on where to break in gdb to see where/when a module gets unloaded would 
be appreciated)

Added in 
https://github.com/python/cpython/commit/5dbbf1abba89ef1766759fbc9d5a5af02db49505
 (3.5.2).

--
components: Extension Modules
messages: 371861
nosy: blueyed
priority: normal
severity: normal
status: open
title: readline.c: SEGFAULT on SIGWINCH when loaded twice
type: crash
versions: Python 3.10, 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



[issue40860] Exception in multiprocessing/context.py under load

2020-06-19 Thread Arkady


Arkady  added the comment:

There is a memory leak every time call to join() fails (is 
https://bugs.python.org/issue37788 relevant?)

--

___
Python tracker 

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



[issue41032] locale.setlocale example incorrect

2020-06-19 Thread MarcoBakera


New submission from MarcoBakera :

The example given results in an error.

https://docs.python.org/3.8/library/locale.html?highlight=locale

>>> locale.setlocale(locale.LC_ALL, 'de_DE')

I could be improved with one of the following versions:

>>> locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
>>> locale.setlocale(locale.LC_ALL, ('de_DE'), ('UTF-8'))

--
assignee: docs@python
components: Documentation
messages: 371860
nosy: docs@python, pintman
priority: normal
severity: normal
status: open
title: locale.setlocale example incorrect
type: enhancement
versions: 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



[issue41030] Provide toList() method on iterators/generators (`list()` is a flow killer in REPL)

2020-06-19 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

It would not work, an iterator is just a thing that has __next__() and 
__iter__():


class MyIterator:
def __iter__(self): return self
def __next__(self): return 1


Plenty of iterators would not have this method even if we added it to some of 
them in the standard library and you would be event more frustated that 
sometimes toList(), and sometimes doesn't.



If you need to move in the current line in the REPL you can use Ctrl-a and 
Ctrl-e and you can use Ctrl + arrow in a Jupyter Notebook.

--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue41030] Provide toList() method on iterators/generators (`list()` is a flow killer in REPL)

2020-06-19 Thread Julien H


Julien H  added the comment:

Hello Ammar Askar,

I agree `_` avoids the "up arrow" problem I mentioned in the REPL. 

I actually primarily use jupyter notebooks in my work.

Point 1. in my first message is the primary issue. Having to edit the line in 
two places to perform one action has driven me crazy over and over.

--

___
Python tracker 

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



[issue41030] Provide toList() method on iterators/generators (`list()` is a flow killer in REPL)

2020-06-19 Thread Julien H


Change by Julien H :


--
title: Provide toList() method on iterators (`list()` is a flow killer in REPL) 
-> Provide toList() method on iterators/generators (`list()` is a flow killer 
in REPL)

___
Python tracker 

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



[issue41031] Inconsistency in C and python traceback printers

2020-06-19 Thread Michael Simacek


New submission from Michael Simacek :

I belive the python traceback module was designed to produce the same output as 
the internal exception printer (sys.__excepthook__), but this is not the case 
when the exception's __str__ raises an exception.

Given an exception of the following class:
class E(Exception):
   def __str__(self):
  raise RuntimeError

Internal printer output:
Traceback (most recent call last):
  File "inconsistent.py", line 6, in 
raise E()
__main__.E: 

traceback.print_exc output:
Traceback (most recent call last):
  File "inconsistent.py", line 6, in 
raise E()
E: 

--
components: Library (Lib)
messages: 371855
nosy: msimacek
priority: normal
severity: normal
status: open
title: Inconsistency in C and python traceback printers
type: behavior
versions: Python 3.10

___
Python tracker 

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



[issue41030] Provide toList() method on iterators/generators (`list()` is a flow killer in REPL)

2020-06-19 Thread Ammar Askar


Ammar Askar  added the comment:

Julien, in the REPL "_" represents the last evaluated expression. So you can do:

>>> iter(range(10))

>>> list(_)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

Do you feel like that covers what you're asking for?

--
nosy: +ammar2

___
Python tracker 

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



[issue41030] Provide toList() method on iterators (`list()` is a flow killer in REPL)

2020-06-19 Thread Julien H


Change by Julien H :


--
components: +Library (Lib) -Demos and Tools
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



[issue41030] Provide toList() method on iterators (`list()` is a flow killer in REPL)

2020-06-19 Thread Julien Edmond René Harbulot

Julien Edmond René Harbulot  added the comment:

Consider how easy in the REPL it is to hit `up arrow` and then append code to 
the previously entered command, compared to having to move the cursor back in 
the command to edit it somewhere in the middle.

Simulated REPL session:

```
dir.iterdir()
> 

 .toList()
> [Path(...), Path(...)]
```

--

___
Python tracker 

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



[issue41026] mailbox does not support new Path object

2020-06-19 Thread Laurence

Laurence  added the comment:

Hi Rémi,

I understand why it is the case, I just thought it would be a nice enhancement 
and quick win to add the support.

RE "you should use os.fspath() instead of str()": I'm following in the pathlib 
docuementation (https://docs.python.org/3/library/pathlib.html):

> The string representation of a path is the raw filesystem path itself (in 
> native form, e.g. with backslashes under Windows), which you can pass to any 
> function taking a file path as a string:
> >>>
> >>> p = PurePath('/etc')
> >>> str(p)
> '/etc'
> >>> p = PureWindowsPath('c:/Program Files')
> >>> str(p)
> 'c:\\Program Files'

Is the pathlib documentation wrong/out-of-date?  I Googled your suggestion of 
`os.fspath` and found  which reads 
like the pathlib docs need correcting?

I'm trying to setup a build environment to create a PR for this issue as I 
type...

Thanks,

Laurence

--

___
Python tracker 

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



[issue41030] Provide toList() method on iterators (`list()` is a flow killer in REPL)

2020-06-19 Thread Julien Edmond René Harbulot

New submission from Julien Edmond René Harbulot :

I work with python in the REPL or jupyter notebooks for my data science work 
and often find myself needing to explore data structures or directories on disk.

So I'll access these data structure in a linear "go-forward" fashion using the 
dot, for instance:

```
root_directory = pathlib.Path(...)
root_directory.iterdir()[0].iterdir()
```

Which of course doesn't work because iterdir() provides an iterator instead of 
a list (I understand this is good for performance, but how annoying for 
interactive sessions!)

The problem with the current API is that:

1. I have to go back to my code and edit in several places to convert the 
iterators to lists. With the currrent way (i.e. `list( ... )`) I have to edit 
before the iterator to add `list(` and then after to add `)`. When my 
one-liners become complex, this is very tedious because I have to perform 
extensive search to find where to insert the `list(` part. Having a method 
`.toList()` would allow to edit the expression in a *single* place instead, and 
is also much easier to read in my opinion:

```
root_directory.iterdir().toList()[0].iterdir().toList()
```

instead of:

```
list(list(root_directory.iterdir())[0].iterdir())
```

2. I want to think about my work, the business task at hand. Not about the 
particularities of python iterators. Having to specify `list(` first, forces me 
to think about the language. This gets in my way. The possiblity to use 
`.toList()` at the end of an expression allows the conversion to happen as an 
afterthought. In particular in REPL or notebooks where I'll often write:

```
directory.iterdir()
```

And the repl will display 

```

```

How easy would it be if I could just *append* to my code instead of surgically 
edit before and after.

--
components: Demos and Tools
messages: 371852
nosy: Julien Edmond René Harbulot
priority: normal
severity: normal
status: open
title: Provide toList() method on iterators (`list()` is a flow killer in REPL)
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



[issue41021] ctypes callback with structure crashes in Python 3.8 on Windows x86

2020-06-19 Thread Aravindhan


Change by Aravindhan :


--
title: ctypes callback with structure crashes in Python 3.8 on Windows -> 
ctypes callback with structure crashes in Python 3.8 on Windows x86

___
Python tracker 

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



[issue41021] ctypes callback with structure crashes in Python 3.8 on Windows

2020-06-19 Thread Aravindhan


Aravindhan  added the comment:

Hi, Thanks for response @eryksun

Sorry that I did not mention it is compiled for x86 and the crash happens in 
32bit python. Yes, the dll is declared with stdcall and built for x86 with 
MSVC. It is tested with python 3.7.4 32bit which is successful and fails on 
python 3.8.2 32bit. I did not look into on x64 though. Below is the source 
code. I have also attached them as a zip.

>>> c/DummyCb.h

#pragma once
#include 
#include 

#define CALLBACK__stdcall
#define WINAPI  __stdcall

#define EXFUNC(type) _declspec(dllexport) void WINAPI // export function
#define CBFUNC(type,func) typedef void (CALLBACK* func) // callback function

extern "C" CBFUNC(void, listen_cb)(int value, FILETIME ts );
extern "C" EXFUNC(void) subscribe_cb(listen_cb);


>>> c/DummyCb.cpp

#include "pch.h"
#include "DummyCb.h"
#include 

EXFUNC(void) subscribe_cb(listen_cb cb)
{

int i = 0;
while (true) {
FILETIME systime;
GetSystemTimeAsFileTime();
i++;
Sleep(1000);
cb(i, systime);
   }
}


>>> c/CbClient.cpp

#include 
#include "DummyCb.h"
#include 
#include 

void __stdcall lis(int a, FILETIME ts) {

printf("calling back %d, %d, %d \n", a,ts.dwHighDateTime, 
ts.dwLowDateTime);
}


int main()
{
subscribe_cb();
}



>>> CbClient.py


from ctypes import *
from time import sleep


class FT(Structure):
_fields_ = [("dwLowDateTime", c_ulong, 32),
("dwHighDateTime", c_ulong, 32)]


@WINFUNCTYPE(c_void_p, c_int, FT)
def cb(val, ft):
print(f"callback {val} {ft.dwLowDateTime} {ft.dwHighDateTime}")


lib = WinDLL(r"c/DummyCb.dll")

lib.subscribe_cb(cb)

while 1:
sleep(5)


>>> Traceback on python 

lib.subscribe_cb(cb)
OSError: exception: access violation writing 0xCA35789B


>>> Native Debug traceback

Run-Time Check Failure #0 - The value of ESP was not properly saved across a 
function call. This is usually a result of calling a function declared with one 
calling convention with a function pointer declared with a different calling 
convention. 

>>> Further analysis

change the callback declaration to a pointer of structure and it has same crash 
on python 3.7 32 bit. 

@WINFUNCTYPE(c_void_p, c_int, POINTER(FT))
def cb(val, ft):
print(f"callback {val} {ft.contents}")

Which makes me correlate is it something to do with vector calling on python 
3.8 which makes callabck as *cb (a pointer) instead of a plain object call 
(just a thought, did not investigate change logs). Though its interesting to 
note that it did not fail on x64 with cdecl calling convention. That explains 
why our larger code base din't crash on Linux x86 linked as a .SO .


cheers.

--
Added file: https://bugs.python.org/file49253/callback.zip

___
Python tracker 

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



  1   2   >