[issue46921] Vectorcall support for super()

2022-03-05 Thread Ken Jin


Change by Ken Jin :


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



[issue37609] support "UNC" device paths in ntpath.splitdrive

2022-03-05 Thread Barney Gale


Change by Barney Gale :


--
pull_requests: +29822
pull_request: https://github.com/python/cpython/pull/31702

___
Python tracker 

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



[issue46921] Vectorcall support for super()

2022-03-05 Thread Ken Jin


Ken Jin  added the comment:


New changeset 602024e6e12c69d836aa191d63db75862aec2493 by Ken Jin in branch 
'main':
bpo-46921: Vectorcall support for `super()` (GH-31687)
https://github.com/python/cpython/commit/602024e6e12c69d836aa191d63db75862aec2493


--

___
Python tracker 

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



Re: Behavior of the for-else construct

2022-03-05 Thread Avi Gross via Python-list
I am not clear on what you are commenting, Dennis. You are responding to what I 
do not believe I wrote. You did not quote the part of my message where I wrote 
what "I" did in the early 80's and did not say when PASCAL was available 
elsewhere.

"I paid no attention to where PASCAL was being used other than I did much of my 
grad school work in PASCAL in the early 80's including my thesis being a 
document that could be typeset or run from the same file ;-)"

I might have encountered it in the early 70's had I had any room in my college 
course schedule where I ended up with a triple major in other subjects or while 
I was in Medical school. But no, I only went back to study C.S. afterwards. So, 
I apologize for being late. Heck I was also not there when ALGOL was created or 
FORTRAN, let alone COBOL! But if it helps, I taught FORTRAN and other languages 
to undergrads ;-)

-Original Message-
From: Dennis Lee Bieber 
To: python-list@python.org
Sent: Sat, Mar 5, 2022 7:00 pm
Subject: Re: Behavior of the for-else construct


On Sat, 5 Mar 2022 21:40:08 + (UTC), Avi Gross 

declaimed the following:



>I am not sure how we end up conversing about PASCAL on a Python forum. But it 
>is worth considering how people educated in aspects of Computer Science often 
>come from somewhat different background and how it flavors what they do now.

>

    You'd prefer REBOL, perhaps? 



    REXX at least has some structure to it 



    NB: Pascal has, like Ada, always been a  name -- not

like the origins of COBOL, FORTRAN, BASIC, et al.



>I paid no attention to where PASCAL was being used other than I did much of my 
>grad school work in PASCAL in the early 80's including my thesis being a 
>document that could be typeset or run from the same file ;-)

>

    Very early? The common versions were probably UCSD (running on UCSD

P-System); or a port of the P-4 compiler (which had been published in book

form) -- maybe a "tinyPascal" (integer only I suspect). Radio Shack did

provide Alcor Pascal for the TRS-80.



    Later, you might have encountered TurboPascal -- which bore little

resemblance to a Jensen Pascal. 



    J was one-program<>one-file (no link libraries, no "include" files as

I recall); very limited math functions if one is trying for scientific

applications (sin, cos, arctan were the trig functions I recall), and that

very unfriendly I/O system (console I/O required special handling from file

I/O as Pascal does a one-element pre-read when an I/O channel is opened --

which occurs on program load for stdin, much before a program could output

a prompt to the user).



    Even my first exposure to VAX/VMS Pascal, which did allow for separate

compilation and linking, required me to declare interfaces to the FORTRAN

run-time library to get advanced math functions (I believe later versions

incorporated the FORTRAN math natively).









-- 

    Wulfraed                 Dennis Lee Bieber         AF6VN

    wlfr...@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/

-- 

https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue40512] [subinterpreters] Meta issue: per-interpreter GIL

2022-03-05 Thread Jon Parise


Change by Jon Parise :


--
nosy: +jon

___
Python tracker 

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



[issue46864] Deprecate ob_shash in BytesObject

2022-03-05 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 2d8b764210c8de10893665aaeec8277b687975cd by Inada Naoki in branch 
'main':
bpo-46864: Deprecate PyBytesObject.ob_shash. (GH-31598)
https://github.com/python/cpython/commit/2d8b764210c8de10893665aaeec8277b687975cd


--

___
Python tracker 

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



[issue46864] Deprecate ob_shash in BytesObject

2022-03-05 Thread Inada Naoki


Change by Inada Naoki :


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



[issue37609] support "UNC" device paths in ntpath.splitdrive

2022-03-05 Thread Barney Gale


Barney Gale  added the comment:

I'd like to pick this up, as it would allow us to remove a duplicate 
implementation in pathlib with its own shortcomings.

If using native functionality if difficult to get right, could I put @eryksun's 
splitdrive.py implementation up for review?

--
nosy: +barneygale

___
Python tracker 

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



Re: Cpython: when to incref before insertdict

2022-03-05 Thread Inada Naoki
On Sat, Mar 5, 2022 at 11:22 PM Marco Sulla
 wrote:
>
> I noticed that some functions inside dictobject.c that call insertdict
> or PyDict_SetItem do an incref of key and value before the call, and a
> decref after it. An example is dict_merge.

First of all, insertdict and PyDict is totally different about
reference ownership handling.

* PyDict_SetItem borrows reference of key and value from the caller as
usual Python/C APIs. And it INCREF them before calling the
insertdict().
* insertdict() takes the reference from its caller. In other words,
insertdict() moves the owner of reference from its caller to the dict.

merge_dict is very special and complex case.
I assume you are talking about this part.
https://github.com/python/cpython/blob/6927632492cbad86a250aa006c1847e03b03e70b/Objects/dictobject.c#L2885-L2912

In general, when reference is borrowed from a caller, the reference is
available during the API.
But merge_dict borrows reference of key/value from other dict, not caller.
So dict_merge must have strong reference of key/value by INCREF before
calling any APIs (e.g. _PyDict_Contains_KnownHash).
That's why dict_merge calls INCREF key/value **twice** before calling
insertdict, and DECREF key/value **once** after it.

> Other functions, such as
> _PyDict_FromKeys, don't do an incref before.
>

Again, insertdict takes the reference. So _PyDict_FromKeys() **does**
INCREF before calling insertdict, when key/value is borrowed
reference.
https://github.com/python/cpython/blob/6927632492cbad86a250aa006c1847e03b03e70b/Objects/dictobject.c#L2287-L2290
https://github.com/python/cpython/blob/6927632492cbad86a250aa006c1847e03b03e70b/Objects/dictobject.c#L2309-L2311

On the other hand, slow path uses PyIter_Next() which returns strong
reference. So no need to INCREF it.
Additionally, the slow path uses PyDict_SetItem(), not insertdict().
PyDict_SetItem() does INCREF key/value for insertdict.
So the slow path need to DECREF(key).
https://github.com/python/cpython/blob/6927632492cbad86a250aa006c1847e03b03e70b/Objects/dictobject.c#L2327-L2329

This is complete guide why/when INCREF/DECREF key/value.
-- 
Inada Naoki  
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46935] import of submodule polutes global namespace

2022-03-05 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

This might be something that rapidfuzz can fix, rather than CPython. In 
whatever import process rapidfuzz uses, it populates sys.modules with a module 
named `Levenshtein` in addition to 'rapidfuzz.distance.Levenshtein'. You might 
be able to request that they change something there.

Python 3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC v.1929 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> m1 = set(sys.modules.keys())
>>> import numpy
>>> m2 = set(sys.modules.keys())
>>> import rapidfuzz
>>> m3 = set(sys.modules.keys())
>>> m2 - m1
{'posixpath', 'numpy.random._pcg64', 'numpy.fft._pocketfft_internal', 
'numpy.core._dtype', 'cython_runtime', 'numpy.random._sfc64', 'urllib', 
'numpy.core.einsumfunc', 'sre_parse', 'numpy.polynomial.laguerre', 
'numpy.fft._pocketfft', 'numpy.lib._iotools', 'numpy.core._exceptions', 
'numpy.random._pickle', 'numpy.lib.twodim_base', 'numpy.polynomial._polybase', 
'numpy.lib._datasource', 'copyreg', 'numpy.random._philox', '_ctypes', 
'numpy.core._ufunc_config', 'platform', 'numpy.lib.histograms', 
'numpy.lib.mixins', 'numpy.core._asarray', 'numpy.polynomial.legendre', 
'numpy.polynomial.polyutils', 'subprocess', 'fnmatch', 'numpy.ctypeslib', 
'ast', 'sre_compile', 'json.scanner', 'numpy.core.arrayprint', 'textwrap', 
'numpy.core.multiarray', 'datetime', 'inspect', 'numpy.core.function_base', 
'hmac', 'numpy.lib.utils', '_json', 'signal', 'numpy.core.machar', 
'numpy.ma.core', 'pathlib', 'numbers', 'numpy.core._methods', 
'numpy.lib.type_check', 'numpy.core.defchararray', 'numpy.core.getlimits', 'n
 umpy.lib.ufunclike', 'numpy.version', 'select', '_sre', 
'numpy.core._dtype_ctypes', 'numpy.lib.arrayterator', 'random', '_blake2', 
'numpy.fft', 'token', 'numpy.core._string_helpers', 'numpy', '_hashlib', 
'opcode', 'tokenize', 'numpy.random._bounded_integers', 'numpy.random.mtrand', 
'ctypes._endian', '_weakrefset', 'numpy.ma', 'numpy.lib.nanfunctions', 
'_random', 'numpy.lib.function_base', '_sha512', 'bisect', 
'numpy.core.records', 'numpy._globals', '_compat_pickle', 'urllib.parse', 
'numpy.random.bit_generator', 'numpy.linalg._umath_linalg', 
'numpy.core._add_newdocs_scalars', 'numpy.polynomial.hermite', 'base64', 
'numpy.linalg.linalg', 'numpy.core._multiarray_tests', '_cython_0_29_24', 
'hashlib', '_struct', 'numpy.lib.arraypad', 'numpy.core', 'msvcrt', 
'numpy.ma.extras', 'numpy.lib.index_tricks', '_locale', 'numpy.lib.shape_base', 
'numpy.compat._inspect', 'numpy.polynomial.hermite_e', 'pickle', 
'numpy._distributor_init', 'numpy.lib._version', '_datetime', 'secrets', 
'numpy.lib.polyno
 mial', 'numpy.core.numerictypes', '_ast', 'numpy.lib.scimath', '_winapi', 
'numpy.matrixlib.defmatrix', '_socket', 'numpy.core.shape_base', 
'numpy.lib.format', 'dis', 'numpy.core._multiarray_umath', 'weakref', 
'numpy.compat.py3k', 'json', 'numpy.core.umath', 'numpy.core.numeric', 
'numpy.core.memmap', 'sre_constants', 'numpy.compat', 
'numpy.core._add_newdocs', 'numpy.polynomial.chebyshev', 'math', 
'numpy.random._common', 'numpy.linalg', 'numpy.random', 're', 'threading', 
'numpy._pytesttester', '_bisect', 'collections.abc', 'socket', 
'numpy.lib.stride_tricks', 'linecache', 'numpy.lib', 'numpy.fft.helper', 
'numpy.core.fromnumeric', 'json.encoder', 'numpy.linalg.lapack_lite', 
'selectors', 'numpy.polynomial', 'numpy.core._internal', 'numpy.__config__', 
'numpy.polynomial.polynomial', 'numpy._version', 'errno', 'struct', 'ctypes', 
'numpy.random._mt19937', 'binascii', 'numpy.lib.npyio', 
'numpy.random._generator', 'numpy.lib.arraysetops', 'numpy.matrixlib', 
'_opcode', 'json.decoder', 'numpy.c
 ore._type_aliases', 'enum', 'numpy.core.overrides', '_pickle'}
>>> m3 - m2
{'rapidfuzz.process', 'rapidfuzz.cpp_process', 'rapidfuzz.string_metric', 
'rapidfuzz.distance.Levenshtein', 'rapidfuzz.cpp_utils', 
'rapidfuzz.cpp_process_cdist', 'cpp_utils', 'cpp_process_cdist', 'rapidfuzz', 
'Jaro', '_heapq', 'rapidfuzz.distance.JaroWinkler', 'cpp_fuzz', 
'rapidfuzz.distance.Hamming', '_cython_3_0_0a10', 'rapidfuzz.utils', 
'cpp_process', 'Hamming', 'rapidfuzz.distance', 'rapidfuzz.distance.Jaro', 
'JaroWinkler', '_initialize', 'rapidfuzz.cpp_fuzz', 'cpp_string_metric', 
'rapidfuzz.distance._initialize', 'rapidfuzz.distance.Indel', 'rapidfuzz.fuzz', 
'Levenshtein', 'heapq', 'Indel', 'array', 'rapidfuzz.cpp_string_metric'}
>>> sys.modules['rapidfuzz.distance.Levenshtein'] is sys.modules['Levenshtein']
True


A temporary workaround could be to delete `sys.modules['Levenshtein']`:

>>> import rapidfuzz
>>> del sys.modules['Levenshtein']
>>> import Levenshtein
>>> Levenshtein.__file__ # not the rapidfuzz one
'C:\\Users\\sween\\AppData\\Roaming\\Python\\Python310\\site-packages\\Levenshtein\\__init__.py'

--
nosy: +Dennis Sweeney

___
Python tracker 

___

Re: Behavior of the for-else construct

2022-03-05 Thread Dennis Lee Bieber
On Sat, 5 Mar 2022 21:40:08 + (UTC), Avi Gross 
declaimed the following:

>I am not sure how we end up conversing about PASCAL on a Python forum. But it 
>is worth considering how people educated in aspects of Computer Science often 
>come from somewhat different background and how it flavors what they do now.
>
You'd prefer REBOL, perhaps? 

REXX at least has some structure to it 

NB: Pascal has, like Ada, always been a  name -- not
like the origins of COBOL, FORTRAN, BASIC, et al.

>I paid no attention to where PASCAL was being used other than I did much of my 
>grad school work in PASCAL in the early 80's including my thesis being a 
>document that could be typeset or run from the same file ;-)
>
Very early? The common versions were probably UCSD (running on UCSD
P-System); or a port of the P-4 compiler (which had been published in book
form) -- maybe a "tinyPascal" (integer only I suspect). Radio Shack did
provide Alcor Pascal for the TRS-80.

Later, you might have encountered TurboPascal -- which bore little
resemblance to a Jensen Pascal. 

J was one-program<>one-file (no link libraries, no "include" files as
I recall); very limited math functions if one is trying for scientific
applications (sin, cos, arctan were the trig functions I recall), and that
very unfriendly I/O system (console I/O required special handling from file
I/O as Pascal does a one-element pre-read when an I/O channel is opened --
which occurs on program load for stdin, much before a program could output
a prompt to the user).

Even my first exposure to VAX/VMS Pascal, which did allow for separate
compilation and linking, required me to declare interfaces to the FORTRAN
run-time library to get advanced math functions (I believe later versions
incorporated the FORTRAN math natively).




-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help: Unable to find IDLE folder inside the Python Lib folder

2022-03-05 Thread MRAB

On 2022-03-05 20:36, Deji Olofinboba via Python-list wrote:


Dear Python officer,
Please I am new to programming. I have justinstalled the python 3.10.2. After 
the installation, I was able to locate thePython Shell but unable to locate 
IDLE despite checking it before downloading in the python installation folder. 
I also reinstalled Python and checked IDLE; still the IDLE is still missing. 
Please. explain to me how I can retrieve the python IDLE.
Thank You,


If you're on Windows 10, type "idle" into the search box on the taskbar.
Alternatively, look in python_folder\Lib\idlelib for idle.bat if you're 
on an older version of Windows.

--
https://mail.python.org/mailman/listinfo/python-list


[issue46911] Early tracing has lineno=None for modules

2022-03-05 Thread Ned Batchelder


Ned Batchelder  added the comment:

Maybe I'm missing something during normal execution, but I'm only seeing this 
effect now during this super-early encodings.py trick.  I don't mind just 
special-casing the Nones in this case.

--

___
Python tracker 

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



[issue40172] ZipInfo corrupts file names in some old zip archives

2022-03-05 Thread Yudi Levi


Yudi Levi  added the comment:

The main issue is that when extracting older zip files, files are actually 
written to disk with corrupted (altered) names.
Unfortunately it's been a while since I saw this issue and I can't tell if it 
was fixed or if I simply can't reproduce it.
I do see that encoding/decoding in ZipInfo is still inconsistent, sometimes 
uses ascii codepage and sometimes uses cp437 codepage which seems wrong to me.
Not sure how we should handle it but I think that switching the default ascii 
encoding to cp437 to be consistent with the old implementation (and with the 
filename decoding) seems like the right way to go.

--

___
Python tracker 

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



[issue46934] Started multiprocessing.Process instances are unserialisable

2022-03-05 Thread Géry

Change by Géry :


--
title: A started multiprocessing.Process instance cannot be serialised -> 
Started multiprocessing.Process instances are unserialisable

___
Python tracker 

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



[issue46934] A started multiprocessing.Process instance cannot be serialised

2022-03-05 Thread Géry

Change by Géry :


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

___
Python tracker 

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



Help: Unable to find IDLE folder inside the Python Lib folder

2022-03-05 Thread Deji Olofinboba via Python-list

Dear Python officer,
Please I am new to programming. I have justinstalled the python 3.10.2. After 
the installation, I was able to locate thePython Shell but unable to locate 
IDLE despite checking it before downloading in the python installation folder. 
I also reinstalled Python and checked IDLE; still the IDLE is still missing. 
Please. explain to me how I can retrieve the python IDLE.
Thank You,

 

Deji Olofinboba 

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46935] import of submodule polutes global namespace

2022-03-05 Thread Max Bachmann


Max Bachmann  added the comment:

It appears this only occurs when a C Extension is involved. When the so is 
imported first it is preferred over the .py file that the user would like to 
import. I could not find any documentation on this behavior, so I assume that 
this is not the intended.

My current workaround is the usage of a unique name for the C Extension and the 
importing everything from a Python file with the corresponding name.

--

___
Python tracker 

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



[issue38364] inspect.iscoroutinefunction / isgeneratorfunction / isasyncgenfunction can't handle partialmethod objects

2022-03-05 Thread Jameel A.


Change by Jameel A. :


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



[issue46935] import of submodule polutes global namespace

2022-03-05 Thread Max Bachmann


New submission from Max Bachmann :

In my environment I installed the following two libraries:
```
pip install rapidfuzz
pip install python-Levenshtein
```
Those two libraries have the following structures:
rapidfuzz
|-distance
  |- __init__.py (from . import Levenshtein)
  |- Levenshtein.*.so
|-__init__.py (from rapidfuzz import distance)


Levenshtein
|-__init__.py

When importing Levenshtein first everything behaves as expected:
```
>>> import Levenshtein
>>> Levenshtein.
Levenshtein.apply_edit(   Levenshtein.jaro_winkler( Levenshtein.ratio(
Levenshtein.distance( Levenshtein.matching_blocks(  
Levenshtein.seqratio(
Levenshtein.editops(  Levenshtein.median(   
Levenshtein.setmedian(
Levenshtein.hamming(  Levenshtein.median_improve(   
Levenshtein.setratio(
Levenshtein.inverse(  Levenshtein.opcodes(  
Levenshtein.subtract_edit(
Levenshtein.jaro( Levenshtein.quickmedian(   
>>> import rapidfuzz
>>> Levenshtein.
Levenshtein.apply_edit(   Levenshtein.jaro_winkler( Levenshtein.ratio(
Levenshtein.distance( Levenshtein.matching_blocks(  
Levenshtein.seqratio(
Levenshtein.editops(  Levenshtein.median(   
Levenshtein.setmedian(
Levenshtein.hamming(  Levenshtein.median_improve(   
Levenshtein.setratio(
Levenshtein.inverse(  Levenshtein.opcodes(  
Levenshtein.subtract_edit(
Levenshtein.jaro( Levenshtein.quickmedian( 
```

However when importing rapidfuzz first it import 
`rapidfuzz.distance.Levenshtein` when running `import Levenshtein`
```
>>> import rapidfuzz
>>> Levenshtein
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'Levenshtein' is not defined
>>> import Levenshtein
>>> Levenshtein.
Levenshtein.array(  Levenshtein.normalized_distance(
Levenshtein.similarity(
Levenshtein.distance(   Levenshtein.normalized_similarity(  
Levenshtein.editops(Levenshtein.opcodes( 
```

My expectation was that in both cases `import Levenshtein` should import the 
`Levenshtein` module. I could reproduce this behavior on all Python versions I 
had available (Python3.8 - Python3.10) on Ubuntu and Fedora.

--
components: Interpreter Core
messages: 414599
nosy: maxbachmann
priority: normal
severity: normal
status: open
title: import of submodule polutes global namespace
type: behavior
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue38364] inspect.iscoroutinefunction / isgeneratorfunction / isasyncgenfunction can't handle partialmethod objects

2022-03-05 Thread Jameel Al-Aziz


Jameel Al-Aziz  added the comment:

I've recently ran into this via unittest.mock.patch.object. Mocking an 
asynchronous partial method returns MagicMock and not AsyncMagicMock, causing 
some pretty hard to debug failures.

--
nosy: +me3

___
Python tracker 

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



[issue46934] A started multiprocessing.Process instance cannot be serialised

2022-03-05 Thread Géry

New submission from Géry :

The Python program:

```
import multiprocessing
import time


class Application:

def __init__(self):
self._event = multiprocessing.Event()
self._processes = [
multiprocessing.Process(target=self._worker)
for _ in range(multiprocessing.cpu_count())]

def _worker(self):
while not self._event.is_set():
print(multiprocessing.current_process().name)
time.sleep(1)

def start(self):
for process in self._processes:
print('starting')
process.start()

def stop(self):
self._event.set()
for process in self._processes:
process.join()


if __name__ == '__main__':
application = Application()
application.start()
time.sleep(3)
application.stop()
```

Its output:

```none
starting
starting
Traceback (most recent call last):
  File "/Users/maggyero/Desktop/application.py", line 31, in 
application.start()
  File "/Users/maggyero/Desktop/application.py", line 21, in start
process.start()
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py",
 line 121, in start
self._popen = self._Popen(self)
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py",
 line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py",
 line 284, in _Popen
return Popen(process_obj)
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py",
 line 32, in __init__
super().__init__(process_obj)
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_fork.py",
 line 19, in __init__
self._launch(process_obj)
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py",
 line 47, in _launch
reduction.dump(process_obj, fp)
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/reduction.py",
 line 60, in dump
ForkingPickler(file, protocol).dump(obj)
TypeError: cannot pickle 'weakref' object
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/spawn.py",
 line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/spawn.py",
 line 126, in _main
self = reduction.pickle.load(from_parent)
  File 
"/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/synchronize.py",
 line 110, in __setstate__
self._semlock = _multiprocessing.SemLock._rebuild(*state)
FileNotFoundError: [Errno 2] No such file or directory
```

In the function `Application.__init__`, each call 
`multiprocessing.Process(target=self._worker)` initializes a 
`multiprocessing.Process` instance with the instance method `self._worker` as 
its `target` argument. `self._worker` is bound to `self` which has the instance 
attribute `self._processes`.

In the function `Application.start`, each call `process.start()` serialises the 
`target` argument and therefore `self._processes`. `self._processes` is a list 
of `multiprocessing.Process` instances, initially not started yet. The first 
call `process.start()` starts the first `multiprocessing.Process` instance in 
that list without issue, but the second call `process.start()` fails.

So a started `multiprocessing.Process` instance cannot be serialised.

The root of the problem is that the `start` method of a 
`multiprocessing.Process` instance sets its `_popen` instance attribute to a 
`multiprocessing.popen_*.Popen` instance. The initialization of that instance 
performs these two steps (among others):

1. For a `multiprocessing.popen_spawn_posix.Popen` instance, a 
`multiprocessing.popen_spawn_win32.Popen` instance, or a 
`multiprocessing.popen_forkserver.Popen` instance but not a 
`multiprocessing.popen_fork.Popen` instance (i.e. for the start method 
`'spawn'` or the start method `'forkserver'` but not the start method 
`'fork'`), it 
[serialises](https://github.com/python/cpython/blob/v3.10.2/Lib/multiprocessing/popen_spawn_posix.py#L47)
 the `multiprocessing.Process` instance for writing it to the end of the pipe 
used by the parent process to communicate with the child process so that the 
child process can execute the `run` method of the `multiprocessing.Process` 
instance.

2. It 

Re: Behavior of the for-else construct

2022-03-05 Thread Cameron Simpson
On 05Mar2022 17:48, Avi Gross  wrote:
>Since we still seem to be dreaming, I wonder when someone will suggest using 
>some variation of the new match statement.

Ugh :-)

But...

What if break were implemented with an exception, like StopIteration but 
for interruption instead of stop? And for-loops were an implied 
try/except:

for ...
except BrokenIteration: # <-- implied
  pass

and you could go:

for ...
except BrokenIteration:
  ... a break occurred
else:
  ... a break did not occur

and, indeed,

for ...
except BrokenIteration:
  ... a break occurred
except StopIteration as stopped:
  print("I did", stopped.count, "iterations")
else:
  # not reached because of the "except StopIteration" above
  ... a break did not occur

if we wanted to cover off the count iterations wish item.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Behavior of the for-else construct

2022-03-05 Thread Avi Gross via Python-list
I am not sure how we end up conversing about PASCAL on a Python forum. But it 
is worth considering how people educated in aspects of Computer Science often 
come from somewhat different background and how it flavors what they do now.

I paid no attention to where PASCAL was being used other than I did much of my 
grad school work in PASCAL in the early 80's including my thesis being a 
document that could be typeset or run from the same file ;-)

And my first job in the field also was doing programming in PASCAL. At the time 
it seemed to be a new and upcoming language with lots of nifty features. It 
seemed to have so many ways it was an improvement on languages I had been using 
including BASIC and Fortran and versions of LISP. So it was a tad surprising 
when my next job at Bell Labs focused on C (and later C++) as well as a large 
array of utilities and small languages in the UNIX world. PASCAL was nowhere to 
be seen nor others that arrived to take over the world like Modula and Ada, and 
yet didn't. It depends where you are and on your perspective, and perhaps it 
survived in places like Europe and often has been enhanced. We have mentioned 
how things like Fortran keep evolving and, in any case, tons of the code we use 
in aspects of Python and especially some add-in modules, is from libraries of 
well-honed   libraries of functions written in Fortran or C or I am sure in 
some cases even assembler languages.

I wonder if some languages of the future may supersede languages like Python 
but retain aspects of them in a similar way? As a hobby, I study lots of 
languages to see if they add anything or are likely to take over. Some seem to 
really be focused on a company like Microsoft or Google using it for their own 
purposes and others who wish to play in their arena may have to go along to 
operate there. Others seem to be the kind of things academics invent to play 
with various ideas. So will SCALA or GO or RUST become major players or will 
they wither away? Will languages that make major changes that make older 
software not compatible, think Python or PERL as examples, end up stronger or 
... motivate some to abandon their projects and switch to a new 
language/system/paradigm?

I do a lot of data manipulation in an assortment of languages including 
multiple methods within a language. I can sometimes see how a person asking for 
features or writing programs has been influenced by earlier experiences. 
Database people who started with a relational database and mainly used some 
dialect of SQL, may face some problems in their own way and think making lots 
of smaller tables in third normal form and constantly doing all kinds of table 
merges is the natural way to do things. Those who start doing things using 
Python or R may view things quite differently and often see ways to do things 
gradually and in a pipelined method and not do what is seen as expensive 
operations like some kinds of merge. I am not saying everyone does things in a 
stereotypical way, just that people learn tools and methods and it may show.

Given how much faster some things have become, even hybrid programmers may play 
games. Yes, you can issue SQL to load data from a database into your Python or 
R programs but some issue a very basic command and then massage it locally 
while others do most of the processing in the SQL component so that less is 
dragged in. Some habits persist even after circumstances change.

I have little against PASCAL and have not looked at how it has evolved but 
found it a very limiting language after a while. But I find most languages 
somewhat limited and now think they should be. What makes a language great for 
me is if it does not try to be too complete but provides a way to extend it so 
people can come up with their own ways to do more complex things, including 
various ways to do graphics or statistical analyses and so on, as sort of 
add-ons which become little languages or worlds grafted on when needed and 
ignored when not.

Python qualifies albeit it is already too bloated! LOL!


Avi

Palm: 3rd digit from the right, vertically.


-Original Message-
From: Michael F. Stemper 
To: python-list@python.org
Sent: Sat, Mar 5, 2022 1:39 pm
Subject: Re: Behavior of the for-else construct


On 04/03/2022 18.11, Peter J. Holzer wrote:

> On 2022-03-04 23:47:09 +, Avi Gross via Python-list wrote:

>> I am not sure a reply is needed, Peter, and what you say is true. But

>> as you point out, when using a German keyboard, I would  already have

>> a way to enter symbols like ä, ö, ü and ß and no reason not to include

>> them in variable names and so on if UNICODE is being used properly. I

>> can use my last name in German notation as a variable in Python now:

>>

>> Groß = 144

>> Groß / 12

>> 12.0

> 

> Yes, I'm using umlauts occasionally in variable names in Python, and

> I've also used Greek characters and others.

> 

> But in Python I CAN use them. I DON'T HAVE to.

> 

> 

[issue46920] Remove code made dead long ago with #if 0

2022-03-05 Thread Oleg Iarygin


Oleg Iarygin  added the comment:

I reverted my changes in Modules/_ctypes/libffi_osx/x86/x86-ffi64.c and 
Modules/_decimal/libmpdec/*step.c to not disturb third-party vendored libraries.

As a result, macOS component is no longer affected along with the corresponding 
experts in a nosy list.

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

___
Python tracker 

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



[issue46933] Make pwd module optional for wasm32-emscripten and wasi

2022-03-05 Thread Christian Heimes


Change by Christian Heimes :


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

___
Python tracker 

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



[issue46933] Make pwd module optional for wasm32-emscripten and wasi

2022-03-05 Thread Christian Heimes


New submission from Christian Heimes :

WebAssembly platforms like wasm32-emscripten and wasm32-wasi don't have a 
typical user and group database.

WASI platform does not provide necessary API functions at all. Emscripten 
provides dummy stubs. On Emscripten the pwd module compiles, but is 
non-functional:

Python 3.11.0a4+ (heads/main-dirty:b1a3446, Jan 25 2022, 10:19:07) [Clang 
14.0.0 (https://github.com/llvm/llvm-project f142c45f1e494f8dbdcc1bcf1412 on 
emscripten
Type "help", "copyright", "credits" or "license" for more information.
>>> import pwd, os
>>> os.getuid()
0
>>> pwd.getpwall()
[]
>>> pwd.getpwuid(os.getuid())
Traceback (most recent call last):
  File "", line 1, in 
KeyError: 'getpwuid(): uid not found: 0'

I propose to make the pwd optional and catch import error in few places where 
the pwd module is used to look up user home directory.

--
assignee: christian.heimes
components: Library (Lib)
messages: 414595
nosy: christian.heimes
priority: normal
severity: normal
status: open
title: Make pwd module optional for wasm32-emscripten and wasi
type: behavior
versions: Python 3.11

___
Python tracker 

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



Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott


> On 5 Mar 2022, at 19:56, Hartmut Goebel  wrote:
> 
> Am 05.03.22 um 17:34 schrieb Barry Scott:
>> Have the RPM install all the pythone code and dependencies and also install 
>> a short script that
>> sets up PYTHONPATH, LD_LIBRARY_PATH, etc and execs the python3 .py.
> The scripts are already created by entry-points. So basically this means to 
> reinvent the wheel. Or did I miss something?
> 

 For example I assume you need something like this:

#!/bin/bash
export PYTHONPATH=/opt//lib
exec /usr/bin/python3 /opt//lib/main.py "$@"

I'm assuming you put all the python code into /opt//lib
and any runnable command into /opt//bin

Barry

> -- 
> Schönen Gruß 
> Hartmut Goebel 
> Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
> Information Security Management, Security Governance, Secure Software 
> Development
> Goebel Consult, Landshut 
> http://www.goebel-consult.de 
> Blog: 
> https://www.goe-con.de/blog/eilt-petition-auf-weact-gegen-vds-jetzt-unterschreiben
>  
> 
>  
> Kolumne: 
> https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-11-in-troja-nichts-neues
>  
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45582] Rewrite getpath.c in Python

2022-03-05 Thread Christian Heimes


Change by Christian Heimes :


--
pull_requests: +29819
pull_request: https://github.com/python/cpython/pull/31699

___
Python tracker 

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



Re: Behavior of the for-else construct

2022-03-05 Thread Michael F. Stemper

On 04/03/2022 18.11, Peter J. Holzer wrote:

On 2022-03-04 23:47:09 +, Avi Gross via Python-list wrote:

I am not sure a reply is needed, Peter, and what you say is true. But
as you point out, when using a German keyboard, I would  already have
a way to enter symbols like ä, ö, ü and ß and no reason not to include
them in variable names and so on if UNICODE is being used properly. I
can use my last name in German notation as a variable in Python now:

Groß = 144
Groß / 12
12.0


Yes, I'm using umlauts occasionally in variable names in Python, and
I've also used Greek characters and others.

But in Python I CAN use them. I DON'T HAVE to.

That's a big difference.

Characters like [] or {} are a part of Python's syntax. You can't avoid
using them. If you can't type them, you can't write Python. If it is
awkward to enter them (like having to type Alt-91 or pasting them from a
character table) it is painful to write programs.

German keyboards aquired an AltGr key and the ability to type these
characters in the mid to late 1980's. Presumably because those
characters were common in C and other programming languages


... especially Pascal, which was probably bigger in Germany and Austria
in the 1980s than was C.

--
Michael F. Stemper
Psalm 94:3-6
--
https://mail.python.org/mailman/listinfo/python-list


Re: Behavior of the for-else construct

2022-03-05 Thread Dennis Lee Bieber
On Sat, 5 Mar 2022 12:39:36 -0600, "Michael F. Stemper"
 declaimed the following:

>... especially Pascal, which was probably bigger in Germany and Austria
>in the 1980s than was C.

Pascal also defined alternate representations (per Jensen) for
some of those (and I don't recall ever seeing a system that actually had an
up-arrow character -- and selecting one in character map doesn't help, my
client doesn't render it).

direct  alternate
?   ^ or @  
[   (.
]   .)
{   (*
}   *)

I'll admit... (. is a clumsy sequence to type in place of [ (RH ring
finger to top-row  on modern keyboards followed by RH ring finger
to bottom-row .), but it is a sequence any terminal mapping to a common
/typewriter/ keyboard should have available. (* isn't quite as clumsy (RH
ring finger to top-row  followed by RH middle finger to top-row
).

More fun is had when doing APL without a dedicated APL keyboard 
(Though Xerox Sigma APL also had plain text alternatives: $RHO for example)


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott


> On 5 Mar 2022, at 19:56, Hartmut Goebel  wrote:
> 
> Am 05.03.22 um 17:34 schrieb Barry Scott:
>> Have the RPM install all the pythone code and dependencies and also install 
>> a short script that
>> sets up PYTHONPATH, LD_LIBRARY_PATH, etc and execs the python3 .py.
> The scripts are already created by entry-points. So basically this means to 
> reinvent the wheel. Or did I miss something?
> 
Are you saying that the only thing you want from the venv is a script that sets 
up PYTHONPATH?

That a trivia thing to write and far easier then battling with packaging a venv 
I'd expect.

Did I miss something?

Barry

> -- 
> Schönen Gruß 
> Hartmut Goebel 
> Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
> Information Security Management, Security Governance, Secure Software 
> Development
> Goebel Consult, Landshut 
> http://www.goebel-consult.de 
> Blog: 
> https://www.goe-con.de/blog/eilt-petition-auf-weact-gegen-vds-jetzt-unterschreiben
>  
> 
>  
> Kolumne: 
> https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-11-in-troja-nichts-neues
>  
> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-05 Thread Hartmut Goebel

Am 05.03.22 um 17:34 schrieb Barry Scott:

Have the RPM install all the pythone code and dependencies and also install a 
short script that
sets up PYTHONPATH, LD_LIBRARY_PATH, etc and execs the python3 .py.


The scripts are already created by entry-points. So basically this means 
to reinvent the wheel. Or did I miss something?


--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software 
Development


Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: 
https://www.goe-con.de/blog/eilt-petition-auf-weact-gegen-vds-jetzt-unterschreiben 

Kolumne: 
https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-11-in-troja-nichts-neues 


--
https://mail.python.org/mailman/listinfo/python-list


[issue46928] type.__qualname__ ignores module name in tp_name for static types

2022-03-05 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

You're right. I was sure that __qualname__ included the module name, but PEP 
3155 is clear about actual semantics.

Sorry about the noise.

--
resolution:  -> not a bug
stage: test needed -> 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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-05 Thread Thomas Grainger

Thomas Grainger  added the comment:

The main advantage for my usecase is support for heterogeneous unpacking

On Sat, Mar 5, 2022, 6:04 PM Alex Waygood  wrote:

>
> Alex Waygood  added the comment:
>
> I sense we'll have to agree to disagree on the usefulness of NamedTuples
> in the age of dataclasses :)
>
> For me, I find the simplicity of the underlying idea behind namedtuples —
> "tuples with some properties bolted on" — very attractive. Yes, standard
> tuples are more performant, but it's great to have a tool in the arsenal
> that's essentially the same as a tuple (and is backwards-compatible with a
> tuple, for APIs that require a tuple), but can also, like dataclasses, be
> self-documenting. (You're right that DoneAndNotDoneFutures isn't a great
> example of this.)
>
> But I agree that this shouldn't be a priority if it's hard to accomplish;
> and there'll certainly be no complaints from me if energy is invested into
> making dataclasses faster.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue45847] Port module setup to PY_STDLIB_MOD() macro and addext()

2022-03-05 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
pull_requests: +29818
pull_request: https://github.com/python/cpython/pull/31698

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-05 Thread Alex Waygood

Alex Waygood  added the comment:

I sense we'll have to agree to disagree on the usefulness of NamedTuples in the 
age of dataclasses :)

For me, I find the simplicity of the underlying idea behind namedtuples — 
"tuples with some properties bolted on" — very attractive. Yes, standard tuples 
are more performant, but it's great to have a tool in the arsenal that's 
essentially the same as a tuple (and is backwards-compatible with a tuple, for 
APIs that require a tuple), but can also, like dataclasses, be 
self-documenting. (You're right that DoneAndNotDoneFutures isn't a great 
example of this.)

But I agree that this shouldn't be a priority if it's hard to accomplish; and 
there'll certainly be no complaints from me if energy is invested into making 
dataclasses faster.

--

___
Python tracker 

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



[issue46932] Please update bundled libexpat to 2.4.7 with an important fix

2022-03-05 Thread sping


New submission from sping :

Hi!

I believe the fix documented at 
https://github.com/libexpat/libexpat/blob/27d5b8ba1771f916d9cfea2aac6bdac72071dc66/expat/Changes#L7-L11
 is important to users of CPython.  Please update bundled libexpat to 2.4.7.  
Thank you!

Best, Sebastian

--
components: XML
messages: 414591
nosy: sping
priority: normal
severity: normal
status: open
title: Please update bundled libexpat to 2.4.7 with an important fix
type: behavior
versions: Python 3.10, Python 3.11, 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



[issue46414] Add typing.reveal_type

2022-03-05 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


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



Re: Behavior of the for-else construct

2022-03-05 Thread Avi Gross via Python-list
Since we still seem to be dreaming, I wonder when someone will suggest using 
some variation of the new match statement. All you need is for the for loop 
(and possibly other such constructs) to return some kind of status that can be 
matched

match (for var in something:
... ) :
  case break():
  case skipped():
  case did(1):
  case didall():

  case crash():
  case _ :

As always, the above is not even pseudocode. But my point is there are 
languages I have seen that are built on such pattern matching and provide 
abilities to do a multi-way branching as long as you are very careful about the 
order you place the things to match.

If not understood, the above function calls are meant to suggest something. For 
argument's sake, the for loop could return a non-negative number that shows the 
number of iterations done completely or even partially. It could also return 
various out-of-band (perhaps negative) values. So if it is skipped you get a 
zero or a value matching what my make-believe function skipped() returns. If 
the loop just ran once, it matched did(1).  If it completed without breaks, it 
didall() and if it broke out, or crashed it matches something. I hope the idea 
comes across, even if you disagree with my indenting or exact method.

Constructs like the above do in theory allow some really complex matching and 
often in a way easier to understand than having endless clauses added below the 
for group. 

But as repeatedly stated, Python currently has no concept of returning a value 
directly from a for loop or lots of other things. A brand new language that 
superficially resembled python could be designed but that is a rather 
formidable task.

And where does it end? I mean you could set it up so the language allows you to 
return an invisible (meaning it does not print unless you ask for it) object 
among many possible objects. 

The simplest object may be an integer or perhaps an object of a class with a 
name like counter so you matched against counter(1) or against counter(n) if 
you want to capture the exact number for further processing. Various other 
object types might be returned including one that tells you about a break and 
also on which iteration it broke out of or even the value of the  item it was 
looping on at the moment. If this starts looking a bit like how errors can be 
created and propagated, that is no coincidence.

But the above also might come with serious overhead. And for many, it would not 
be seen as necessary. I will say that by allowing the match statement in the 
current form, the door has been opened wide for all kinds of potential 
enhancements. Older code and features may be left alone, but newer code is now 
free to do esoteric things. If I rewrote my call to the loop into a function 
that takes arguments including the data I want to have used and internally does 
the for loop while setting various variables that capture all kinds of info 
needed, then it potentially could return one of a series of objects you could 
pattern match against to your heart's content. A call to the function could be 
used in a match statement vaguely as in my hand-waving above. And of course you 
can use unpacking to make all kinds of compound patterns if done carefully.

I think my part of this endless conversation may have gone a bit beyond far 
enough and I await some new topics.


-Original Message-
From: Rob Cliffe via Python-list 
To: python-list@python.org
Sent: Sat, Mar 5, 2022 7:15 am
Subject: Re: Behavior of the for-else construct




On 05/03/2022 01:15, Cameron Simpson wrote:
>
> I sort of wish it had both "used break" and "did not use break"
> branches, a bit like try/except/else.
And "zero iterations".
Rob Cliffe

-- 
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46931] zipfile library will raise uncaught oserror when reading length incorrect zip file

2022-03-05 Thread Vertu Joe


New submission from Vertu Joe :

I intentionally made some corrupted zip archive files for testing.
If some contents were removed from the archive instead of changing the bits. 
when trying to read such files, the zipfile will raise an uncaught  OSError, 
instead of a badzipfile error as expected.

os is windows 10 x64 not sure if this also happens on the UNIX system or it's 
intended to be happen.

code:

import zipfile
with zipfile.ZipFile(r'damaged.zip') as dmg:
dmg.testzip()

result:
OSError
[Errno 22] Invalid argument
  File "test.py", line 20, in 
file = dmg.testzip()

--
components: Library (Lib)
files: damaged.zip
messages: 414590
nosy: ultimalium
priority: normal
severity: normal
status: open
title: zipfile library will raise uncaught oserror when reading length 
incorrect zip file
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50658/damaged.zip

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-05 Thread Guido van Rossum

Guido van Rossum  added the comment:

Okay, that's a sensible use case.

I do doubt your intuition of preferring named tuples over dataclasses a bit. 
This seems to encourage premature optimization. I'd say for simple cases use 
plain tuples (most performant), for complex cases use dataclasses (named fields 
and many other features that you may eventually want).

Compare concurent.futures.wait()'s return type (a named tuple) to 
asyncio.tasks.wait()'s return type (a plain tuple). I don't think that naming 
the fields of the return tuple (awkwardly :-) makes the c.f.wait() API easier 
to understand than the asyncio.wait() API.

Maybe named tuples, like typed dicts, are "in-between" solutions on the 
spectrum of data types (tuple - named tuple - dataclass; dict - typed dict - 
dataclass), and we should encourage people to use the neighboring solutions 
instead.

I'd rather spend efforts making dataclasses faster than adding features to 
named tuples.

--

___
Python tracker 

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



Re: virtualenv and make DESTDIR=

2022-03-05 Thread Kirill Ratkin

Hi,

As far I know there is tool rpmvenv 
(https://github.com/kevinconway/rpmvenv).


Try it, maybe ot helps.

04.03.2022 16:03, Hartmut Goebel wrote:

Hi,

How can I make installing a virtual environment honor DESTDIR? How can 
I install a virtual environment in $(DESTDIR)$(PREFIX), which behaves 
as being set-up in $(PREFIX)? (Of course, this virtual environment can 
not be used. My aim is to ship it as part of a rpm package)


In Makefiles is good practice to honor DESTDIR in the "install" 
target, like this


install:
    install -t $(DESTDIR)$(PREFIX)/bin build/bin/my-tool

Now when running

    python3 -m venv $(DESTDIR)$(PREFIX)

all paths in this virtual environment refer to $(DESTDIR)$(PREFIX) 
instead of just $$(PREFIX)


Any ideas?


Background:

More about DESTDIR: 
https://www.gnu.org/prep/standards/html_node/DESTDIR.html


Following Redhat's commendations, I want to install my (somewhat 
complex) software into /opt/my-software. To make it easier for users 
to use the software, my idea was to setup a virtual environment in 
/opt/my-software. Thus users can easily use 
/opt/my-software/bin/python and have the library provided by 
my-software available. My Software also includes some scripts, which 
will also reside in /opt/my-software/bin and refer to 
/opt/my-software/bin/python. This will avoid to require users to set 
up PYTHONPATH when thy want to use MY Software.




--
https://mail.python.org/mailman/listinfo/python-list


looking for a freelancer to update a python NNTP script

2022-03-05 Thread RS Wood


I'm looking for a mid-level python programmer to help me with a python
script that accesses Usenet. I've got a non-working 2.7 script that
needs a little more attention than just running 2to3 on it.  Estimated
level of effort: about 2 hours or less.

If interested please send me an email at moc.liamg@71orifaz (spell that
backwards - rudimentary anti-spam measure). Tell me your hourly rate or
fixed price for the work and explain your qualifications.  (Use email,
don't post here).

Payment would be through Paypal - half up front, half on
completion. Selection will be made on the basis of both qualifications
and cost - I'm not just looking for the lowest bidder.

I'm posting the offer here because to test the script you need to have
some understanding of Usenet and working Usenet access, obviously.

I'll respond to this post when the job is filled.

Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott



> On 5 Mar 2022, at 16:59, Marco Sulla  wrote:
> 
> On Sat, 5 Mar 2022 at 17:36, Barry Scott  wrote:
>> Note: you usually cannot use pip when building an RPM with mock as the 
>> network is disabled inside the build for
>> security reasons.
> 
> Can't he previously download the packages and run pip on the local packages?
> 

I guess that can work. In this case I would install with pip install --user and 
move the
files out of .local into an appropriate place in /opt/.

At work I package a lot of packages for python and what we do is get the 
sources, 
review them then turn them into an RPM using the setup.py to do the file 
placement.

We do not use the wheels from PyPI ever. They may not match the claimed sources.
Which I have seen a few times; the version on PyPI can contain helpful patches 
that
are not in the sources.

Barry


-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46928] type.__qualname__ ignores module name in tp_name for static types

2022-03-05 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

What do you expect?

The full qualified name of the object is __module__ + '.' + __qualname__.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



Re: virtualenv and make DESTDIR=

2022-03-05 Thread Marco Sulla
On Sat, 5 Mar 2022 at 17:36, Barry Scott  wrote:
> Note: you usually cannot use pip when building an RPM with mock as the 
> network is disabled inside the build for
> security reasons.

Can't he previously download the packages and run pip on the local packages?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46794] Please update bundled libexpat to 2.4.6 with security fixes (5 CVEs)

2022-03-05 Thread mattip


mattip  added the comment:

> [T]he test has been removed in CPython pull request 
> https://github.com/python/cpython/pull/31453/files

Thanks, I missed that. Makes sense.

--

___
Python tracker 

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



[issue9305] Don't use east/west of UTC in date/time documentation

2022-03-05 Thread Stanley


Change by Stanley :


--
nosy: +slateny
nosy_count: 14.0 -> 15.0
pull_requests: +29817
pull_request: https://github.com/python/cpython/pull/31697

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-05 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +graingert

___
Python tracker 

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



[issue46925] Document dict behavior when setting equal but not identical key

2022-03-05 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The weakref docs in particular should point out the OP's example and highlight 
the workaround.

--

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-05 Thread Alex Waygood


Alex Waygood  added the comment:

Consider the typeshed stub for `concurrent.futures.DoneAndNotDoneFutures`. At 
runtime this is a `collections.namedtuple`, but in the stub, we need it to be 
generic to allow precise type inference. But we can't have a generic 
NamedTuple, so the stub is currently this:

```
class DoneAndNotDoneFutures(Sequence[set[Future[_T]]]):
@property
def done(self) -> set[Future[_T]]: ...
@property
def not_done(self) -> set[Future[_T]]: ...
def __new__(_cls, done: set[Future[_T]], not_done: set[Future[_T]]) -> 
DoneAndNotDoneFutures[_T]: ...
def __len__(self) -> int: ...
@overload
def __getitem__(self, __i: SupportsIndex) -> set[Future[_T]]: ...
@overload
def __getitem__(self, __s: slice) -> DoneAndNotDoneFutures[_T]: ...
```

Until two days ago, this stub actually had a bug: `done` and `not_done` were 
both given as writeable attributes, whereas they are read-only properties at 
runtime.

With generic NamedTuples, we could write the stub for the class far more simply 
(and more accurately) like this:

```
class DoneAndNotDoneFutures(NamedTuple, Generic[_T]):
done: set[Future[_T]]
not_done: set[Future[_T]]
```

And in code that actually needs to run at runtime, I frequently find it 
frustrating that I have to use dataclasses instead of NamedTuples if I want a 
simple class that just happens to be generic. dataclasses are great, but for 
small, lightweight classes, I prefer to use NamedTuples where possible. I often 
find that I don't need to use the full range of features dataclasses provide; 
and NamedTuples are often more performant than dataclasses, especially in cases 
where there's a lot of tuple unpacking.

--

___
Python tracker 

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



Re: virtualenv and make DESTDIR=

2022-03-05 Thread Barry Scott


> On 4 Mar 2022, at 13:03, Hartmut Goebel  wrote:
> 
> Hi,
> 
> How can I make installing a virtual environment honor DESTDIR? How can I 
> install a virtual environment in $(DESTDIR)$(PREFIX), which behaves as being 
> set-up in $(PREFIX)? (Of course, this virtual environment can not be used. My 
> aim is to ship it as part of a rpm package)
> 
> In Makefiles is good practice to honor DESTDIR in the "install" target, like 
> this
> 
> install:
> install -t $(DESTDIR)$(PREFIX)/bin build/bin/my-tool
> 
> Now when running
> 
> python3 -m venv $(DESTDIR)$(PREFIX)
> 
> all paths in this virtual environment refer to $(DESTDIR)$(PREFIX) instead of 
> just $$(PREFIX)
> 
> Any ideas?
> 
> 
> Background:
> 
> More about DESTDIR: https://www.gnu.org/prep/standards/html_node/DESTDIR.html
> 
> Following Redhat's commendations, I want to install my (somewhat complex) 
> software into /opt/my-software. To make it easier for users to use the 
> software, my idea was to setup a virtual environment in /opt/my-software. 
> Thus users can easily use /opt/my-software/bin/python and have the library 
> provided by my-software available. My Software also includes some scripts, 
> which will also reside in /opt/my-software/bin and refer to 
> /opt/my-software/bin/python. This will avoid to require users to set up 
> PYTHONPATH when thy want to use MY Software.

If you are packaging the code then I do not see the need to use a venv at all.

Have the RPM install all the pythone code and dependencies and also install a 
short script that
sets up PYTHONPATH, LD_LIBRARY_PATH, etc and execs the python3 .py.

Note: you usually cannot use pip when building an RPM with mock as the network 
is disabled inside the build for
security reasons.

I package two of my projects this was for Fedora as RPMs.

Barry


> 
> 
> -- 
> Schönen Gruß
> Hartmut Goebel
> Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
> Information Security Management, Security Governance, Secure Software 
> Development
> 
> Goebel Consult, Landshut
> http://www.goebel-consult.de
> 
> Blog: https://www.goe-con.de/blog/why-a-pki-is-barely-trustworthy
> Kolumne: 
> https://www.goe-con.de/hartmut-goebel/cissp-gefluester/2011-11-in-troja-nichts-neues
>  
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting Syslog working on OSX Monterey

2022-03-05 Thread Barry Scott



> On 4 Mar 2022, at 21:23, Peter J. Holzer  wrote:
> 
> On 2022-02-28 22:05:05 +, Barry Scott wrote:
>> On 28 Feb 2022, at 21:41, Peter J. Holzer  wrote:
>>> On 2022-02-27 22:16:54 +, Barry wrote:
 I have always assumed that if I want a logger syslog handler that I would 
 have
 to implement it myself. So far I have code that uses syslog directly and 
 have
 not written that code yet.
>>> 
>>> What do you mean by using syslog directly? The syslog(3) library
>>> function also just sends messages to a "syslog listener" (more commonly
>>> called a syslog daemon) - at least on any unix-like system I'm familiar
>>> with (which doesn't include MacOS). It will, however, always use the
>>> *local* syslog daemon - AFAIK there is no standard way to open a remote
>>> connection (many syslog daemons can be configured to forward messages to
>>> a remote server, however).
>> 
>> I'm re-reading the code to check on what I'm seeing. (Its been a long
>> time since I last look deeply at this code).
>> 
>> You can write to /dev/log if you pass that to
>> SysLogHandler(address='/dev/log'), but the default is to use a socket
>> to talk to a network listener on localhost:514. There are no deamons
>> listening on port 514 on my Fedora systems or mac OS.
> 
> If you are saying that SysLogHandler should use a system specific
> default (e.g. "/dev/log" on Linux) instead of UDP port 514 everywhere, I
> agree 99 % (the remaining 1 % is my contrarian alter ego arguing that
> that's really the distribution maintainer's job since a Linux
> distribution might use some other socket).
> 
> If you are saying it should use the libc syslog routines, I disagree for
> at least two reasons: a) they are OS specific, b) you can't configure the
> destination. So that would remove useful functionality.
> 
> In any case it seems strange to me that you want to rewrite it just to
> avoid passing a single parameter to the constructor (or - more likely -
> adding a single line to a config file).

What I am used to is a setup where programs use syslog() to log and
a dameon like rsyslog is responsible for routing the logs to local files
and/or remote systems. On a modern linux I think the route is
syslog() -> journald. And you can have syslog() -> journald -> rsyslogd.

Using the syslog() function means that any platform/distro details are
hidden from the user of syslog() and as is the case of macOS it
"just works". (I assume, not checked, that the write to the socket does not work
because Apple is not implementing the syslog protocol from the RFC).

> 
>> What you do not see used in the SyslogHandler() is the import syslog
>> and hence its nor using openlog() etc from syslog API.
> 
> For good reasons. The C syslog API is missing important functionality.

What are you think about being missing? Just curious.

As an aside if I had the need to log into a system log mechanism I'd be
looking to use the jounald API so that I can use structured logging on linux
systems.

Barry


> 
>hp
> 
> -- 
>   _  | Peter J. Holzer| Story must make more sense than reality.
> |_|_) ||
> | |   | h...@hjp.at |-- Charles Stross, "Creative writing
> __/   | http://www.hjp.at/ |   challenge!"
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46920] Remove code made dead long ago with #if 0

2022-03-05 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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-05 Thread Guido van Rossum


Guido van Rossum  added the comment:

Can you be more specific about your use cases?

--

___
Python tracker 

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



[issue46930] Iterating over cls.__dict__ in classmethod causes RuntimeError when printing __annotations__

2022-03-05 Thread Alex Waygood


Change by Alex Waygood :


--
type: crash -> behavior
versions: +Python 3.11

___
Python tracker 

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



[issue46930] Iterating over cls.__dict__ in classmethod causes RuntimeError when printing __annotations__

2022-03-05 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

Can reproduce this:

>>> ExampleCls.__dict__
mappingproxy({'__module__': '__main__', 'iter_cls': )>, '__dict__': , '__weakref__': , '__doc__': None})
>>> ExampleCls.iter_cls()
{}
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 4, in iter_cls
RuntimeError: dictionary changed size during iteration
>>> ExampleCls.__dict__
mappingproxy({'__module__': '__main__', 'iter_cls': )>, '__dict__': , '__weakref__': , '__doc__': None, '__annotations__': {}})

The descriptor for type.__annotations__ writes a new attribute into the class's 
dict if it doesn't exist yet. This was done in bpo-43901 / GH-25263.

I don't see a way to fix this bug while preserving the behavior bpo-43901 was 
aiming for.

--
nosy: +Jelle Zijlstra, larry

___
Python tracker 

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



[issue46930] Iterating over cls.__dict__ in classmethod causes RuntimeError when printing __annotations__

2022-03-05 Thread Fabian Zills


New submission from Fabian Zills :

When iterating over __dict__ inside a classmethod, accessing __annotations 
causses RuntimeError: dictionary changed size during iteration.
This only seems to affect Python 3.10.x on a Ubuntu system.

The following can be used to reproduce this issue:

class ExampleCls:
@classmethod
def iter_cls(cls):
for name, val in cls.__dict__.items():
print(cls.__annotations__)


This can be fixed for this Example by calling  _ = cls.__annotations__ before 
iterating over the __dict__

--
messages: 414582
nosy: PythonF
priority: normal
severity: normal
status: open
title: Iterating over cls.__dict__ in classmethod causes RuntimeError when 
printing __annotations__
type: crash
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



[issue43292] xml.ElementTree iterparse filehandle left open

2022-03-05 Thread Jacob Walls


Change by Jacob Walls :


--
keywords: +patch
nosy: +jacobtylerwalls
nosy_count: 4.0 -> 5.0
pull_requests: +29815
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31696

___
Python tracker 

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



[issue25707] Add the close method for ElementTree.iterparse() object

2022-03-05 Thread Jacob Walls


Change by Jacob Walls :


--
keywords: +patch
nosy: +jacobtylerwalls
nosy_count: 4.0 -> 5.0
pull_requests: +29816
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/31696

___
Python tracker 

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



[issue46925] Document dict behavior when setting equal but not identical key

2022-03-05 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

Agree, I couldn't find a place where this behavior is documented. The second 
paragraph in 
https://docs.python.org/3.10/library/stdtypes.html#mapping-types-dict comes 
close. Reopening as a documentation issue.

--
assignee:  -> docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python
resolution: rejected -> 
stage: resolved -> needs patch
status: closed -> open
title: Replace key if not identical to old key in dict -> Document dict 
behavior when setting equal but not identical key
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



[issue46929] __rrshift__ for same class obj will raise TypeError

2022-03-05 Thread Mark Dickinson

Mark Dickinson  added the comment:

This is the intended behaviour. See the docs here: 
https://docs.python.org/3/reference/datamodel.html#object.__ror__

> These functions are only called if the left operand does not support the 
> corresponding operation and the operands are of different types.

There's a further explanation in a footnote:

> For operands of the same type, it is assumed that if the non-reflected method 
> – such as __add__() – fails then the overall operation is not supported, 
> which is why the reflected method is not called.

--
nosy: +mark.dickinson
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



[issue46929] __rrshift__ for same class obj will raise TypeError

2022-03-05 Thread ZhengYu, Xu


ZhengYu, Xu  added the comment:

But with different classed will be right

```
class C:
def __rrshift__(self, v):
return 1

class D:
def __rrshift__(self, v):
return 2

C() >> D() # 2
```

--

___
Python tracker 

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



[issue46929] __rrshift__ for same class obj will raise TypeError

2022-03-05 Thread ZhengYu, Xu


New submission from ZhengYu, Xu :

```
class C:
def __rrshift__(self, v):
return 1

C() >> C()   # raise TypeError: unsupported operand types(s) for >>: 'C' and 'C'
```

--
messages: 414578
nosy: zen-xu
priority: normal
severity: normal
status: open
title: __rrshift__ for same class obj will  raise TypeError
type: behavior
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue46921] Vectorcall support for super()

2022-03-05 Thread Dong-hee Na


Dong-hee Na  added the comment:

Mean +- std dev: [base] 254 ns +- 6 ns -> [vectorcall] 225 ns +- 1 ns: 1.13x 
faster

--
Added file: https://bugs.python.org/file50657/bench_super.py

___
Python tracker 

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



Cpython: when to incref before insertdict

2022-03-05 Thread Marco Sulla
I noticed that some functions inside dictobject.c that call insertdict
or PyDict_SetItem do an incref of key and value before the call, and a
decref after it. An example is dict_merge. Other functions, such as
_PyDict_FromKeys, don't do an incref before.

When an incref of key and value is needed before insertdict and when
is not? And why is an incref needed?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46927] Improve error message for subscripting non-generic types

2022-03-05 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue46927] Improve error message for subscripting non-generic types

2022-03-05 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset ab9301a28fa431d7a32163126fc96de3b2ce6107 by Serhiy Storchaka in 
branch 'main':
bpo-46927: Include the type's name in the error message for subscripting 
non-generic types (GH-31694)
https://github.com/python/cpython/commit/ab9301a28fa431d7a32163126fc96de3b2ce6107


--

___
Python tracker 

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



[issue46798] xml.etree.ElementTree: get() doesn't return default value, always ATTLIST value

2022-03-05 Thread Stefan Behnel


Change by Stefan Behnel :


--
status: open -> closed

___
Python tracker 

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



Re: Behavior of the for-else construct

2022-03-05 Thread Rob Cliffe via Python-list




On 05/03/2022 01:15, Cameron Simpson wrote:


I sort of wish it had both "used break" and "did not use break"
branches, a bit like try/except/else.

And "zero iterations".
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list


[issue46917] Require IEEE 754 floating point to build Python 3.11

2022-03-05 Thread Mark Dickinson


Mark Dickinson  added the comment:

> * Mention the new build requirement in What's New in Python 3.11.
> * Modify configure script to make it fail if the IEEE 754 support is missing.
> * Remove code handling missing NAN and infinity: float("nan"), float("inf"), 
> math.nan and math.inf are always available.

That sounds fine.

> * Remove @requires_IEEE_754 decorator of test.support and tests.

I'd suggest leaving those decorators. Some of the tests are used by Python 
implementations other than CPython, and we're not requiring IEEE 754 on all 
Python implementations.

> * Remove "unknown_format" code path of pack/unpack functions like 
> _PyFloat_Pack8() (see bpo-46906 which proposes to make these functions 
> public).

Sounds fine.

> platforms with float larger than 64-bit

I'm assuming you mean Python "float" / C "double" here. There seems to be a 
persistent misunderstanding here, and I'd really like to be sure that everyone 
understands what the current code is doing before changing anything. There are 
*no* platforms that Python cares about where the C double is larger than 
64-bits, and as far as I'm aware there never have been.

What there *is* is a set of platforms where the C double is IEEE 754 binary64 
format, but where arithmetic operations between doubles may be performed in 
extended precision (usually 64-bit precision), so those arithmetic operations 
don't conform strictly to IEEE 754 semantics. Most flavours of Linux on x86 
match that description.

Then there's a (possibly empty, but we don't know that for sure) subset of 
*that* set of platforms where we don't know how to temporarily enforce 53-bit 
precision during numeric parsing / formatting operations.

It's that second subset where dtoa.c can't be used, and where we need the 
fallback of the "legacy" float repr.

I'd be more than happy to deprecate and eventually remove support for the 
legacy float repr, but I think it's too big a change to make for 3.11: we'd 
need to deprecate the support for 3.11 and eventually remove it in 3.13.

--

___
Python tracker 

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



Re: Behavior of the for-else construct

2022-03-05 Thread Peter J. Holzer
On 2022-03-05 00:25:44 +0100, Peter J. Holzer wrote:
> On 2022-03-04 11:34:07 +1100, Chris Angelico wrote:
> > What I'm hearing is that there are, broadly speaking, two types of
> > programmers [1]:
> > 
> > 1) Those who think about "for-else" as a search tool and perfectly
> > understand how it behaves
> > 2) Those who have an incorrect idea about what for-else is supposed to
> > do, don't understand it, and don't like it.
> 
> 3) Those who understand what it does und don't even find it*s syntax
> very confusing, yet only very rarely find it useful.
> 
> I have probably used it a handful of times in 8 years of Python
> programming. Coincidentally, I think I used it just this week - but I
> can't find it any more which probably means that it was either in a
> throwaway script or I have since rewritten the code.

Just found it again. Not yet committed, and I may still end up rewriting
it again before turning in the pull request, but for now it's the
simplest solution for the problem.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46928] type.__qualname__ ignores module name in tp_name for static types

2022-03-05 Thread Ronald Oussoren


New submission from Ronald Oussoren :

In a static type when the "tp_name" is set to a fully qualified name (such as 
"my.package.TypeName") the "__qualname__" returns the unqualified name 
("TypeName") instead of the fully qualified name.

The type's ``__name__`` and ``__module__`` have the expected value.

This is IMHO a bug in the implementation of type_qualname in 
Objects/typeobject.c.

Note that setting ``__qualname__`` in the types's ``__dict__`` doesn't work, 
that value is ignored.

--
components: Interpreter Core
messages: 414574
nosy: ronaldoussoren
priority: normal
severity: normal
stage: test needed
status: open
title: type.__qualname__ ignores module name in tp_name for static types
type: behavior
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



[issue46927] Improve error message for subscripting non-generic types

2022-03-05 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue46927] Improve error message for subscripting non-generic types

2022-03-05 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue46927] Improve error message for subscripting non-generic types

2022-03-05 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +gvanrossum, kj

___
Python tracker 

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



[issue46927] Improve error message for subscripting non-generic types

2022-03-05 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

Currently, if you try to subscript a non-generic type you will get an error:

>>> int[str]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'type' object is not subscriptable

Yes, 'type' objects are usually not subscriptable, but list[str] works, and it 
is not clear from the error message for what type it is failed.

The following PR changes an error message:

>>> int[str]
Traceback (most recent call last):
  File "", line 1, in 
TypeError: type 'int' is not subscriptable

--
components: Interpreter Core
messages: 414573
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Improve error message for subscripting non-generic types
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



[issue44863] Allow TypedDict to inherit from Generics

2022-03-05 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +Jelle Zijlstra, sobolevn

___
Python tracker 

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



[issue44863] Allow TypedDict to inherit from Generics

2022-03-05 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +AlexWaygood

___
Python tracker 

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



[issue46925] Replace key if not identical to old key in dict

2022-03-05 Thread Jarek Potiuk


Jarek Potiuk  added the comment:

How about if we make PR instead to the documentation about this behaviour? 

I think this behaviour is a little surprising (you need to know the internals 
of how WeakKeyDict keys are constructed and checked) and while I understand you 
do not want breaking change, maybe this should be explained to the users and 
example given how to apply the workaround?

Just following the "least surprise" principle.

--
nosy: +potiuk

___
Python tracker 

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



[issue39298] add BLAKE3 to hashlib

2022-03-05 Thread Larry Hastings


Larry Hastings  added the comment:

Right, and I did say "(or BDFL)".  Apparently you didn't bother to consult with 
the BDFL in advance, or at least not in the usual public venues--I haven't 
found a record of such a conversation on the bpo issue, nor in python-dev.

BTW you simultaneously proposed adding SHA3/SHAKE.  The total kloc for all this 
work was over 26k; you didn't mention any discomfort with the size of these 
patches at the time in public correspondance.

In fact, quite the opposite.  On 2016/05/28 you said:

> I also don't get your obsession with lines of code. The gzip and expat
> are far bigger than the KeccakCodePackage.

https://mail.python.org/archives/list/python-...@python.org/message/3YHVN2I74UQC36AVY5BGRJJUE4PMU6GX/

--

___
Python tracker 

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



[issue46921] Vectorcall support for super()

2022-03-05 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue44863] Allow TypedDict to inherit from Generics

2022-03-05 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-05 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Please don't revert all changes. It will not make it working right in any case. 
See issue44863 for more correct approach.

--

___
Python tracker 

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



[issue11352] Update cgi module doc

2022-03-05 Thread Irit Katriel


Change by Irit Katriel :


--
priority: high -> normal

___
Python tracker 

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



[issue39298] add BLAKE3 to hashlib

2022-03-05 Thread Christian Heimes


Christian Heimes  added the comment:

I didn't consult the steering council in 2016, because I lost the keys to the 
time machine. The very first SC election was in 2019. :)

--

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-05 Thread Alex Waygood


Alex Waygood  added the comment:

> Is there an actual use case that broke?

No, because this was never usable in the first place. But there are those who 
wish it were usable :)

--

___
Python tracker 

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



[issue43923] Can't create generic NamedTuple as of py3.9

2022-03-05 Thread Alex Waygood


Alex Waygood  added the comment:

I actually have quite a few use cases for this feature. It's true that type 
checkers don't (yet) support it, but that doesn't mean that it should be 
disallowed at runtime. In fact, allowing it at runtime will surely give type  
checkers room to experiment with implementing this feature if it is requested 
by enough users. As it is, they are blocked from doing so.

--

___
Python tracker 

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



[issue45100] Improve help() by making typing.overload() information accessible at runtime

2022-03-05 Thread Alex Waygood


Alex Waygood  added the comment:

The latest plan sounds good to me. I have some Thoughts on the proposed API, 
but it will be easier to express those as part of a PR review. Looking forward 
to seeing the PR!

--

___
Python tracker 

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