[issue43098] tarfile list() method does not show file type

2021-02-01 Thread Val Shkolnikov


New submission from Val Shkolnikov :

The list() method of TarFile tarfile object shows question mark in place of 
file type in verbose mode. For instance
python3 -m tarfile -v -l my.tar
?rwxr-xr-x vals/users  0 2021-01-16 18:28:30 bin/
?rwxr-x--- vals/users266 2021-01-16 18:28:30 bin/backmine.sh
?rwxr-xr-x vals/users950 2018-01-02 10:39:18 bin/tm.sh
?rwxrwxrwx vals/users  0 2021-01-16 11:49:36 bin/source-highlight -> 
../source-highlight/bin/source-highlight
?rwxr-xr-x vals/users435 2011-03-27 15:38:06 bin/dd.sh

This is because the call stat.filemode(tarinfo.mode) does not pass tarinfo.type 
to stat.filemode. The type needs to be properly encoded and added to the 
argument.

My patch is attached. Verified under Linux, Cygwin and Windows.

--
files: patch
messages: 386129
nosy: val.shkolnikov
priority: normal
severity: normal
status: open
title: tarfile list() method does not show file type
type: behavior
versions: Python 3.7, Python 3.8
Added file: https://bugs.python.org/file49786/patch

___
Python tracker 

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



[issue43097] IndexError msg of random.choice() not helpful

2021-02-01 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +mark.dickinson, rhettinger

___
Python tracker 

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



[issue43097] IndexError msg of random.choice() not helpful

2021-02-01 Thread wyz23x2


New submission from wyz23x2 :

When you apply `random.choice` on empty sequences:
>>> import random
>>> random.choice([])
Traceback (most recent call last):
  File "", line 2, in 
return seq[self._randbelow(len(seq))]
IndexError: list index out of range
This message doesn't clearly state the real problem -- an empty seq.
Meanwhile, many other methods give messages.
>>> [].pop()
Traceback (most recent call last):
  File "", line 3, in 
IndexError: pop from empty list
>>> import collections
>>> collections.deque().popleft()
Traceback (most recent call last):
  File "", line 5, in 
IndexError: pop from an empty deque
>>> random.randrange(0, 0)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Program Files\Python39\lib\random.py", line 316, in randrange
raise ValueError("empty range for randrange() (%d, %d, %d)" % (istart, 
istop, width))
ValueError: empty range for randrange() (0, 0, 0)

P.S. Both are empty sequences/ranges, randrange() raises ValueError, while 
choice() raises IndexError.

--
components: Library (Lib)
messages: 386128
nosy: wyz23x2
priority: normal
severity: normal
status: open
title: IndexError msg of random.choice() not helpful
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



[issue43048] Printing RecursionError results in RecursionError

2021-02-01 Thread Vladimir Feinberg

Vladimir Feinberg  added the comment:

Oh, yes, I suppose, that'll truncate to just the first TracebackException.

On Mon, Feb 1, 2021 at 4:38 PM Irit Katriel  wrote:

>
> Irit Katriel  added the comment:
>
> I meant to catch the exception in the constructor’s recursive call, and if
> necessary then the same again in format (if there are more function calls
> per exception in format, it will be necessary. The unit test from the 3.10
> patch will tell).
>
> Would that not work?
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



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

2021-02-01 Thread Guido van Rossum


Guido van Rossum  added the comment:

I still favor (3) -- I don't want to renege on the promise we made when we
allowed overloading comparisons to return something other than a bool.

--

___
Python tracker 

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



[issue43048] Printing RecursionError results in RecursionError

2021-02-01 Thread Irit Katriel

Irit Katriel  added the comment:

I meant to catch the exception in the constructor’s recursive call, and if 
necessary then the same again in format (if there are more function calls per 
exception in format, it will be necessary. The unit test from the 3.10 patch 
will tell).

Would that not work?

--

___
Python tracker 

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



[issue38302] [3.10] __pow__ and __rpow__ are not reached when __ipow__ returns NotImplemented for **=

2021-02-01 Thread Brett Cannon


Brett Cannon  added the comment:

I'm totally fine with pushing this until b1 since this has been broken for  
ages.

--

___
Python tracker 

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



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

2021-02-01 Thread Mark Shannon


Change by Mark Shannon :


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



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

2021-02-01 Thread Mark Shannon


Mark Shannon  added the comment:

The differences between allowing the optimiser to remove truly redundant (in 
terms of control flow) boolean tests, or not, is slight.
It only matters for __bool__() calls that have side effects. Like __hash__(), 
__bool__() should not produce side effects.


There are three options, each with their own issues.

1. Freely remove redundant boolean checks, which means that

b = B()
try:
if b: pass
except:
print("This won't happen, but it used to")

will not print anything.

2. Don't remove redundant boolean checks, which prevents optimizations to 
remove repeated checks in short-circuiting operators, and would be a regression 
in terms of efficiency.

3. Attempt some sort of complex compromise. This is hard to get right, 
especially once the optimizer has started to transform the code.
It is also likely to produce inconsistencies, in that `True or b` might behave 
differently from `b or True`. Both are true, but one might raise an exception, 
whereas the other might not.


I favour option 1. It is already implemented. It is consistent both with 
itself, and with optimizations up to 3.9.
PEP 626 means that it will generally only be applied to short-circuiting 
operators and will not eliminate entire lines.


Note:

b = B()
try:
if b: 
 pass
except:
print("This will still happen")

Will print, as PEP 626 requires the execution of the pass statement to be 
observable, as it is on a line by itself. Consequently the test must be 
performed.

Given that this is quite obscure, I don't think it is a problem to release an 
alpha with this unresolved.
I would like to resolve it before beta.

--

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread twoone3


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

Thank you for solving my problem

--

___
Python tracker 

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



[issue42634] Incorrect line number in bytecode for try-except-finally

2021-02-01 Thread Mark Shannon


Mark Shannon  added the comment:

Sorry. I forgot the close the issue when it was fixed.

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



[issue43094] sqlite3.create_function takes parameter named narg, not num_params

2021-02-01 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


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



[issue43094] sqlite3.create_function takes parameter named narg, not num_params

2021-02-01 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

There's also a discrepancy between the docs and the signature for 
create_aggregate():

https://docs.python.org/3.9/library/sqlite3.html#sqlite3.Connection.create_aggregate

create_aggregate(name, num_params, aggregate_class)

The second parameter is named n_arg, here with an underscore.

I'm not sure what's the best fix; fixing the docs or the signatures. If we fix 
the signatures, we'll at least get a kind of consistency.

--
nosy: +berker.peksag, erlendaasland

___
Python tracker 

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



[issue38078] IDLE: Don't run internal code in user namespace.

2021-02-01 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Zachery, thank you for the PR to test.  It turns out that the proposed change 
is more dangerous the the possible error it prevent.  I could have easily 
missed the problem (not setting __file__, see PR).

Before considering this again, I need to list ways to run user code with Python 
and what envivonment (cwd, path, dir() results.  Then see what IDLE does in 
corresponding situations.

--
resolution:  -> rejected
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



[issue42464] Pathlib resolve() resolves non-existent ".." components with strict=False

2021-02-01 Thread Eryk Sun


Eryk Sun  added the comment:

I'd prefer to leave ".." in the path, at least with PosixPath. (It doesn't 
matter with WindowsPath.) The "there" component may be a symlink that's 
currently inaccessible. That said, Python's os.path.realpath() has a long 
history of naively resolving ".." components in the remainder.

--
nosy: +eryksun

___
Python tracker 

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



[issue43095] Windows does not raise IsADirectoryError

2021-02-01 Thread Eryk Sun


Eryk Sun  added the comment:

When an open attempts to access a directory as data, the error code from WinAPI 
CreateFileW is ERROR_ACCESS_DENIED (5), which maps to C EACCES and thus raises 
Python PermissionError. 

Python's io.FileIO() type could handle an EACCES error in Windows by checking 
for a directory. There's a race condition to consider in which an inaccessible 
file is replaced by a directory, but that seems to be a trivial concern.

io.FileIO() could also use the undocumented _O_OBTAIN_DIR (0x2000) open flag. 
This opens with backup semantics, which allows opening directories. Then, as 
already implemented in POSIX, fail with EISDIR if a directory is opened. For 
example:

>>> fd = os.open('C:/Temp', 0x2000)
>>> stat.S_ISDIR(os.fstat(fd).st_mode)
True

--
components: +IO
nosy: +eryksun
type:  -> behavior

___
Python tracker 

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



[issue42634] Incorrect line number in bytecode for try-except-finally

2021-02-01 Thread Ned Batchelder


Ned Batchelder  added the comment:

This problem no longer appears with master (commit 9eb11a139f).

--

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-02-01 Thread Ezio Melotti


Ezio Melotti  added the comment:

Merged! Thanks for the report and the PR!

--
assignee:  -> ezio.melotti
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



[issue43096] Adding `read_into` method to `asyncio.StreamReader`

2021-02-01 Thread jakirkham


New submission from jakirkham :

To allow reading into a provided buffer without copying, it would be useful to 
have a `read_into` method on `asyncio.StreamReader`, which takes a buffer 
supporting the buffer protocol and fills it.

--
components: asyncio
messages: 386114
nosy: asvetlov, jakirkham, yselivanov
priority: normal
severity: normal
status: open
title: Adding `read_into` method to `asyncio.StreamReader`
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



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

2021-02-01 Thread Paul Moore


Paul Moore  added the comment:

I'm not sure why, but the PR to update the bundled pip to 21.0.1 (and 
setuptools to 52.0.0) merged cleanly, so this may be obsolete now.

--

___
Python tracker 

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



[issue43064] Cannot clear signal handler set with loop.add_signal_handler in forked process with signal.signal

2021-02-01 Thread Selim Belhaouane


Selim Belhaouane  added the comment:

Playing with this a bit more, I found a weird workaround. By adding the 
following to the top of worker_sync(), Experiment 1 produces the expected 
result.

def worker_sync():
async def clear_asyncio_signal_handlers():
loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, signal.SIG_IGN)
asyncio.run(clear_asyncio_signal_handlers())

if WORKER_SIGNAL_HANDLER is WorkerSignalHandler.NONE:
[...]

FYI, this did *not* work (the outcome is still the same for Experiment 1):

def worker_sync():
loop = asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT, signal.SIG_IGN)

if WORKER_SIGNAL_HANDLER is WorkerSignalHandler.NONE:
[...]


Maybe this all can be flagged as "as designed". However, perhaps it could be 
documented?

--

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-02-01 Thread miss-islington


miss-islington  added the comment:


New changeset 0874491bcc392f7bd9c394ec2fdab183e3f320dd by Miss Islington (bot) 
in branch '3.9':
bpo-41748: Handles unquoted attributes with commas (GH-24072)
https://github.com/python/cpython/commit/0874491bcc392f7bd9c394ec2fdab183e3f320dd


--

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-02-01 Thread miss-islington


miss-islington  added the comment:


New changeset 0869a713f21f4b2fe021d802cf18f1b1af53695f by Miss Islington (bot) 
in branch '3.8':
bpo-41748: Handles unquoted attributes with commas (GH-24072)
https://github.com/python/cpython/commit/0869a713f21f4b2fe021d802cf18f1b1af53695f


--

___
Python tracker 

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



[issue26455] Inconsistent behavior with KeyboardInterrupt and asyncio futures

2021-02-01 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-02-01 Thread STINNER Victor


STINNER Victor  added the comment:

Oh, thank you Karl Dubost for the fix!

--

___
Python tracker 

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



[issue38302] [3.10] __pow__ and __rpow__ are not reached when __ipow__ returns NotImplemented for **=

2021-02-01 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Friendly reminder that this issue is currently blocking the 3.10a5 release. If 
you are ok with waiting for the next release to include the fix, please say so 
here or drop me an email/

--
nosy: +pablogsal

___
Python tracker 

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



[issue42634] Incorrect line number in bytecode for try-except-finally

2021-02-01 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Friendly reminder that this issue is currently blocking the 3.10a5 release. If 
you are ok with waiting for the next release to include the fix, please say so 
here or drop me an email/

--
nosy: +pablogsal

___
Python tracker 

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



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

2021-02-01 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Friendly reminder that this issue is currently blocking the 3.10a5 release. If 
you are ok with waiting for the next release to include the fix, please say so 
here or drop me an email/

--

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread Eryk Sun


Eryk Sun  added the comment:

I assume you're linking to the CRT dynamically, which is shared with 
"python39.dll", which means you're sharing the configured locale with Python. 
Since you're not using an isolated configuration, the LC_CTYPE locale will be 
set to the current user's default locale (configured in "HKCU\Control 
Panel\International"). 

If the STDOUT low I/O file is in ANSI text mode, and the LC_CTYPE locale is not 
the default "C" locale, and it's a console file, then C write() does a double 
translated write. First, the UTF-8 byte string is decoded to wide-character 
UTF-16 using the current LC_CTYPE locale encoding. Then the wide-character 
string is encoded back to a byte string using the console output code page. The 
first step leads to mojibake if the locale encoding isn't UTF-8.

At a minimum, you'll need to add `cfg.configure_locale = 0` in order to prevent 
Python from configuring the LC_CTYPE locale to the default user locale. 

That said, your code should be written to work in locales other than the 
default "C" locale. For the past few years, Windows ucrt has supported UTF-8 as 
a locale encoding, such as via setlocale(LC_CTYPE, ".utf8"). Alternatively, or 
in addition to the latter, you can use std::wcout with wide-character strings 
and switch stdout to UTF-8 Unicode mode via _setmode(_fileno(stdout), 
_O_U8TEXT). In this case, the CRT writes to the console via putwch(), which 
calls the wide-character WinAPI function WriteConsoleW(). If your code uses 
UTF-8 byte strings, you'll have to decode them to UTF-16 wide-character strings 
before writing to stdout.

--
nosy: +eryksun

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-02-01 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23231
pull_request: https://github.com/python/cpython/pull/24416

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-02-01 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +23230
pull_request: https://github.com/python/cpython/pull/24415

___
Python tracker 

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



[issue41748] HTMLParser: comma in attribute values with/without space

2021-02-01 Thread Ezio Melotti


Ezio Melotti  added the comment:


New changeset 9eb11a139fac5514d8456626806a68b3e3b7eafb by Karl Dubost in branch 
'master':
bpo-41748: Handles unquoted attributes with commas (#24072)
https://github.com/python/cpython/commit/9eb11a139fac5514d8456626806a68b3e3b7eafb


--

___
Python tracker 

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



[issue43095] Windows does not raise IsADirectoryError

2021-02-01 Thread Jairo Llopis


New submission from Jairo Llopis :

Trying to read a directory on Linux raises the expected exception:

Python 3.9.1 (default, Jan 20 2021, 00:00:00) 
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> pathlib.Path(".venv").read_text()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib64/python3.9/pathlib.py", line 1255, in read_text
with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib64/python3.9/pathlib.py", line 1241, in open
return io.open(self, mode, buffering, encoding, errors, newline,
IsADirectoryError: [Errno 21] Is a directory: '.venv'


Doing the same on Windows raises a misleading permission error instead:

>>> import pathlib
>>> pathlib.Path(".venv").read_text()
Traceback (most recent call last):   
  File "", line 1, in 
  File "C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\pathlib.py",
 line 1255, in read_text
with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\pathlib.py",
 line 1241, in open
return io.open(self, mode, buffering, encoding, errors, newline,
  File "C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.496.0_x64__qbz5n2kfra8p0\lib\pathlib.py",
 line 1109, in _opener
return self._accessor.open(self, flags, mode)
PermissionError: [Errno 13] Permission denied: '.venv'

--
components: Windows
messages: 386103
nosy: Jairo Llopis, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Windows does not raise IsADirectoryError
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



[issue43088] Regression in math.hypot

2021-02-01 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



[issue40042] Enum Flag: psuedo-members have None for name attribute

2021-02-01 Thread Ethan Furman


Ethan Furman  added the comment:

This issue is fixed in #38250.

--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed
superseder:  -> enum.Flag should be more set-like

___
Python tracker 

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



[issue42727] [Enum] EnumMeta.__prepare__ needs to accept **kwds

2021-02-01 Thread Ethan Furman


Change by Ethan Furman :


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



[issue35815] Able to instantiate a subclass with abstract methods from __init_subclass__ of the ABC

2021-02-01 Thread Ethan Furman


Ethan Furman  added the comment:

That patch was rejected in favor of updating Enum to use `__set_name__` to do 
the final creation of enum members.

The same thing could be done for ABC, but I lack the C skills to make it happen.

--

___
Python tracker 

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



[issue35815] Able to instantiate a subclass with abstract methods from __init_subclass__ of the ABC

2021-02-01 Thread Ethan Furman


Change by Ethan Furman :


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

___
Python tracker 

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



[issue43094] sqlite3.create_function takes parameter named narg, not num_params

2021-02-01 Thread Nicholas Chammas


New submission from Nicholas Chammas :

The doc for sqlite3.create_function shows the signature as follows:

https://docs.python.org/3.9/library/sqlite3.html#sqlite3.Connection.create_function

```
create_function(name, num_params, func, *, deterministic=False)
```

But it appears that the parameter name is `narg`, not `num_params`. Trying 
`num_params` yields:

```
TypeError: function missing required argument 'narg' (pos 2)
```

--
assignee: docs@python
components: Documentation
messages: 386100
nosy: docs@python, nchammas
priority: normal
severity: normal
status: open
title: sqlite3.create_function takes parameter named narg, not num_params
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



[issue35815] Able to instantiate a subclass with abstract methods from __init_subclass__ of the ABC

2021-02-01 Thread Ethan Furman


Ethan Furman  added the comment:

That patch was reject in favor of updating Enum to use `__set_name__` to do the 
final creation of enum members.

The same thing could be done for ABC, but I lack the C skills to make it happen.

--
assignee: ethan.furman -> 
superseder: __init_subclass__ should be called in __init__ -> 
versions: +Python 3.10 -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



[issue42911] Addition chains for pow saves 5-20% time for pow(int, int)

2021-02-01 Thread Mark Dickinson


Mark Dickinson  added the comment:

Looks like Tim isn't taking the bait. :-)

@Jurjen: Thank you for the suggestion and PR, but I'm going to close here; for 
me this ends up on the wrong side of the performance / complexity trade-off.

--
resolution:  -> rejected
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



[issue43063] zipfile.Path / importlib.resources raises KeyError if a file wasn't found

2021-02-01 Thread Emmanuel Arias


Change by Emmanuel Arias :


--
nosy: +eamanu

___
Python tracker 

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



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

2021-02-01 Thread Steve Dower


Steve Dower  added the comment:

On Windows it should only affect non-exported functions. Comparing "dumpbin 
/exports" output will tell you whether anything has changed there.

The bigger concern is if it merges identical functions that are compared by 
function pointer. I know we've had issues with that in the past, and I forget 
how we've dealt with that. I thought OPT:REF would do this optimisation too 
(though ISTR it's known as COMDAT folding and may have its own option).

--

___
Python tracker 

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



[issue43093] Make modules picklable

2021-02-01 Thread Arusekk


Arusekk  added the comment:

Sorry, I forgot to state what is my actual goal: for the module objects to be 
pickleable in native CPython (possibly from C layer) without the need to add 
this to every code that wants to pickle module objects.

The point is that they can already be unpickled from the representation 
generated by the code, so it should only be necessary to implement __reduce__ 
in moduleobject.c, and probably to change the object's qualname / module 
attributes. Or to introduce a helper function, like PyPy did, for the fake 
module case; I just found supporting existing unpickling paths more elegant 
(and working across all Python versions since 2.0.0), as much as unelegant is 
the monkey-patching done in my example. It is possible that (for the actual 
module case) _compat_pickle.REVERSE_IMPORT_MAPPING should be considered as well 
for the old protocols (which would probably imply using __reduce_ex__ instead), 
but I did not explore that.

--

___
Python tracker 

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



[issue42464] Pathlib resolve() resolves non-existent ".." components with strict=False

2021-02-01 Thread Emmanuel Arias


Emmanuel Arias  added the comment:

Hi, 

I don't understand the point here. If you go back on a folder
'..', IMO has more sense remove the '..', that is a way to 
resolve it

--
nosy: +eamanu

___
Python tracker 

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



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

2021-02-01 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Mark, what is the status of this issue? This is marked as a release blocker so 
I would prefer not to release the next alpha with this being unfixed.

--

___
Python tracker 

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



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

2021-02-01 Thread Austin Lamb


Austin Lamb  added the comment:

Ping - can anyone suggest either how ctypes does its exporting, or suggest 
tests I could run to confirm if this change affects python code?  The entire 
test suite in the repo passes.

--

___
Python tracker 

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



[issue43053] Speed up math.isqrt, again

2021-02-01 Thread Mark Dickinson


Mark Dickinson  added the comment:

> Java's implementation of BigInteger.sqrt can't do that. :-)

Well, okay, depending on your definition of "a few", actually it can, but 
Python is still faster.

--

___
Python tracker 

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



[issue43074] Unable to use system proxy with HTTPS connection on Windows

2021-02-01 Thread Steve Dower


Steve Dower  added the comment:

requests is a third-party library that has no obligation to use urllib's 
functionality.

If you can show the same behaviour with urllib alone, we can treat it as an 
issue here. Otherwise, you'll need to report it to requests.

--

___
Python tracker 

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



[issue43093] Make modules picklable

2021-02-01 Thread Arusekk


New submission from Arusekk :

Currently pickling functions and types stores modules by their name.

So I believe it is possible to support pickling module objects with the 
following code (based on the logic in PyPy, which supports pickling modules):


import copyreg
import types
import pickle
import sys

def picklemod(mod):
if mod.__name__ in sys.modules:  # real modules
return (__import__, (mod.__name__, None, None, ('',)))

# module objects created manually:
return (types.ModuleType, (mod.__name__,), mod.__dict__)
copyreg.pickle(types.ModuleType, picklemod)

pickle.loads(pickle.dumps(sys))  # works
import http.server
pickle.loads(pickle.dumps(http.server))  # works for nested modules

fakemod = types.ModuleType('fakemod')
fakemod.field1 = 'whatever'

# This fake type is used instead of types.ModuleType in order to re-confuse 
pickle back on track.
# Should not have been necessary in the first place,
# but types.ModuleType has misconfigured fields according to pickle
# (and they are read-only).
class _types_ModuleType(types.ModuleType):
__module__ = 'types'
__name__ = __qualname__ = 'ModuleType'

_orig_types_ModuleType = types.ModuleType
# bad monkey-patching, but needed for the confusion to work
types.ModuleType = _types_ModuleType
dump = pickle.dumps(fakemod)
# not necessary, but to show unpickling is regardless correct
types.ModuleType = _orig_types_ModuleType

pickle.loads(dump).field1  # works


Disclaimer: I do not see any specific use for this, I was just surprised while 
trying to port snakeoil library to PyPy, which (snakeoil) uses sys module as an 
example of an unpicklable object (they should switch to a traceback for 
instance, but that is not the scope of this issue).

--
components: Library (Lib)
messages: 386090
nosy: Arusekk
priority: normal
severity: normal
status: open
title: Make modules picklable
type: enhancement

___
Python tracker 

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



[issue43053] Speed up math.isqrt, again

2021-02-01 Thread Mark Dickinson


Change by Mark Dickinson :


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

___
Python tracker 

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



[issue43053] Speed up math.isqrt, again

2021-02-01 Thread Mark Dickinson


Mark Dickinson  added the comment:

> the complication probably amounts to no more than 10-20 extra lines of C code

A net difference of 16 lines of code, as it turns out. The branch is here: 
https://github.com/mdickinson/cpython/tree/isqrt-performance

Informal not-very-scientific timings more-or-less confirm what I expected: I 
_do_ get a speedup approaching a factor of 2 for huge n: getting a million 
digits of sqrt(2) via `n = 2*10**10**6; x = isqrt(n)` takes around 9 seconds on 
master and 5 seconds with this branch, on my machine. But for values with 20 
digits or so, the overhead of the extra operations means that the algorithm is 
around 20% slower. The cutoff for me seems to be somewhere between 200 and 1000 
digits.

So I'm afraid I'm going to leave this as is: if speed were all we cared about 
then there are all sorts of things we could try, but I'd rather keep the 
simplicity. And it's nice that it's still *possible* to compute a million 
digits of sqrt(2) in a few seconds. Java's implementation of BigInteger.sqrt 
can't do that. :-)

--

___
Python tracker 

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



[issue26455] Inconsistent behavior with KeyboardInterrupt and asyncio futures

2021-02-01 Thread Guido van Rossum


Guido van Rossum  added the comment:

If you just need help, I recommend https://discuss.python.org/c/users/7

If you still have an issue with ^C, open a new issue.

--

___
Python tracker 

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



[issue26455] Inconsistent behavior with KeyboardInterrupt and asyncio futures

2021-02-01 Thread Matej Volf


Matej Volf  added the comment:

python/asyncio is archived now and there is no definitive resolution, nor a 
concrete workaround in that thread. has this progressed elsewhere? or is it 
still unresolved?

could anyone please show sample workaround code? (i need to call some cleanup 
code which still runs in the context of the event loop)

---

also, I was unable to login to this bug tracker with GitHub, because my name 
contains non-ascii characters. where should I report that :D ?

--
nosy: +mvolfik

___
Python tracker 

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



[issue43085] Loosening | and |= operator type checking restriction

2021-02-01 Thread Brandt Bucher


Brandt Bucher  added the comment:

Any class that registers itself as a Mapping/MutableMapping using their 
"register" methods (*not* through inheritance) will be lacking the new methods. 
This includes all C extensions.

Further, binary "|" would require subclasses of these ABCs to have a concrete 
way of creating a new instance (we don't have anything like Set._from_iterable 
for this). One option could be to just call self.__class__({**self, **other}), 
but a cursory scan of the stdlib shows that many classes don't have compatible 
signatures, and the we would get lots of surprising/broken behavior if we just 
suddenly introduced this.

--

___
Python tracker 

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



[issue38307] Add .end_lineno attribute to pyclbr _Objects

2021-02-01 Thread Terry J. Reedy


Terry J. Reedy  added the comment:


New changeset 000cde59847beaf5fa7b73633e1f3c898fe5bf90 by Aviral Srivastava in 
branch 'master':
bpo-38307: Add end_lineno attribute to pyclbr Objects (GH-24348)
https://github.com/python/cpython/commit/000cde59847beaf5fa7b73633e1f3c898fe5bf90


--

___
Python tracker 

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



[issue43085] Loosening | and |= operator type checking restriction

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

Vedran Čačić  added the comment:

@Raymond: why can't ABCs have _default_ implementation of | and |=, in terms of 
other supported methods (such as update)? It seems to me this would be the best 
of both worlds.

--
nosy: +veky

___
Python tracker 

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



[issue43085] Loosening | and |= operator type checking restriction

2021-02-01 Thread Brandt Bucher


Brandt Bucher  added the comment:

Yurii, I agree with Raymond that it's probably not worth adding new ABCs for 
this.

I'm happy to consider patches that add these operators to concrete stdlib 
mappings on a case-by-case basis. However, please be aware that we already went 
through a fairly comprehensive review of each dict/Mapping/MutableMapping 
subclass (real or virtual) in the entire stdlib to see if they would benefit 
here. I don't think we bothered updating *any* classes that weren't publicly 
documented, which is probably why "SignalDict" was left untouched.

It's also important to remember that the motivating use-case for PEP 584 was 
binary "|", and that "|=" just logically followed from that change. In this 
specific case, I think just using the good ol' update method (or even item 
assignment) is probably good enough.

I'm not very familiar with how SignalDict is used, though: do we ever actually 
want to create a new updated copy using binary "|"? That would probably be 
enough to convince me.

--
components: +Library (Lib) -Regular Expressions
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



[issue43048] Printing RecursionError results in RecursionError

2021-02-01 Thread Vladimir Feinberg


Vladimir Feinberg  added the comment:

A simple catch may not work (the very first TracebackException is the one
that gets the RecursionError during initialization of its __context__), but
one thing I was thinking about was walking the __context__ pointers and
nulling out anything past the sys.getrecursionlimit() with a warning.

On Sat, Jan 30, 2021 at 10:00 AM Irit Katriel 
wrote:

>
> Change by Irit Katriel :
>
>
> --
> keywords: +easy
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue42834] [subinterpreters] Convert "global" static variable caches in _json to heap variables

2021-02-01 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



[issue42834] [subinterpreters] Convert "global" static variable caches in _json to heap variables

2021-02-01 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset b5931f1d9f1f9f907e5cb6e193154672f78c1225 by Ken Jin in branch 
'master':
bpo-42834: Fix _json internal caches for subinterpreters (GH-24121)
https://github.com/python/cpython/commit/b5931f1d9f1f9f907e5cb6e193154672f78c1225


--

___
Python tracker 

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



[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-02-01 Thread hai shi


hai shi  added the comment:

I found `type.__name__` has the implementation details in 
https://github.com/python/cpython/blob/master/Objects/typeobject.c#L486. 
IMHO, keep the consistency in `PyType_GetName()` is OK.

Victor, Petr. Do you think it make senses?

--

___
Python tracker 

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



[issue43092] Python installation fails to install pip3 if pip, setuptools in ~/.local

2021-02-01 Thread Daniel Colascione


New submission from Daniel Colascione :

The ensurepip module in the Python distribution bootstraps the pip package 
manager. The Python build system runs this module during installation so that 
the resulting Python installation is ready to install packages. Right now, the 
pip command that ensurepip installs the pip and setuptools packages only if it 
doesn't find them installed already. The problem is that the pip run by 
ensurepip checks for its bootstrap packages in ~/.local, and if it finds them 
there, it concludes it doesn't need to install these packages as part of 
bootstrap. But in various situations (e.g., installing Python into an isolated 
environment), these packages need to be installed anyway.

ensurepip should ignore packages in ~/.local, at least when as part of the 
Python build system

--
components: Installation
messages: 386079
nosy: quotemstr
priority: normal
severity: normal
status: open
title: Python installation fails to install pip3 if pip, setuptools in ~/.local
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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread twoone3


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

when i use python 3.6.5
There won't be this problem

--

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread Christian Heimes


Christian Heimes  added the comment:

It's not a Python problem. The Python configuration API only configures 
Python's input/output API to UTF-8 mode. It does not affect the C++ 
input/output cout API.

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread twoone3


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

Look it!
It's really Python's problem

--
Added file: https://bugs.python.org/file49785/389e661314157b8f.jpg

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread STINNER Victor

STINNER Victor  added the comment:

PyPreConfig.utf8_mode=1 enables the *Python* UTF-8 Mode:
* 
https://docs.python.org/dev/c-api/init_config.html?highlight=pypreconfig_initpythonconfig#c.PyPreConfig.utf8_mode
* https://docs.python.org/dev/library/os.html#utf8-mode

> then i 'cout << u8"Chinese中文" << endl;

This is C++. C++ is not aware of the Python UTF-8 Mode.

You misunderstood the purpose of the Python UTF-8 Mode.

std::cout must be configured differently. This is not a Python problem. I 
suggest to close the issue.

--
nosy: +vstinner

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread twoone3


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

This is out put

--
Added file: https://bugs.python.org/file49784/Screenshot_2021_0201_225300.png

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread twoone3

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

After I changed it to 1, the console code remained unchanged.
I use' chcp 65001' first.
then i use PyPreConfig and Py_initialize
then i 'cout << u8"Chinese中文" << endl;
It is not utf-8.

--

___
Python tracker 

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



[issue43085] Loosening | and |= operator type checking restriction

2021-02-01 Thread Yurii Karabas


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


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

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread Christian Heimes


Christian Heimes  added the comment:

"utf8_mode = -1" falls back to command line, env vars, locales, and eventually 
disables UTF-8 mode. Try "cfg.utf8_mode = 1" as documented at 
https://docs.python.org/3/c-api/init_config.html?highlight=pypreconfig_initpythonconfig#c.Py_PreInitializeFromArgs

--

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread twoone3


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

PyPreConfig cfg;
PyPreConfig_InitPythonConfig();
cfg.utf8_mode = -1;
PyStatus status = Py_PreInitialize();
if (PyStatus_Exception(status)) {
Py_ExitStatusException(status);
}

I use this to test,there are no exceptions

--

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread Christian Heimes


Christian Heimes  added the comment:

What's the result of the Py_PreInitialize() call?

--
nosy: +christian.heimes

___
Python tracker 

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



[issue43091] console encode is not utf-8!!

2021-02-01 Thread twoone3


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

https://docs.python.org/3/c-api/init_config.html?highlight=pypreconfig_initpythonconfig#c.PyPreConfig
When I use this api,The coding of the console has not changed,utf8_mode is 1.
This is my code.
PyPreConfig_InitPythonConfig();
cfg.utf8_mode = -1;
Py_PreInitialize();

--
messages: 386069
nosy: twoone3
priority: normal
severity: normal
status: open
title: console encode is not utf-8!!
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



[issue40601] [C API] Hide static types from the limited C API

2021-02-01 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue42647] Unable to use concurrent.futures in atexit hook

2021-02-01 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +vstinner

___
Python tracker 

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



[issue43085] Loosening | and |= operator type checking restriction

2021-02-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Because ABCs set minimum standards for compliance, they can't be extended 
without breaking existing code that registers to the ABC.

Brandt added __or/ior__ support to some of the mapping classes in the standard 
library, but it is a fact of life that there will always be some mapping 
classes that don't have __or/ior__ support.  It is an optional feature.

It is possible add new ABC subclasses with the extra methods, but I don't think 
that is worth it.  The effort for a mapping class maintainer to change which 
class it inherits from or registers to is about equal to the effort to just add 
the two methods.

So, I think your best bet is to propose PRs for individual mapping classes on a 
case-by-case basis.

--

___
Python tracker 

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



[issue42647] Unable to use concurrent.futures in atexit hook

2021-02-01 Thread Julien Danjou


Julien Danjou  added the comment:

> Is there a real-world situation where it's specifically necessary or even 
> beneficial to utilize ThreadPoolExecutor at this point after thread 
> finalization rather than earlier in the program? Not that it doesn't exist, 
> but to me it intuitively seems very odd to utilize an executor within an 
> atexit hook, which are intended to just be resource finalization/cleanup 
> functions called at interpreter shutdown. Assuming there is a genuine use 
> case I'm not seeing, it may be worth weighing against the decision to convert 
> the executors to not use daemon threads, as I presently don't think there's a 
> way to (safely) allow that behavior without reverting back to using daemon 
> threads.

To put that in perspective, here is the original issue that trigged this bug 
for me:


Traceback (most recent call last):
  File "/root/project/ddtrace/profiling/scheduler.py", line 50, in flush
exp.export(events, start, self._last_export)
  File "/root/project/ddtrace/profiling/exporter/http.py", line 186, in export
self._upload(client, self.endpoint_path, body, headers)
  File "/root/project/ddtrace/profiling/exporter/http.py", line 189, in _upload
self._retry_upload(self._upload_once, client, path, body, headers)
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/tenacity/__init__.py",
 line 423, in __call__
do = self.iter(retry_state=retry_state)
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/tenacity/__init__.py",
 line 360, in iter
return fut.result()
  File "/root/.pyenv/versions/3.9.0/lib/python3.9/concurrent/futures/_base.py", 
line 433, in result
return self.__get_result()
  File "/root/.pyenv/versions/3.9.0/lib/python3.9/concurrent/futures/_base.py", 
line 389, in __get_result
raise self._exception
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/tenacity/__init__.py",
 line 426, in __call__
result = fn(*args, **kwargs)
  File "/root/project/ddtrace/profiling/exporter/http.py", line 193, in 
_upload_once
client.request("POST", path, body=body, headers=headers)
  File "/root/.pyenv/versions/3.9.0/lib/python3.9/http/client.py", line 1255, 
in request
self._send_request(method, url, body, headers, encode_chunked)
  File "/root/.pyenv/versions/3.9.0/lib/python3.9/http/client.py", line 1301, 
in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
  File "/root/.pyenv/versions/3.9.0/lib/python3.9/http/client.py", line 1250, 
in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
  File "/root/.pyenv/versions/3.9.0/lib/python3.9/http/client.py", line 1010, 
in _send_output
self.send(msg)
  File "/root/.pyenv/versions/3.9.0/lib/python3.9/http/client.py", line 950, in 
send
self.connect()
  File "/root/.pyenv/versions/3.9.0/lib/python3.9/http/client.py", line 921, in 
connect
self.sock = self._create_connection(
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/socket.py",
 line 88, in create_connection
addrs = list(getaddrinfo(host, port, 0, SOCK_STREAM))
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/_socketcommon.py",
 line 247, in getaddrinfo
addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, 
flags)
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/hub.py",
 line 841, in _get_resolver
self._resolver = self.resolver_class(hub=self) # pylint:disable=not-callable
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/resolver/thread.py",
 line 39, in __init__
self.pool = hub.threadpool
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/hub.py",
 line 865, in _get_threadpool
self._threadpool = self.threadpool_class(self.threadpool_size, hub=self)
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/hub.py",
 line 860, in threadpool_class
return GEVENT_CONFIG.threadpool
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/_config.py",
 line 50, in getter
return self.settings[setting_name].get()
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/_config.py",
 line 146, in get
self.value = self.validate(self._default())
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/_config.py",
 line 248, in validate
return self._import_one_of([self.shortname_map.get(x, x) for x in value])
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/_config.py",
 line 223, in _import_one_of
return self._import_one(candidates[-1])
  File 
"/root/project/.tox/py39-profile-gevent/lib/python3.9/site-packages/gevent/_config.py",
 line 237, in _import_one
module = importlib.import_module(module)
  File 

[issue43085] Loosening | and |= operator type checking restriction

2021-02-01 Thread Yurii Karabas


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

Hi Raymond,

I was trying to add __or__ method for collections.abc.Mapping, __ior__ method 
for collections.abc.MutableMapping, link to issue - 
https://bugs.python.org/issue42841.

I can extract code and move it to separate classes as you propose above.
What do you think about that?

--
nosy: +uriyyo

___
Python tracker 

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



[issue43090] parseaddr (from email.utils) returns invalid input string instead of ('', '')

2021-02-01 Thread R. David Murray


R. David Murray  added the comment:

The return value is correct.  Interpreted as an email address, 'randomstring' 
is a local mailbox.

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



[issue43056] Use of dicts in 4.2 and 4.7 of Python tutorial a bit confusing

2021-02-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The link to https://docs.python.org/3.9/library/stdtypes.html#typesmapping
 isn't a forward reference. It is a link to the main docs which is entirely 
appropriate and likely the only way a beginner would find that section.

I concur with Terry that this should be closed.  I've no evidence of an actual 
user ever having been confused by this presentation.

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



[issue43089] The optional argument to random.Random() is called "x" not "seed"

2021-02-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> It would be better to rename "x" to "seed" but that's
> not backwards compatible.

As you said, this would be a breaking change, so we can't do it.

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



[issue43090] parseaddr (from email.utils) returns invalid input string instead of ('', '')

2021-02-01 Thread Livio Bencik


New submission from Livio Bencik :

```
from email.utils import parseaddr
parseaddr('randomstring')
```

returns ('', 'randomstring'), instead of ('', '') as the documentation says.

--
components: email
messages: 386062
nosy: barry, lbenc135, r.david.murray
priority: normal
severity: normal
status: open
title: parseaddr (from email.utils) returns invalid input string instead of 
('', '')
type: behavior
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



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

2021-02-01 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 0332e569c12d3dc97171546c6dc10e42c27de34b by Mark Shannon in 
branch 'master':
bpo-42990: Further refactoring of PyEval_ functions. (GH-24368)
https://github.com/python/cpython/commit/0332e569c12d3dc97171546c6dc10e42c27de34b


--

___
Python tracker 

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



[issue43089] The optional argument to random.Random() is called "x" not "seed"

2021-02-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +mark.dickinson, rhettinger

___
Python tracker 

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



[issue42972] [C API] Heap types (PyType_FromSpec) must fully implement the GC protocol

2021-02-01 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


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

___
Python tracker 

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



[issue43016] Improve tests for curses

2021-02-01 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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