[issue42969] pthread_exit & PyThread_exit_thread from PyEval_RestoreThread etc. are harmful

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> Change CPython to call abort() instead of pthread_exit() as that situation is 
> unresolvable and the process dying is better than hanging, partially alive.  
> That solution isn't friendly, but is better than being silent and allowing 
> deadlock.  A failing process is always better than a hung process, especially 
> a partially hung process.

The last time someone proposed to always call abort(), I proposed to add a hook 
instead: I added sys.unraisablehook. See bpo-36829.

If we adopt this option, it can be a callback in C, something like: 
Py_SetThreadExitCallback(func) which would call func() rather than 
pthread_exit() in ceval.c.

--

Another option would be to add an option to disable daemon thread.

concurrent.futures has been modified to no longer use daemon threads: bpo-39812.

It is really hard to write a reliable implementation of daemon threads with 
Python subintepreters. See bpo-40234 "[subinterpreters] Disallow daemon threads 
in subinterpreters optionally".

There is already a private flag for that in subinterpreters to disallow 
spawning processes or threads: an "isolated" subintepreter. Example with 
_thread.start_new_thread():

PyInterpreterState *interp = _PyInterpreterState_GET();
if (interp->config._isolated_interpreter) {
PyErr_SetString(PyExc_RuntimeError,
"thread is not supported for isolated subinterpreters");
return NULL;
}

Or os.fork():

if (interp->config._isolated_interpreter) {
PyErr_SetString(PyExc_RuntimeError,
"fork not supported for isolated subinterpreters");
return NULL;
}

See also my article on fixing crashes with daemon threads:

* https://vstinner.github.io/gil-bugfixes-daemon-threads-python39.html
* https://vstinner.github.io/daemon-threads-python-finalization-python32.html

--

___
Python tracker 

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



[issue45216] Remove redundand information from difflib docstrings

2021-09-16 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

Difflib docstrings contain short descriptions of functions and methods defined 
in the module and classes. It is redundant because pydoc shows descriptions for 
every function and method just few lines below. For example:

 |  Methods:
 |  
 |  __init__(linejunk=None, charjunk=None)
 |  Construct a text differencer, with optional filters.
 |  
 |  compare(a, b)
 |  Compare two sequences of lines; generate the resulting delta.
 |  
 |  Methods defined here:
 |  
 |  __init__(self, linejunk=None, charjunk=None)
 |  Construct a text differencer, with optional filters.
 |  
 |  The two optional keyword parameters are for filter functions:
 |  
 |  - `linejunk`: A function that should accept a single string 
argument,
 |and return true iff the string is junk. The module-level function
 |`IS_LINE_JUNK` may be used to filter out lines without visible
 |characters, except for at most one splat ('#').  It is recommended
 |to leave linejunk None; the underlying SequenceMatcher class has
 |an adaptive notion of "noise" lines that's better than any static
 |definition the author has ever been able to craft.
 |  
 |  - `charjunk`: A function that should accept a string of length 1. 
The
 |module-level function `IS_CHARACTER_JUNK` may be used to filter 
out
 |whitespace characters (a blank or tab; **note**: bad idea to 
include
 |newline in this!).  Use of IS_CHARACTER_JUNK is recommended.
 |  
 |  compare(self, a, b)
 |  Compare two sequences of lines; generate the resulting delta.
 |  
 |  Each sequence must contain individual single-line strings ending 
with
 |  newlines. Such sequences can be obtained from the `readlines()` 
method
 |  of file-like objects.  The delta generated also consists of newline-
 |  terminated strings, ready to be printed as-is via the writeline()
 |  method of a file-like object.
 |  
 |  Example:

It leads to confusion because it looks like methods are described twice. Also 
the signature of a method in the class docstring can be outdated. For example 
the description of SequenceMatcher.__init__ was not updated for new parameter 
autojunk.

--
assignee: docs@python
components: Documentation
messages: 401923
nosy: docs@python, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Remove redundand information from difflib docstrings
type: enhancement
versions: Python 3.11

___
Python tracker 

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



[issue45208] test_pdb: test_checkline_is_not_executable() logs messages

2021-09-16 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +26796
pull_request: https://github.com/python/cpython/pull/28381

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> bpo-45155 : Default arguments for int.to_bytes(length=1, 
> byteorder=sys.byteorder) (#28265)

The commit title is wrong, the default "big" not sys.byteorder:

int.to_bytes(length=1, byteorder='big', *, signed=False)
int.from_bytes(bytes, byteorder='big', *, signed=False)

--

___
Python tracker 

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



[issue45128] test_multiprocessing fails sporadically on the release artifacts

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> The thing is that we are running the test suite constantly on CI and 
> buildbots and non of them have seen this problem :(

Most (if not all) Python CIs run the Python test suite using -jN option which 
runs each test in isolation: a fresh process is spawned to a test file.

--

___
Python tracker 

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



[issue45208] test_pdb: test_checkline_is_not_executable() logs messages

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 471b3811fe695dcd388396893a0f375a8866ac0c by Victor Stinner in 
branch '3.9':
bpo-45208: Make test_pdb.test_checkline_is_not_executable() quiet (GH-28354) 
(GH-28381)
https://github.com/python/cpython/commit/471b3811fe695dcd388396893a0f375a8866ac0c


--

___
Python tracker 

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



[issue45208] test_pdb: test_checkline_is_not_executable() logs messages

2021-09-16 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



[issue45186] Marshal output isn't completely deterministic.

2021-09-16 Thread Inada Naoki


Inada Naoki  added the comment:

FYI, This issue is duplicate of https://bugs.python.org/issue34093, and I had 
made two pull requests to solve the issue.

--
nosy: +methane

___
Python tracker 

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



[issue45128] test_multiprocessing fails sporadically on the release artifacts

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

Minimum command to reproduce the issue (on Linux):

$ ./python -m test -m test.test_logging.LogRecordTest.test_multiprocessing 
test_genericalias test_logging test_multiprocessing_fork -v

(...)
0:00:00 load avg: 0.45 Run tests sequentially
0:00:00 load avg: 0.45 [1/3] test_genericalias

--
Ran 0 tests in 0.000s

OK
0:00:00 load avg: 0.49 [2/3] test_logging -- test_genericalias ran no tests
test_multiprocessing (test.test_logging.LogRecordTest) ... ok

--
Ran 1 test in 0.008s

OK
0:00:00 load avg: 0.49 [3/3] test_multiprocessing_fork
test test_multiprocessing_fork crashed -- Traceback (most recent call last):
  File "/home/vstinner/python/main/Lib/test/libregrtest/runtest.py", line 340, 
in _runtest_inner
refleak = _runtest_inner2(ns, test_name)
  ^^
  File "/home/vstinner/python/main/Lib/test/libregrtest/runtest.py", line 280, 
in _runtest_inner2
the_module = importlib.import_module(abstest)
 
  File "/home/vstinner/python/main/Lib/importlib/__init__.py", line 126, in 
import_module
return _bootstrap._gcd_import(name[level:], package, level)
   
  File "", line 1072, in _gcd_import
  File "", line 1044, in _find_and_load
  File "", line 1015, in _find_and_load_unlocked
  File "", line 689, in _load_unlocked
  File "", line 894, in exec_module
  File "", line 241, in _call_with_frames_removed
  File "/home/vstinner/python/main/Lib/test/test_multiprocessing_fork.py", line 
2, in 
import test._test_multiprocessing
^
  File "/home/vstinner/python/main/Lib/test/_test_multiprocessing.py", line 
5374, in 
class TestSyncManagerTypes(unittest.TestCase):
^^
  File "/home/vstinner/python/main/Lib/test/_test_multiprocessing.py", line 
5396, in TestSyncManagerTypes
manager_class = multiprocessing.managers.SyncManager

AttributeError: module 'multiprocessing' has no attribute 'managers'

test_multiprocessing_fork failed (uncaught exception)
(...)

--

___
Python tracker 

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



[issue45128] test_multiprocessing fails sporadically on the release artifacts

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

I can still reproduce the issue if test_logging.py is simplified to:
---
import unittest
import sys

class LogRecordTest(unittest.TestCase):
def test_multiprocessing(self):
import multiprocessing.queues
del sys.modules['multiprocessing']
import multiprocessing
---


The "del sys.modules['multiprocessing']" line comes from 
LogRecordTest._extract_logrecord_process_name() method.

--

___
Python tracker 

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



[issue45128] test_multiprocessing_fork fails if run sequentially after test_logging

2021-09-16 Thread STINNER Victor


Change by STINNER Victor :


--
title: test_multiprocessing fails sporadically on the release artifacts -> 
test_multiprocessing_fork fails if run sequentially after  test_logging

___
Python tracker 

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



[issue5846] Deprecate obsolete functions in unittest

2021-09-16 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +26797
pull_request: https://github.com/python/cpython/pull/28382

___
Python tracker 

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



[issue45128] test_multiprocessing_fork fails if run sequentially after test_logging

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> ./python -m test -m test.test_logging.LogRecordTest.test_multiprocessing 
> test_genericalias test_logging test_multiprocessing_fork -v

This command reproduces the issue:

* importing test.test_genericalias imports multiprocessing submodules like 
multiprocessing.queues
* test_logging does: del sys.modules['multiprocessing']
* test_multiprocessing_fork fails to import multiprocessing submodules

--

___
Python tracker 

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



[issue45128] test_multiprocessing_fork fails if run sequentially after test_logging

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

The issue can be reproduced just with these lines:
---
import sys
import multiprocessing.queues
del sys.modules['multiprocessing']
import multiprocessing
import multiprocessing.connection
from multiprocessing.connection import wait
connection = multiprocessing.connection   # AttributeError here
---

--

___
Python tracker 

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



[issue45128] test_multiprocessing_fork fails if run sequentially after test_genericalias and test_logging

2021-09-16 Thread STINNER Victor


Change by STINNER Victor :


--
title: test_multiprocessing_fork fails if run sequentially after  test_logging 
-> test_multiprocessing_fork fails if run sequentially after test_genericalias 
and test_logging

___
Python tracker 

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



[issue45217] ConfigParser does not accept "No value" reversely to the doc

2021-09-16 Thread sbougnoux


New submission from sbougnoux :

Just the simple following config crashes

"""
[Bug]
Here
"""

Hopefully using "Here=" solves the issue, but the doc claims it shall work.
https://docs.python.org/3.8/library/configparser.html?highlight=configparser#supported-ini-file-structure

Save the config in "bug.ini", then write (it will raise an exception)
"""
from configparser import ConfigParser
ConfigParser().read('bug.ini')
"""

--
assignee: docs@python
components: Demos and Tools, Documentation, Library (Lib)
messages: 401932
nosy: docs@python, sbougnoux
priority: normal
severity: normal
status: open
title: ConfigParser does not accept "No value" reversely to the doc
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



[issue45218] cmath.log has an invalid signature

2021-09-16 Thread Mark Dickinson


New submission from Mark Dickinson :

inspect.signature reports that the cmath.log function has an invalid signature:

Python 3.11.0a0 (heads/fix-44954:d0ea569eb5, Aug 19 2021, 14:59:04) [Clang 
12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cmath
>>> import inspect
>>> inspect.signature(cmath.log)
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/mdickinson/Python/cpython/Lib/inspect.py", line 3215, in 
signature
return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
   ^^^
  File "/Users/mdickinson/Python/cpython/Lib/inspect.py", line 2963, in 
from_callable
return _signature_from_callable(obj, sigcls=cls,
   ^
  File "/Users/mdickinson/Python/cpython/Lib/inspect.py", line 2432, in 
_signature_from_callable
return _signature_from_builtin(sigcls, obj,
   
  File "/Users/mdickinson/Python/cpython/Lib/inspect.py", line 2244, in 
_signature_from_builtin
return _signature_fromstr(cls, func, s, skip_bound_arg)
   
  File "/Users/mdickinson/Python/cpython/Lib/inspect.py", line 2114, in 
_signature_fromstr
raise ValueError("{!r} builtin has invalid signature".format(obj))
^^
ValueError:  builtin has invalid signature

--
components: Extension Modules
messages: 401933
nosy: mark.dickinson
priority: normal
severity: normal
status: open
title: cmath.log has an invalid signature
versions: Python 3.10, Python 3.11, Python 3.9

___
Python tracker 

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



[issue45218] cmath.log has an invalid signature

2021-09-16 Thread Mark Dickinson


Change by Mark Dickinson :


--
type:  -> behavior

___
Python tracker 

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



[issue45212] Dangling threads in skipped tests in test_socket

2021-09-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 7dacb70485a0910eb298c24b4d051720ca56fb91 by Serhiy Storchaka in 
branch 'main':
bpo-45212: Fix dangling threads in skipped tests in test_socket (GH-28361)
https://github.com/python/cpython/commit/7dacb70485a0910eb298c24b4d051720ca56fb91


--

___
Python tracker 

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



[issue45212] Dangling threads in skipped tests in test_socket

2021-09-16 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue45212] Dangling threads in skipped tests in test_socket

2021-09-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26799
pull_request: https://github.com/python/cpython/pull/28385

___
Python tracker 

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



[issue45183] Unexpected exception with zip importer

2021-09-16 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

I just noticed that I'm unnecessarily obtuse in my description of a possible 
fix, the diff (without test update):

% git diff Lib/zipimport.py 
   (main)cpython
diff --git a/Lib/zipimport.py b/Lib/zipimport.py
index c55fec6aa1..43ac6cbe57 100644
--- a/Lib/zipimport.py
+++ b/Lib/zipimport.py
@@ -334,7 +334,7 @@ def invalidate_caches(self):
 _zip_directory_cache[self.archive] = self._files
 except ZipImportError:
 _zip_directory_cache.pop(self.archive, None)
-self._files = None
+self._files = {}
 
 
 def __repr__(self):


With that change the exception should not happen, and the now stale zipimporter 
would be ignored when flushing the cache while the zipfile referenced by the 
zip importer instance has been removed.

That said, I haven't tested this and won't create a PR because my local tree is 
(still) a mess.

--

___
Python tracker 

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



[issue45219] Expose indexing and other simple operations on dict-keys in internal API

2021-09-16 Thread Mark Shannon


New submission from Mark Shannon :

Specialization and other optimizations rely on shared dictionary key properties 
(version number, no deletions, etc).
However checking those properties during specialization is tricky and rather 
clunky as the dict-keys can only be tested indirectly through a dictionary.

We should add a few internal API functions. Specifically we want to know:

Is a key in a dict-keys?
What index is that key at?
Is a dict-keys all unicode?

--
assignee: Mark.Shannon
messages: 401936
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: Expose indexing and other simple operations on dict-keys in internal API

___
Python tracker 

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



[issue45218] cmath.log has an invalid signature

2021-09-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

Issue #43067 is similar. I'm not sure what the best solution is in this case:

- un-argument-clinic cmath.log, and document the signature using two lines 
(similar to range):

 log(z)
 log(z, base)

- change the behaviour of cmath.log so that the second argument is allowed be 
None (and defaults to None)

--

___
Python tracker 

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



[issue45218] cmath.log has an invalid signature

2021-09-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

See also #36306 and #29299. There may be nothing to be done here, but it would 
be nice if math.log and cmath.log at least behaved in the same way. A default 
of `None` doesn't seem like a terrible option.

(BTW, just to forestall the suggestion, a default of `math.e` or `cmath.e` is 
definitely *not* the right thing to use as a default: `math.e` is not exactly 
Euler's value for e, and `log` base `math.e` is likely to be less accurate than 
plain natural log.)

--

___
Python tracker 

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



[issue45218] cmath.log has an invalid signature

2021-09-16 Thread Mark Dickinson


Mark Dickinson  added the comment:

> and `log` base `math.e` is likely to be less accurate than plain natural log

Nope, that's nonsense, since the two-argument form simply divides by log(base), 
and while log(math.e) is mathematically not exactly 1 (its exact value, 
assuming IEEE 754 binary64, starts 0.468176229339410862948..., 
which is off from 1.0 by around 0.48 ulps), it's *just* close enough that with 
a well-behaved libm log implementation it's exactly 1.0 after rounding.

I still don't like the idea of math.e as a default value here, but I'd have to 
work harder to identify why it makes me uneasy.

--

___
Python tracker 

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



[issue45218] cmath.log has an invalid signature

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

The current Argument Clinic syntax for math.log() is:

--
/*[clinic input]
math.log

x:object
[
base: object(c_default="NULL") = math.e
]
/

Return the logarithm of x to the given base.
(...)
--

math.log.__text_signature__ is None. __text_signature__ is used by 
inspect.signature().

I guess that it's a bug in Argument Clinic.

--
nosy: +vstinner

___
Python tracker 

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



[issue45212] Dangling threads in skipped tests in test_socket

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

def testWithTimeoutTriggeredSend(self):
conn = self.accept_conn()
conn.recv(88192)
+time.sleep(1)

Was it a deliberate choice to add a sleep of 1 second? If yes, can you please 
add a comment to explain why?

--
nosy: +vstinner

___
Python tracker 

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



[issue45027] Allow basicConfig to configure any logger, not just root

2021-09-16 Thread Vinay Sajip


Vinay Sajip  added the comment:

> This change serves the purpose of making it easier to configure non-root 
> loggers.

My point was, they don't need to configure non-root loggers (in terms of adding 
handlers) because the root logger's handlers will normally be used for all 
loggers.

> However, if you configure the root logger in your application, you will see 
> those [other libraries'] log messages.

Users certainly don't need an API change to prevent that, should they wish to. 
The following simple call will suffice (using 'gnupg' just as an example):

logging.getLogger('gnupg').setLevel(logging.CRITICAL + 1)

> I would frame this proposal as a third configuration option

As you can see, it's not needed for the purpose you described (avoiding 
messages from third-party loggers).

> it would be nice to adjust the type stubs for dictConfig() to use a TypedDict 
> ... I'm happy to make a PR to Typeshed for it, though!

Sure, sounds like a good idea.

> I also think there should be a note about dictConfig() in the docs for 
> basicConfig() ... Again, I'm happy to make a separate PR for that change.

By all means. You could also look at updating the cookbook content, if you feel 
that parts relating to the concerns expressed in this issue could be expanded 
on.

--

___
Python tracker 

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



[issue45211] Useful (expensive) information is discarded in getpath.c.

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

See also https://github.com/python/cpython/pull/23169 of bpo-42260 which 
rewrites getpath.c in pure Python.

--
nosy: +vstinner

___
Python tracker 

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



[issue45210] tp_dealloc docs should mention error indicator may be set

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

I'm not sure that it's a feature. Maybe we should modify to never call 
tp_dealloc with an exception set.

--
nosy: +vstinner

___
Python tracker 

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



[issue45156] mock.seal has infinite recursion with int class attributes

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks for the report and the fix!

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



[issue24132] Direct sub-classing of pathlib.Path

2021-09-16 Thread Richard


Richard  added the comment:

I agree this would be nice. For now, I'm doing this as a hack:

class Path(type(pathlib.Path())):
...

--
nosy: +nyuszika7h

___
Python tracker 

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



[issue45128] test_multiprocessing_fork fails if run sequentially after test_genericalias and test_logging

2021-09-16 Thread Nikita Sobolev


Change by Nikita Sobolev :


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

___
Python tracker 

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



[issue45155] Add default arguments for int.to_bytes()

2021-09-16 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:

On Sep 16, 2021, at 00:36, STINNER Victor  wrote:
> 
> The commit title is wrong, the default "big" not sys.byteorder:
> 
>int.to_bytes(length=1, byteorder='big', *, signed=False)
>int.from_bytes(bytes, byteorder='big', *, signed=False)

Oops

--

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on main branch

2021-09-16 Thread Nikita Sobolev


New submission from Nikita Sobolev :

I've started to notice that CPython's builds on Windows now simetimes fail with 
something like this:

(both Azure and Github Actions are affected)

```
Using "C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" (found in the Visual 
Studio installation)
Using py -3.9 (found 3.9 with py.exe)

D:\a\cpython\cpython>"C:\Program Files (x86)\Microsoft Visual 
Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" 
"D:\a\cpython\cpython\PCbuild\pcbuild.proj" /t:Build /m /nologo /v:m 
/clp:summary /p:Configuration=Release /p:Platform=Win32 
/p:IncludeExternals=true /p:IncludeCTypes=true /p:IncludeSSL=true 
/p:IncludeTkinter=true /p:UseTestMarker= /p:GIT="C:\Program 
Files\Git\bin\git.exe"  
  _freeze_module.c
  config_minimal.c
  atexitmodule.c
  faulthandler.c
  gcmodule.c
  getbuildinfo.c
  posixmodule.c
  signalmodule.c
  _tracemalloc.c
  _iomodule.c
  bufferedio.c
  bytesio.c
  fileio.c
  iobase.c
  stringio.c
  textio.c
  winconsoleio.c
  abstract.c
  accu.c
  boolobject.c
  Compiling...
  bytearrayobject.c
  bytes_methods.c
  bytesobject.c
  call.c
  capsule.c
  cellobject.c
  classobject.c
  codeobject.c
  complexobject.c
  descrobject.c
  dictobject.c
  enumobject.c
  exceptions.c
  fileobject.c
  floatobject.c
  frameobject.c
  funcobject.c
  genericaliasobject.c
  genobject.c
  interpreteridobject.c
  Compiling...
  iterobject.c
  listobject.c
  longobject.c
  memoryobject.c
  methodobject.c
  moduleobject.c
  namespaceobject.c
  object.c
  obmalloc.c
  odictobject.c
  picklebufobject.c
  rangeobject.c
  setobject.c
  sliceobject.c
  structseq.c
  tupleobject.c
  typeobject.c
  unicodectype.c
  unicodeobject.c
  unionobject.c
  Compiling...
  weakrefobject.c
  myreadline.c
  parser.c
  peg_api.c
  pegen.c
  string_parser.c
  token.c
  tokenizer.c
  getpathp.c
  invalid_parameter_handler.c
  msvcrtmodule.c
  winreg.c
  _warnings.c
  asdl.c
  ast.c
  ast_opt.c
  ast_unparse.c
  bltinmodule.c
  bootstrap_hash.c
  ceval.c
D:\a\cpython\cpython\Python\ceval.c(3669,13): warning C4018: '>=': 
signed/unsigned mismatch [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]
D:\a\cpython\cpython\Python\ceval.c(3777,13): warning C4018: '>=': 
signed/unsigned mismatch [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]
  Compiling...
  codecs.c
  compile.c
  context.c
  dtoa.c
  dynamic_annotations.c
  dynload_win.c
  errors.c
  fileutils.c
  formatter_unicode.c
  frame.c
  future.c
  getargs.c
  getcompiler.c
  getcopyright.c
  getopt.c
  getplatform.c
  getversion.c
  hamt.c
  hashtable.c
  import.c
  Compiling...
  importdl.c
  initconfig.c
  marshal.c
  modsupport.c
  mysnprintf.c
  mystrtoul.c
  pathconfig.c
  preconfig.c
  pyarena.c
  pyctype.c
  pyfpe.c
  pyhash.c
  pylifecycle.c
  pymath.c
  pystate.c
  pystrcmp.c
  pystrhex.c
  pystrtod.c
  Python-ast.c
  pythonrun.c
  Compiling...
  Python-tokenize.c
  pytime.c
  specialize.c
  structmember.c
  suggestions.c
  symtable.c
  sysmodule.c
  thread.c
  traceback.c
 Creating library D:\a\cpython\cpython\PCbuild\win32\_freeze_module.lib and 
object D:\a\cpython\cpython\PCbuild\win32\_freeze_module.exp
  Generating code
  Finished generating code
  _freeze_module.vcxproj -> 
D:\a\cpython\cpython\PCbuild\win32\_freeze_module.exe
  Updated files: __hello__.h
  Killing any running python.exe instances...
  Regenerate pycore_ast.h pycore_ast_state.h Python-ast.c
  D:\a\cpython\cpython\Python\Python-ast.c, 
D:\a\cpython\cpython\Include\internal\pycore_ast.h, 
D:\a\cpython\cpython\Include\internal\pycore_ast_state.h regenerated.
  Regenerate opcode.h opcode_targets.h
  Include\opcode.h regenerated from Lib\opcode.py
  Jump table written into Python\opcode_targets.h
  Regenerate token-list.inc token.h token.c token.py
  Generated sources are up to date
  Getting build info from "C:\Program Files\Git\bin\git.exe"
  Building heads/main-dirty:7dacb70 main
  _abc.c
  _bisectmodule.c
  blake2module.c
  blake2b_impl.c
  blake2s_impl.c
  _codecsmodule.c
  _collectionsmodule.c
  _contextvarsmodule.c
  _csv.c
  _functoolsmodule.c
  _heapqmodule.c
  _json.c
  _localemodule.c
  _lsprof.c
  _math.c
  _pickle.c
  _randommodule.c
  sha3module.c
  _sre.c
  _stat.c
  Compiling...
  _struct.c
  _weakref.c
  arraymodule.c
  atexitmodule.c
  audioop.c
  binascii.c
  cmathmodule.c
  _datetimemodule.c
  errnomodule.c
  faulthandler.c
  gcmodule.c
  itertoolsmodule.c
  main.c
  mathmodule.c
  md5module.c
  mmapmodule.c
  _opcode.c
  _operator.c
  posixmodule.c
  rotatingtree.c
  Compiling...
  sha1module.c
  sha256module.c
  sha512module.c
  signalmodule.c
  _statisticsmodule.c
  symtablemodule.c
  _threadmodule.c
  _tracemalloc.c
  _typingmodule.c
  timemodule.c
  xxsubtype.c
  _xxsubinterpretersmodule.c
  fileio.c
  bytesio.c
  stringio.c
  bufferedio.c
  iobase.c
  textio.c
  winconsoleio.c
  _iomodule.c
  Compiling...
  _codecs_cn.c
  _codecs_hk.c
  _codecs_iso2022.c
  _codecs_jp.c
  _codecs_

[issue45212] Dangling threads in skipped tests in test_socket

2021-09-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Yes, it is a deliberate choice. It is difficult to explain why it was passed 
without it -- dues to a specific order of calling tearDown() and callbacks 
registered with addCleanup() in different base classes.

Using an event object would fix it too, but:

* Re-using an existing event object (like self.done) can have side effects in 
future.
* Introducing a new event object has a risk of name conflicts, because the 
hierarchy of classes is complicated, and same name can be reused by accident.
* time.sleep() is already used in other similar tests for timeouts. We only 
need to do a sleep longer then the timeout on the client side (0.01).

Given all this, I decided that adding time.sleep(1) was the simplest, the most 
obvious, and maybe the most resistant to future human errors way. If we want to 
use an event object here, we will need to re-consider using time.sleep() in 
other tests.

What comment do you want to add?

--

___
Python tracker 

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



[issue44598] test_constructor (test.test_ssl.ContextTests) ... Fatal Python error: Segmentation fault

2021-09-16 Thread tongxiaoge


tongxiaoge  added the comment:

I'm sorry I haven't replied for a long time. I found that the OpenSSL version I 
use is 1.1.1f, which is probably caused by this. Today, I tried to upgrade 
Python 3 to 3.8.12, and the same problem occurred. I'll try again after 
upgrading the OpenSSL version tomorrow. If there are still problems, I'll give 
a reply at that time.

--

___
Python tracker 

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



[issue45221] Linker flags starting with -h breaks setup.py (regression)

2021-09-16 Thread ux


New submission from ux :

Hi,

Since 3.8 (included), the following build command fails:

LDFLAGS=-headerpad_max_install_names ./configure
make

With the following error:

setup.py: error: argument -h/--help: ignored explicit argument 
'eaderpad_max_install_names'


A quick hack in setup.py "fixes" the issue:

-options, _ = parser.parse_known_args(env_val.split())
+options, _ = parser.parse_known_args([x for x in 
env_val.split() if not x.startswith('-h')])

Another workaround as a user is to do use 
`LDFLAGS=-Wl,-headerpad_max_install_names`.

--
components: Build
messages: 401951
nosy: ux
priority: normal
severity: normal
status: open
title: Linker flags starting with -h breaks setup.py (regression)
type: compile error
versions: Python 3.10, Python 3.11, Python 3.8, Python 3.9

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on main branch

2021-09-16 Thread Zachary Ware


Change by Zachary Ware :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on main branch: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread STINNER Victor


Change by STINNER Victor :


--
title: Windows builds sometimes fail on main branch -> Windows builds sometimes 
fail on main branch: fatal error RC1116: RC terminating after preprocessor 
errors

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on main branch

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

It also fails on the 3.9 and 3.10 on the Windows jobs of GitHub Action.

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread STINNER Victor


Change by STINNER Victor :


--
title: Windows builds sometimes fail on main branch: fatal error RC1116: RC 
terminating after preprocessor errors -> Windows builds sometimes fail on Azure 
and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

Is bpo-45220 "Windows builds sometimes fail on Azure and GitHub Action: fatal 
error RC1116: RC terminating after preprocessor errors" related to this issue?

--
nosy: +vstinner

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

It may be related to bpo-45020 which recently got a change:

New changeset 9fd87a5fe5c468cf94265365091267838b004b7f by Eric Snow in branch 
'main':
bpo-45020: Revert "Drop the frozen .h files from the repo." (gh-28380)
https://github.com/python/cpython/commit/9fd87a5fe5c468cf94265365091267838b004b7f

--

___
Python tracker 

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



[issue45222] test_with_pip fail

2021-09-16 Thread tongxiaoge


New submission from tongxiaoge :

Today, I tried to upgrade Python 3 to version 3.8.12, the test case 
test_with_pip failed. The error message is as follows:
[  356s] test_with_pip (test.test_venv.EnsurePipTest) ... FAIL
[  356s] 
[  356s] ==
[  356s] FAIL: test_with_pip (test.test_venv.EnsurePipTest)
[  356s] --
[  356s] Traceback (most recent call last):
[  356s]   File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/test/test_venv.py", line 444, in 
do_test_with_pip
[  356s] self.run_with_capture(venv.create, self.env_dir,
[  356s]   File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/test/test_venv.py", line 77, in 
run_with_capture
[  356s] func(*args, **kwargs)
[  356s] subprocess.CalledProcessError: Command 
'['/tmp/tmpm13zz0cn/bin/python', '-Im', 'ensurepip', '--upgrade', 
'--default-pip']' returned non-zero exit status 1.
[  356s] 
[  356s] During handling of the above exception, another exception occurred:
[  356s] 
[  356s] Traceback (most recent call last):
[  356s]   File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/test/test_venv.py", line 504, in 
test_with_pip
[  356s] self.do_test_with_pip(False)
[  356s]   File 
"/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/test/test_venv.py", line 452, in 
do_test_with_pip
[  356s] self.fail(msg.format(exc, details))
[  356s] AssertionError: Command '['/tmp/tmpm13zz0cn/bin/python', '-Im', 
'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
[  356s] 
[  356s] **Subprocess Output**
[  356s] Looking in links: /tmp/tmp7usqy615
[  356s] Processing /tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl
[  356s] Processing /tmp/tmp7usqy615/setuptools-54.2.0-py3-none-any.whl
[  356s] Installing collected packages: setuptools, pip
[  356s] ERROR: Exception:
[  356s] Traceback (most recent call last):
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/packaging/version.py",
 line 57, in parse
[  356s] return Version(version)
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/packaging/version.py",
 line 298, in __init__
[  356s] raise InvalidVersion("Invalid version: '{0}'".format(version))
[  356s] pip._vendor.packaging.version.InvalidVersion: Invalid version: 
'setuptools'
[  356s] 
[  356s] During handling of the above exception, another exception occurred:
[  356s] 
[  356s] Traceback (most recent call last):
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py",
 line 224, in _main
[  356s] status = self.run(options, args)
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_internal/cli/req_command.py",
 line 180, in wrapper
[  356s] return func(self, options, args)
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_internal/commands/install.py",
 line 439, in run
[  356s] working_set = pkg_resources.WorkingSet(lib_locations)
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py",
 line 567, in __init__
[  356s] self.add_entry(entry)
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py",
 line 623, in add_entry
[  356s] for dist in find_distributions(entry, True):
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py",
 line 2061, in find_on_path
[  356s] path_item_entries = _by_version_descending(filtered)
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py",
 line 2034, in _by_version_descending
[  356s] return sorted(names, key=_by_version, reverse=True)
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py",
 line 2032, in _by_version
[  356s] return [packaging.version.parse(part) for part in parts]
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py",
 line 2032, in 
[  356s] return [packaging.version.parse(part) for part in parts]
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/packaging/version.py",
 line 59, in parse
[  356s] return LegacyVersion(version)
[  356s]   File 
"/tmp/tmp7usqy615/pip-20.3.3-py2.py3-none-any.whl/pip/_vendor/packaging/version.py",
 line 127, in __init__
[  356s] warnings.warn(
[  356s] DeprecationWarning: Creating a LegacyVersion has been deprecated and 
will be removed in the next major release
[  356s] Traceback (most recent call last):
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/runpy.py", line 
194, in _run_module_as_main
[  356s] return _run_code(code, main_globals, None,
[  356s]   File "/home/abuild/rpmbuild/BUILD/Python-3.8.12/Lib/runpy.py", line 
87, in _run_code
[  356s] exec(code, run_

[issue44936] test_concurrent_futures: test_cancel_futures_wait_false() and test_interpreter_shutdown() failed on GHA Windows x64

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

Recent failure, Windows x64 job of GitHub Action:
https://github.com/python/cpython/runs/3617689771

0:07:18 load avg: 6.20 [425/427/2] test_concurrent_futures failed (2 failures) 
(1 min 51 sec)
(...)
==
FAIL: test_cancel_futures_wait_false 
(test.test_concurrent_futures.ThreadPoolShutdownTest)
--
Traceback (most recent call last):
  File "D:\a\cpython\cpython\lib\test\test_concurrent_futures.py", line 488, in 
test_cancel_futures_wait_false
rc, out, err = assert_python_ok('-c', """if True:
   ^^
  File "D:\a\cpython\cpython\lib\test\support\script_helper.py", line 160, in 
assert_python_ok
return _assert_python(True, *args, **env_vars)
   ^^^
  File "D:\a\cpython\cpython\lib\test\support\script_helper.py", line 145, in 
_assert_python
res.fail(cmd_line)
^^
  File "D:\a\cpython\cpython\lib\test\support\script_helper.py", line 72, in 
fail
raise AssertionError("Process return code is %d\n"
^^
AssertionError: Process return code is 3221225477
command line: ['D:\\a\\cpython\\cpython\\PCbuild\\amd64\\python.exe', '-X', 
'faulthandler', '-I', '-c', 'if True:\nfrom concurrent.futures 
import ThreadPoolExecutor\nfrom test.test_concurrent_futures import 
sleep_and_print\nif __name__ == "__main__":\nt = 
ThreadPoolExecutor()\nt.submit(sleep_and_print, .1, "apple")\n  
  t.shutdown(wait=False, cancel_futures=True)\n']

stdout:
---
apple
---

stderr:
---

---

==
FAIL: test_hang_issue39205 (test.test_concurrent_futures.ThreadPoolShutdownTest)
shutdown(wait=False) doesn't hang at exit with running futures.
--
Traceback (most recent call last):
  File "D:\a\cpython\cpython\lib\test\test_concurrent_futures.py", line 393, in 
test_hang_issue39205
rc, out, err = assert_python_ok('-c', """if True:
   ^^
  File "D:\a\cpython\cpython\lib\test\support\script_helper.py", line 160, in 
assert_python_ok
return _assert_python(True, *args, **env_vars)
   ^^^
  File "D:\a\cpython\cpython\lib\test\support\script_helper.py", line 145, in 
_assert_python
res.fail(cmd_line)
^^
  File "D:\a\cpython\cpython\lib\test\support\script_helper.py", line 72, in 
fail
raise AssertionError("Process return code is %d\n"
^^
AssertionError: Process return code is 3221225477
command line: ['D:\\a\\cpython\\cpython\\PCbuild\\amd64\\python.exe', '-X', 
'faulthandler', '-I', '-c', 'if True:\nfrom concurrent.futures 
import ThreadPoolExecutor\nfrom test.test_concurrent_futures import 
sleep_and_print\nif __name__ == "__main__":\nt = 
ThreadPoolExecutor(max_workers=3)\nt.submit(sleep_and_print, 
1.0, "apple")\nt.shutdown(wait=False)\n']

stdout:
---
apple
---

stderr:
---

---

--
Ran 226 tests in 111.014s

FAILED (failures=2, skipped=111)
test test_concurrent_futures failed

--

___
Python tracker 

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



[issue45116] Performance regression 3.10b1 and later on Windows: Py_DECREF() not inlined in PGO build

2021-09-16 Thread Ken Jin


Change by Ken Jin :


--
nosy: +kj

___
Python tracker 

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



[issue45222] test_with_pip fail

2021-09-16 Thread tongxiaoge


Change by tongxiaoge :


--
components: +Build
type:  -> behavior

___
Python tracker 

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



[issue45222] test_with_pip fail

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> Today, I tried to upgrade Python 3 to version 3.8.12, the test case 
> test_with_pip failed. The error message is as follows:

What is your operating system? How did you install Python? Which command did 
you type to run tests?

--

___
Python tracker 

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



[issue45222] test_venv: test_with_pip fails on version 3.8.12 with: pip._vendor.packaging.version.InvalidVersion: Invalid version: 'setuptools'

2021-09-16 Thread STINNER Victor


Change by STINNER Victor :


--
title: test_with_pip fail -> test_venv: test_with_pip fails on version 3.8.12 
with: pip._vendor.packaging.version.InvalidVersion: Invalid version: 
'setuptools'

___
Python tracker 

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



[issue42969] pthread_exit & PyThread_exit_thread from PyEval_RestoreThread etc. are harmful

2021-09-16 Thread Jeremy Maitin-Shepard


Jeremy Maitin-Shepard  added the comment:

Regarding your suggestion of adding a hook like `Py_SetThreadExitCallback`, it 
seems like there are 4 plausible behaviors that such a callback may implement:

1. Abort the process immediately with an error.

2. Exit immediately with the original exit code specified by the user.

3. Hang the thread.

4. Attempt to unwind the thread, like `pthread_exit`, calling pthread thread 
cleanup functions and C++ destructors.

5. Terminate the thread immediately without any cleanup or C++ destructor calls.

The current behavior is (4) on POSIX platforms (`pthread_exit`), and (5) on 
Windows (`_endthreadex`).

In general, achieving a clean shutdown will require the cooperation of all 
relevant code in the program, particularly code using the Python C API.  
Commonly the Python C API is used more by library code rather than application 
code, while it would presumably be the application that is responsible for 
setting this callback.  Writing a library that supports multiple different 
thread shutdown behaviors would be particularly challenging.

I think the callback is useful, but we would still need to discuss what the 
default behavior should be (hopefully different from the current behavior), and 
what guidance would be provided as far as what the callback is allowed to do.

Option (1) is highly likely to result in a user-visible error --- a lot of 
Python programs that previously exited successfully will now, possibly only 
some of the time, exit with an error.  The advantage is the user is alerted to 
the fact that some threads were not cleanly exited, but a lot of previously 
working code is now broken.  This seems like a reasonable policy for a given 
application to impose (effectively requiring the use of an atexit handler to 
terminate all daemon threads), but does not seem like a reasonable default 
given the existing use of daemon threads.

Option (2) would likely do the right thing in many cases, but main thread 
cleanup that was previously run would now be silently skipped.  This again 
seems like a reasonable policy for a given application to impose, but does not 
seem like a reasonable default.

Option (3) avoids the possibility of crashes and memory corruption.  Since the 
thread stack remains allocated, any pointers to the thread stack held in global 
data structures or by other threads remain valid.  There is a risk that the 
thread may be holding a lock, or otherwise block progress of the main thread, 
resulting in silent deadlock.  That can be mitigated by registering an atexit 
handler.

Option (4) in theory would allow cleanup handlers to be registered in order to 
avoid deadlock due to locks held.  In practice, though, it causes a lot of 
problems:
 - The CPython codebase itself contains no such cleanup handlers, and I expect 
the vast majority of existing C extensionss are also not designed to properly 
handle the stack unwind triggered by `pthread_exit`.  Without proper cleanup 
handlers, this option reverts to option (5), where there is a risk of memory 
corruption due to other threads accessing pointers to the freed thread stack.  
There is also the same risk of deadlock as in option (3).
 - Stack unwinding interacts particularly badly with common C++ usage because 
the very first thing most people want to do when using the Python C API from 
C++ is create a "smart pointer" type for holding a `PyObject` pointer that 
handles the reference counting automatically (calls `Py_INCREF` when copied, 
`Py_DECREF` in the destructor).  When the stack unwinds due to `pthread_exit`, 
the current thread will NOT hold the GIL, and these `Py_DECREF` calls result in 
a crash / memory corruption.  We would need to either create a new 
finalizing-safe version of Py_DECREF, that is a noop when called from a 
non-main thread if `_Py_IsFinalizing()` is true (and then existing C++ 
libraries like pybind11 would need to be changed to use it), or modify the 
existing `Py_DECREF` to always have that additional check.  Other calls to 
Python C APIs in destructors are also common.
 - When writing code that attempts to be safe in the presence of stack 
unwinding due to `pthread_exit`, it is not merely explicitly GIL-related calls 
that are a concern.  Virtually any Python C API function can transitively 
release and acquire the GIL and therefore you must defend against unwind from 
virtually all Python C API functions.
 - Some C++ functions in the call stack may unintentionally catch the exception 
thrown by `pthread_exit` and then return normally.  If they return back to a 
CPython stack frame, memory corruption/crashing is likely.
 - Alternatively, some C++ functions in the call stack may be marked 
`noexcept`.  If the unwinding reaches such a function, then we end up with 
option (1).
  - In general this option seems to require auditing and fixing a very large 
amount of existing code, and introduces a lot of complexity.  For that reasons, 
I think this option should be a

[issue42969] pthread_exit & PyThread_exit_thread from PyEval_RestoreThread etc. are harmful

2021-09-16 Thread Jeremy Maitin-Shepard


Jeremy Maitin-Shepard  added the comment:

Regarding your suggestion of banning daemon threads: I happened to come across 
this bug not because of daemon threads but because of threads started by C++ 
code directly that call into Python APIs.  The solution I am planning to 
implement is to add an `atexit` handler to prevent this problem.

I do think it is reasonable to suggest that users should ensure daemon threads 
are exited cleanly via an atexit handler.  However, in some cases that may be 
challenging to implement, and there is also the issue of backward compatibility.

--

___
Python tracker 

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



[issue45186] Marshal output isn't completely deterministic.

2021-09-16 Thread Eric Snow


Eric Snow  added the comment:

Thanks, Inada-san.  That's super helpful.

--

___
Python tracker 

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



[issue45223] test_spawn_doesnt_hang (test.test_pty.PtyTest) fails when stdin isn't readable

2021-09-16 Thread Alexander Kanavin


New submission from Alexander Kanavin :

I am observing the following under yocto's test harness:
==
ERROR: test_spawn_doesnt_hang (test.test_pty.PtyTest)
--
Traceback (most recent call last):
  File "/usr/lib/python3.10/test/test_pty.py", line 316, in 
test_spawn_doesnt_hang
pty.spawn([sys.executable, '-c', 'print("hi there")'])
  File "/usr/lib/python3.10/pty.py", line 181, in spawn
_copy(master_fd, master_read, stdin_read)
  File "/usr/lib/python3.10/pty.py", line 157, in _copy
data = stdin_read(STDIN_FILENO)
  File "/usr/lib/python3.10/pty.py", line 132, in _read
return os.read(fd, 1024)
OSError: [Errno 5] Input/output error


The same tests runs fine in a regular console.

--
messages: 401961
nosy: Alexander Kanavin
priority: normal
severity: normal
status: open
title: test_spawn_doesnt_hang (test.test_pty.PtyTest) fails when stdin isn't 
readable

___
Python tracker 

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



[issue45223] test_spawn_doesnt_hang (test.test_pty.PtyTest) fails when stdin isn't readable

2021-09-16 Thread Roundup Robot


Change by Roundup Robot :


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

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread Eric Snow


Eric Snow  added the comment:

This is more likely to relate to bpo-45188, "De-couple the Windows builds from 
freezing modules.", for which the PR was merged yesterday:

New changeset 09b4ad11f323f8702cde795e345b75e0fbb1a9a5 by Steve Dower in branch 
'main':
bpo-45188: Windows now regenerates frozen modules at the start of build instead 
of late (GH-28322)
https://github.com/python/cpython/commit/09b4ad11f323f8702cde795e345b75e0fbb1a9a5

(https://github.com/python/cpython/pull/28322)

--
nosy: +eric.snow

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread Eric Snow


Eric Snow  added the comment:

Of course, it might also be unrelated.

--

___
Python tracker 

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



[issue45116] Performance regression 3.10b1 and later on Windows: Py_DECREF() not inlined in PGO build

2021-09-16 Thread neonene


neonene  added the comment:

I reported this issue to developercommunity of microsoft.

https://developercommunity.visualstudio.com/t/1531987

--

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(253): 
> error RC2188: 
> D:\a\cpython\cpython\PCbuild\obj\311win32_Release\pythoncore\RCa05056(47) : 
> fatal error RC1116: RC terminating after preprocessor errors 
> [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

Let's split it into sub-parts:

* C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(253): 
error RC2188
* D:\a\cpython\cpython\PCbuild\obj\311win32_Release\pythoncore\RCa05056(47)
* fatal error RC1116: RC terminating after preprocessor errors
* [D:\a\cpython\cpython\PCbuild\pythoncore.vcxproj]

RC errors are generated by the resource compiler

> C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h(253)

What is the code at line 253?

> error RC2188

What is this error?

> 311win32_Release\pythoncore\RCa05056(47)

Is this a directory with a generated name, or is it an error code?

> fatal error RC1116

What is this error?

--

Python contains the following .rc files:

PC/pylauncher.rc
PC/pyshellext.rc
PC/python_exe.rc
PC/python_nt.rc
PC/pythonw_exe.rc
PC/sqlite3.rc

None of these files include winnt.h.

In fact, "winnt.h" cannot be found in any file of the Python source code.

PC/python_nt.rc includes PC/python_ver_rc.h which contains 3 includes:

* #include "winver.h" => Windows SDK header file
* #include "modsupport.h" => Include/modsupport.h
  => it includes #include 
* #include "patchlevel.h" => Include/patchlevel.h

I'm not sure why modsupport.h is included.

--

I found one page mentioning RC2188 *and* RC1116 error codes together:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/7ba8eb72-12e9-4c78-af68-7f50c170040f/warning-rc4011-and-error-rc2188?forum=vclanguage

"RC errors are generated by the resource compiler. One of your .rc files 
includes directly or indirectly headers that RC can't understand so you'll have 
to check that and remove the #includes."

--

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-16 Thread Eric Snow


Eric Snow  added the comment:

I left a comment on bpo-45220.

--

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

> bpo-45188: Windows now regenerates frozen modules at the start of build 
> instead of late (GH-28322)

Maybe the resource compiler needs a header file which is not generated yet, and 
so the build fails.

In msg401948 logs, I don't see when header files are generated. This build step 
seems to be fully quiet.

--

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

This issue is serious: it prevents to merge many pull requests, it blocks the 
Python development workflow.

--

___
Python tracker 

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



[issue45219] Expose indexing and other simple operations on dict-keys in internal API

2021-09-16 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue45116] Performance regression 3.10b1 and later on Windows: Py_DECREF() not inlined in PGO build

2021-09-16 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue45116] Performance regression 3.10b1 and later on Windows: Py_DECREF() not inlined in PGO build

2021-09-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

These should be changed back to macros where inlining is guaranteed.

--

___
Python tracker 

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



[issue45224] Argparse shows required arguments as optional

2021-09-16 Thread Khalid Mammadov


New submission from Khalid Mammadov :

Currently argparse module shows all optional arguments under "optional 
arguments" section of the help.
It also includes those flags/arguments that are required as well. 
This add confusion to a user and does not properly show intention

--
components: Library (Lib)
messages: 401969
nosy: khalidmammadov
priority: normal
severity: normal
status: open
title: Argparse shows required arguments as optional
type: behavior
versions: Python 3.10, Python 3.11, 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



[issue45224] Argparse shows required arguments as optional

2021-09-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

In Python3.10, "optional arguments" has been replaced with "options".

We didn't backport the change because it risks breaking tests that rely on 
exact string matches.  Also, it was really a bug, it was just an unfortunate 
choice of words.  "Optional arguments" meant to say that it was one of the -x 
or --fullword style arguments which are called options, so they really are 
"optional arguments" as opposed to "positional arguments".  Unfortunately, the 
most obvious reading of "optional arguments" is as the opposite of "required 
arguments" which is not what was meant.

--
nosy: +rhettinger
resolution:  -> out of date
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue45116] Performance regression 3.10b1 and later on Windows: Py_DECREF() not inlined in PGO build

2021-09-16 Thread Steve Dower


Steve Dower  added the comment:

I agree with Raymond. Let's stop throwing more code at this until we've figured 
out what's going on and revert the change for now.

--

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread Steve Dower


Steve Dower  added the comment:

The build order change was not backported (and should not be), so it's 
unrelated to the failures on 3.9 and 3.10.

More likely this is either a problematic compiler update, or some additional 
data leaking into the build information (e.g. I could see this happening if 
someone added a UTF-8 copyright symbol somewhere instead of an escaped version).

--

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread Steve Dower


Steve Dower  added the comment:

> C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\winnt.h

This appears to be the Windows 11 preview SDK, so most likely it's a bug in 
that. We'll obviously need some logic to not automatically upgrade to this SDK 
on build.

--

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-16 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +26804
pull_request: https://github.com/python/cpython/pull/28392

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread Steve Dower


Change by Steve Dower :


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

___
Python tracker 

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



[issue33809] Expose `capture_locals` parameter in `traceback` convenience functions

2021-09-16 Thread Ulrich Petri


Ulrich Petri  added the comment:

> If we copy all the params from TracebackException (and it will be all params, 
> why only this one?)

Why expose the internal machinery at all?
If all additional parameters (and unless I'm miscounting we're talking about 2) 
were exposed on the convenience functions why add to the developers mental load 
with the underlying implementation?

> more documentation and a higher cognitive load for someone reading the 
> documentation to learn the API.

I would agree if the API in question was ergonomic and the documentation easy 
to read in the first place. I think neither is true for the traceback module 
and its documentation.

Another example from today where I helped a coworker who was unable to figure 
out on his own how to print the current stack with locals:


  from traceback import StackSummary, walk_stack
  
  print("".join(StackSummary.extract(walk_stack(None), 
capture_locals=True).format()))

There are multiple things that make this API non-intuitive:
- Why does walk_stack() need an explicit None argument?
- Why is StackSummary created via the extract() classmethod instead of having a 
regular __init__?
- Why can't extract() be smart if no iterator is passed and figure out on it's 
own if we're in an exception context or not and call walk_stack / walk_tb 
accordingly?
- Why is the result a list if each item can contain multiple internal newlines?

--

___
Python tracker 

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



[issue33809] Expose `capture_locals` parameter in `traceback` convenience functions

2021-09-16 Thread Irit Katriel


Irit Katriel  added the comment:

Feel free to create a new issue and propose a patch.

--

___
Python tracker 

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



[issue45186] Marshal output isn't completely deterministic.

2021-09-16 Thread Eric Snow


Eric Snow  added the comment:

I'm closing this in favor of bpo-34093.

--

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 7.0 -> 8.0
pull_requests: +26806
pull_request: https://github.com/python/cpython/pull/28394

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26807
pull_request: https://github.com/python/cpython/pull/28395

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread Steve Dower


Steve Dower  added the comment:


New changeset f4b94b1f57827083990272b5f282aa1493ae2bf4 by Steve Dower in branch 
'main':
bpo-45220: Avoid automatically selecting the Windows 11 SDK preview when 
building (GH-28393)
https://github.com/python/cpython/commit/f4b94b1f57827083990272b5f282aa1493ae2bf4


--

___
Python tracker 

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



[issue34093] Reproducible pyc: FLAG_REF is not stable.

2021-09-16 Thread Eric Snow


Eric Snow  added the comment:

FYI, I unknowingly created a duplicate of this issue a few days ago, bpo-45186, 
and created a PR for it: https://github.com/python/cpython/pull/28379.  
Interestingly, while I did that PR independently, it has a lot in common with 
Inada-san's second PR.

My interest here is in how frozen modules can be affected by this problem, 
particularly between debug and non-debug builds.  See bpo-45020, where I'm 
working on freezing all the stdlib modules imported during startup.

--
components: +Interpreter Core -Extension Modules
nosy: +eric.snow
type:  -> behavior
versions: +Python 3.11 -Python 3.8

___
Python tracker 

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



[issue45186] Marshal output isn't completely deterministic.

2021-09-16 Thread Eric Snow


Change by Eric Snow :


--
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> Reproducible pyc: FLAG_REF is not stable.

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread miss-islington


miss-islington  added the comment:


New changeset 7ad07eed885ae333d5dfc470b9c11ff2f7b229aa by Miss Islington (bot) 
in branch '3.9':
bpo-45220: Avoid automatically selecting the Windows 11 SDK preview when 
building (GH-28393)
https://github.com/python/cpython/commit/7ad07eed885ae333d5dfc470b9c11ff2f7b229aa


--

___
Python tracker 

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



[issue45225] use map function instead of genexpr in capwords

2021-09-16 Thread speedrun-program

New submission from speedrun-program :

In string.py, the capwords function passes str.join a generator expression, but 
the map function
could be used instead. This is how capwords is currently written:


```py
def capwords(s, sep=None):
"""capwords(s [,sep]) -> string

Split the argument into words using split, capitalize each
word using capitalize, and join the capitalized words using
join.  If the optional second argument sep is absent or None,
runs of whitespace characters are replaced by a single space
and leading and trailing whitespace are removed, otherwise
sep is used to split and join the words.

"""
return (sep or ' ').join(x.capitalize() for x in s.split(sep))
```


This is how capwords could be written:


```py
def capwords(s, sep=None):
"""capwords(s [,sep]) -> string

Split the argument into words using split, capitalize each
word using capitalize, and join the capitalized words using
join.  If the optional second argument sep is absent or None,
runs of whitespace characters are replaced by a single space
and leading and trailing whitespace are removed, otherwise
sep is used to split and join the words.

"""
return (sep or ' ').join(map(str.capitalize, s.split(sep)))
```


These are the benefits:

1. Faster performance which increases with the number of times the str is split.

2. Very slightly smaller .py and .pyc file sizes.

3. Source code is slightly more concise.

This is the performance test code in ipython:


```py
def capwords_current(s, sep=None):
return (sep or ' ').join(x.capitalize() for x in s.split(sep))
​
def capwords_new(s, sep=None):
return (sep or ' ').join(map(str.capitalize, s.split(sep)))
​
tests = ["a " * 10**n for n in range(9)]
tests.append("a " * (10**9 // 2)) # I only have 16GB of RAM
```


These are the results of a performance test using %timeit in ipython:



%timeit x = capwords_current("")
835 ns ± 15.2 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)

%timeit x = capwords_new("")
758 ns ± 35.1 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[0])
977 ns ± 16.9 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)

%timeit x = capwords_new(tests[0])
822 ns ± 30 ns per loop (mean ± std. dev. of 7 runs, 100 loops each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[1])
3.07 µs ± 88.8 ns per loop (mean ± std. dev. of 7 runs, 10 loops each)

%timeit x = capwords_new(tests[1])
2.17 µs ± 194 ns per loop (mean ± std. dev. of 7 runs, 10 loops each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[2])
28 µs ± 896 ns per loop (mean ± std. dev. of 7 runs, 1 loops each)

%timeit x = capwords_new(tests[2])
19.4 µs ± 352 ns per loop (mean ± std. dev. of 7 runs, 10 loops each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[3])
236 µs ± 14.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)

%timeit x = capwords_new(tests[3])
153 µs ± 2 µs per loop (mean ± std. dev. of 7 runs, 1 loops each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[4])
2.12 ms ± 106 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

%timeit x = capwords_new(tests[4])
1.5 ms ± 9.61 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[5])
23.8 ms ± 1.38 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

%timeit x = capwords_new(tests[5])
15.6 ms ± 355 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[6])
271 ms ± 10.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

%timeit x = capwords_new(tests[6])
192 ms ± 807 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[7])
2.66 s ± 14.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

%timeit x = capwords_new(tests[7])
1.95 s ± 26.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[8])
25.9 s ± 80.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

%timeit x = capwords_new(tests[8])
18.4 s ± 123 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
- - - - - - - - - - - - - - - - - - - - 
%timeit x = capwords_current(tests[9])
6min 17s ± 29 s per loop (mean ± std. dev. of 7 runs, 1 loop each)

%timeit x = capwords_new(tests[9])
5min 36s ± 24.8 s per loop (mean ± std. dev. of 7 runs, 1 loop each)



--
components: Library (Lib)
messages: 401981
nosy: speedrun-program
priority: normal
pull_requests: 26808
sev

[issue45063] PEP 657 Fine Grained Error Locations: omit indicators if they are one the whole line, to make tracebacks shorter

2021-09-16 Thread STINNER Victor


STINNER Victor  added the comment:

It seems that I will have to learn to use PYTHONNODEBUGRANGES=1 and 
-Xno_debug_ranges. I close the issue.

--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue45217] ConfigParser does not accept "No value" reversely to the doc

2021-09-16 Thread Nikita Sobolev


Nikita Sobolev  added the comment:

Try this:

```
from configparser import ConfigParser
ConfigParser(allow_no_value=True).read('bug.ini')
```

It should work! :)

But, the docs are missing this config value here (which caused this issue):

> Values can be omitted, in which case the key/value delimiter may also be left 
> out.

https://github.com/python/cpython/blame/f4b94b1f57827083990272b5f282aa1493ae2bf4/Doc/library/configparser.rst#L264

I will update the docs.

--
nosy: +sobolevn

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset f798cef87faeb428bdb9ebf73df1a6146304 by Miss Islington (bot) 
in branch '3.10':
bpo-45220: Avoid automatically selecting the Windows 11 SDK preview when 
building (GH-28393) (GH-28394)
https://github.com/python/cpython/commit/f798cef87faeb428bdb9ebf73df1a6146304


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue45217] ConfigParser does not accept "No value" reversely to the doc

2021-09-16 Thread Nikita Sobolev


Change by Nikita Sobolev :


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

___
Python tracker 

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



[issue45225] use map function instead of genexpr in capwords

2021-09-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset a59ede244714455aa9ee8637608e019a20fa2ca6 by speedrun-program in 
branch 'main':
bpo-45225: use map function instead of genexpr in capwords (GH-28342)
https://github.com/python/cpython/commit/a59ede244714455aa9ee8637608e019a20fa2ca6


--
nosy: +rhettinger

___
Python tracker 

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



[issue45225] use map function instead of genexpr in capwords

2021-09-16 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks for the PR.

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

___
Python tracker 

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



[issue43574] Regression in overallocation for literal list initialization in v3.9+

2021-09-16 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +rhettinger

___
Python tracker 

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



[issue45224] Argparse shows required arguments as optional

2021-09-16 Thread Khalid Mammadov


Khalid Mammadov  added the comment:

May I suggest to change it again so we two sections: required and optional? 
This can help to be more clear from usage perspective. I have changed it 
locally and it looks like below:

usage: myprogram.py [-h] [--foo FOO] --bar BAR

required arguments:
  --bar BAR   foo help

optional arguments:
  -h, --help  show this help message and exit
  --foo FOO   foo help

--

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-16 Thread Eric Snow


Eric Snow  added the comment:


New changeset fdc6b3d9316501d2f0068a1bf4334debc1949e62 by Eric Snow in branch 
'main':
bpo-45020: Drop the frozen .h files from the repo. (gh-28392)
https://github.com/python/cpython/commit/fdc6b3d9316501d2f0068a1bf4334debc1949e62


--

___
Python tracker 

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



[issue45224] Argparse shows required arguments as optional

2021-09-16 Thread Khalid Mammadov


Khalid Mammadov  added the comment:

This is another, larger example, where I actually stumbled on this when looking 
into Apache Airflow project. Below makes it confusing to see what is actually 
required and what not. Unless you look for square brackets. Would be it much 
nicer to list required ones explicitly rather than looking into options and 
figuring out which one is a must?

usage: airflow users create [-h] -e EMAIL -f FIRSTNAME -l LASTNAME [-p 
PASSWORD] -r ROLE [--use-random-password] -u USERNAME

Create a user

optional arguments:
  -h, --helpshow this help message and exit
  -e EMAIL, --email EMAIL
Email of the user
  -f FIRSTNAME, --firstname FIRSTNAME
First name of the user
  -l LASTNAME, --lastname LASTNAME
Last name of the user
  -p PASSWORD, --password PASSWORD
Password of the user, required to create a user without 
--use-random-password
  -r ROLE, --role ROLE  Role of the user. Existing roles include Admin, User, 
Op, Viewer, and Public
  --use-random-password
Do not prompt for password. Use random string instead. 
Required to create a user without --password 
  -u USERNAME, --username USERNAME
Username of the user

examples:
To create an user with "Admin" role and username equals to "admin", run:

$ airflow users create \
  --username admin \
  --firstname FIRST_NAME \
  --lastname LAST_NAME \
  --role Admin \
  --email ad...@example.org

airflow users create command error: the following arguments are required: 
-e/--email, -f/--firstname, -l/--lastname, -r/--role, -u/--username, see help 
above.

--

___
Python tracker 

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



[issue45220] Windows builds sometimes fail on Azure and GitHub Action: fatal error RC1116: RC terminating after preprocessor errors

2021-09-16 Thread Steve Dower


Change by Steve Dower :


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



[issue45215] Add docs for Mock name and parent args and deprecation warning when wrong args are passed

2021-09-16 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I forgot to include example of the breakage:

>>> m=Mock(name=1)
>>> m
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/ak/opensource/cpython2/Lib/unittest/mock.py", line 735, in 
__repr__
name = self._extract_mock_name()
   ^
  File "/Users/ak/opensource/cpython2/Lib/unittest/mock.py", line 732, in 
_extract_mock_name
return ''.join(_name_list)
   ^^^
TypeError: sequence item 0: expected str instance, int found

>>> m=Mock(parent='foo')
>>> m
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/ak/opensource/cpython2/Lib/unittest/mock.py", line 735, in 
__repr__
name = self._extract_mock_name()
   ^
  File "/Users/ak/opensource/cpython2/Lib/unittest/mock.py", line 719, in 
_extract_mock_name
_name_list.append(_parent._mock_new_name + dot)
  ^^
AttributeError: 'str' object has no attribute '_mock_new_name'

--

___
Python tracker 

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



[issue22699] Module source files not found when cross-compiling

2021-09-16 Thread Isuru Fernando


Change by Isuru Fernando :


--
keywords: +patch
nosy: +isuruf
nosy_count: 8.0 -> 9.0
pull_requests: +26810
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28397

___
Python tracker 

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



[issue45120] Windows cp encodings "UNDEFINED" entries update

2021-09-16 Thread Steve Dower


Steve Dower  added the comment:

Thanks for the PR.

Just wanted to acknowledge that we've seen it. Unfortunately, I'm not feeling 
confident to take this change right now - encodings are a real minefield, and 
we need to think through the implications. It's been a while since I've done 
that, so could take some time.

Unless one of the other people who have spent time working on this comes in and 
says they've thought it through and this is the best approach. In which case 
I'll happily trust them :)

--
nosy: +eryksun, serhiy.storchaka

___
Python tracker 

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



[issue17005] Add a topological sort algorithm

2021-09-16 Thread Éric Araujo

Change by Éric Araujo :


--
versions: +Python 3.9 -Python 3.8

___
Python tracker 

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



[issue40503] PEP 615: Add zoneinfo module

2021-09-16 Thread Isuru Fernando

Isuru Fernando  added the comment:

> If anyone building Python for Windows shows up needing support for this, we 
> can re-visit the issue — I don't believe it's technically infeasible, just 
> that the usage patterns of Python on Windows mean that it's not worth doing.

At conda-forge, we need this and our current solution is
https://github.com/conda-forge/python-feedstock/blob/8195ba1178041b7461238e8c5680eee62f5ea9d0/recipe/patches/0032-Fix-TZPATH-on-windows.patch#L19

I can change to check if that directory exists. What do you think?

--
nosy: +FFY00, isuruf

___
Python tracker 

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



[issue34093] Reproducible pyc: FLAG_REF is not stable.

2021-09-16 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +26811
pull_request: https://github.com/python/cpython/pull/28379

___
Python tracker 

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



  1   2   >