[issue30267] Deprecate os.path.commonprefix

2022-02-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

For now, there are three uses of commonprefix() in the stdlib:

1. In urllib.request it causes a security issue (see issue46756). commonpath() 
or just str.startswith() should be used instead.

2. In lib2to3.main. The code contains a workaround around commonprefix(). It 
could be simplified by using commonpath().

3. In unittest.util. This is the only correct use of commonprefix(). It cannot 
be replaced by commonpath().

I think that we should add commonprefix() in the string module (or maybe in a 
new module for operations on sequences), deprecate os.path.commonprefix() in 
documentation only, several versions later add a deprecation warning in 
os.path.commonprefix(), and several versions later remove 
os.path.commonprefix().

--

___
Python tracker 

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



[issue46730] Please consider mentioning property without setter when an attribute can't be set

2022-02-15 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Thanks for the PR!

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



[issue46730] Please consider mentioning property without setter when an attribute can't be set

2022-02-15 Thread Dennis Sweeney


[issue46766] Add a class for file operations so a syntax such as open("file.img", File.Write | File.Binary | File.Disk) is possible.

2022-02-15 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I'm sorry, I don't see why you think this will improve code readability. I also 
expect it will be harder to teach than the current code.

open("file.img", "wb") just needs the user to learn about reading and writing 
files, and the difference between binary and text files. It works the same way 
in probably dozens of different languages.

open("file.img", File.Write | File.Binary | File.Disk) needs the beginner to 
learn the same details, *plus* they have to learn about this mystery File 
object, classes, dot notation, `|` the bitwise-or operator, and how to import 
File from the io module.

My guess is that File.Write etc are just enums equivalent to strings 'w' and 
'b', but what's File.Disk?

What else does this File object do?

--
nosy: +steven.daprano

___
Python tracker 

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



[issue46766] Add a class for file operations so a syntax such as open("file.img", File.Write | File.Binary | File.Disk) is possible.

2022-02-15 Thread Isaac Johnson


Change by Isaac Johnson :


--
type:  -> enhancement

___
Python tracker 

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



[issue46766] Add a class for file operations so a syntax such as open("file.img", File.Write | File.Binary | File.Disk) is possible.

2022-02-15 Thread Isaac Johnson


Isaac Johnson  added the comment:

I'm currently working on implementing this. It will probably be a few weeks.

--

___
Python tracker 

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



[issue46766] Add a class for file operations so a syntax such as open("file.img", File.Write | File.Binary | File.Disk) is possible.

2022-02-15 Thread Isaac Johnson


New submission from Isaac Johnson :

I think it would be great for something like this to be with the IO module. It 
will improve code readability.

--
components: Library (Lib)
messages: 413315
nosy: isaacsjohnson22
priority: normal
severity: normal
status: open
title: Add a class for file operations so a syntax such as open("file.img", 
File.Write | File.Binary | File.Disk) is possible.
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: venv and executing other python programs

2022-02-15 Thread Eryk Sun
On 2/15/22, Martin Di Paola  wrote:
>
> That's correct. I tried to be systematic in the analysis so I tested all
> the possibilities.

Your test results were unexpected for `python3 -m venv xxx`. By
default, virtual environments exclude the system and user site
packages. Including them should require the command-line argument
`--system-site-packages`. I'd check sys.path in the environment. Maybe
you have PYTHONPATH set.

> I had to test this myself because I didn't believe it but you are right.
> Without having the venv activated, if the shebang explicitly points to
> the python executable of the venv, the program will have access to the
> libs installed in the environment.

A virtual environment is configured by a "pyvenv.cfg" file that's
either beside the executable or one directory up. Activating an
environment is a convenience, not a requirement.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46337] urllib.parse: Allow more flexibility in schemes and URL resolution behavior

2022-02-15 Thread karl


karl  added the comment:

Just to note that there is a maintained list of officially accepted schemes at 
IANA.
https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml

In addition there is a list of unofficial schemes on wikipedia 
https://en.wikipedia.org/wiki/List_of_URI_schemes#Unofficial_but_common_URI_schemes

--
nosy: +karlcow

___
Python tracker 

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



[issue46764] Wrapping a bound method with a @classmethod no longer works

2022-02-15 Thread Michael J. Sullivan


Change by Michael J. Sullivan :


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

___
Python tracker 

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



[issue46765] Replace Locally Cached Strings with Statically Initialized Objects

2022-02-15 Thread Eric Snow


Change by Eric Snow :


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

___
Python tracker 

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



[issue46765] Replace Locally Cached Strings with Statically Initialized Objects

2022-02-15 Thread Eric Snow


New submission from Eric Snow :

This removes a number of static variables and is a little more efficient.

--
assignee: eric.snow
components: Interpreter Core
messages: 413313
nosy: eric.snow
priority: normal
severity: normal
stage: needs patch
status: open
title: Replace Locally Cached Strings with Statically Initialized Objects
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



[issue46764] Wrapping a bound method with a @classmethod no longer works

2022-02-15 Thread Alex Waygood


Change by Alex Waygood :


--
nosy: +rhettinger
type:  -> behavior

___
Python tracker 

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



[issue46541] Replace _Py_IDENTIFIER() with statically initialized objects.

2022-02-15 Thread Eric Snow


Eric Snow  added the comment:


New changeset 4d8a515d193a4c9f3844704f974ddb870d7ee383 by Eric Snow in branch 
'main':
bpo-46541: Scan Fewer Files in generate_global_objects.py (gh-31364)
https://github.com/python/cpython/commit/4d8a515d193a4c9f3844704f974ddb870d7ee383


--

___
Python tracker 

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



[issue46541] Replace _Py_IDENTIFIER() with statically initialized objects.

2022-02-15 Thread Eric Snow


Eric Snow  added the comment:


New changeset 6c8958948666403f2370ca7b4c0a52b2010ec16d by Eric Snow in branch 
'main':
bpo-46541: Drop the check for orphaned global strings. (gh-31363)
https://github.com/python/cpython/commit/6c8958948666403f2370ca7b4c0a52b2010ec16d


--

___
Python tracker 

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



[issue46738] Allow http.server to emit HTML 5

2022-02-15 Thread Martin Panter


Change by Martin Panter :


--
superseder:  -> Generate HTML 5 with SimpleHTTPRequestHandler.list_directory

___
Python tracker 

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



Re: venv and executing other python programs

2022-02-15 Thread Martin Di Paola
If you have activated the venv then any script that uses /usr/bin/env 
will use executables from the venv

bin folder.


That's correct. I tried to be systematic in the analysis so I tested all 
the possibilities.


I avoid all these issues by not activating the venv. Python has code to 
know

how to use the venv libraries that are installed in it when invoked. It does not
depend on the activate script being run.


I had to test this myself because I didn't believe it but you are right.  
Without having the venv activated, if the shebang explicitly points to 
the python executable of the venv, the program will have access to the 
libs installed in the environment.


The same if I do:

/home/user/venv/bin/python foo.py

Thanks for the info!


Barry




Do you have a particular context where you are having troubles? May be there is 
something else going on...

Thanks,
Martin.

On Tue, Feb 15, 2022 at 06:35:18AM +0100, Mirko via Python-list wrote:

Hi,

I have recently started using venv for my hobby-programming. There
is an annoying problem. Since venv modifies $PATH, python programs
that use the "#!/usr/bin/env python" variant of the hashbang often
fail since their additional modules aren't install inside in venv.

How to people here deal with that?

Please note: I'm not interested in discussing whether the
env-variant is good or bad. ;-) It's not that *I* use it, but
several progs in /usr/bin/.

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

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




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


[issue46764] Wrapping a bound method with a @classmethod no longer works

2022-02-15 Thread Michael J. Sullivan


New submission from Michael J. Sullivan :

class A:
def foo(self, cls): return 1

class B: pass

class B:
bar = classmethod(A().foo)

B.bar()


In Python 3.8 and prior, this worked. Since Python 3.9, it produces "TypeError: 
A.foo() missing 1 required positional argument: 'cls'"

I tracked it down, and the issue was introduced by 
https://github.com/python/cpython/pull/8405/files, which makes classmethod's 
tp_descr_get invoke its argument tp_descr_get when present instead of calling 
PyMethod_New. That this was a semantics change that could break existing code 
may have been missed (though it is a fairly obscure such change).

The reason it breaks this case in particular of bound methods, though, is that 
bound methods have a tp_descr_get that does nothing (increfs the method and 
then returns it). Dropping that tp_descr_get fixes this issue and doesn't 
introduce any test failures. Not sure if there is some potential downstream 
breakage of that?

(This issue was originally reported to me by Jared Hance)

--
components: Interpreter Core
messages: 413310
nosy: msullivan
priority: normal
severity: normal
status: open
title: Wrapping a bound method with a @classmethod no longer works
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



[issue46763] os.path.samefile incorrect results for shadow copies

2022-02-15 Thread Nick Venenga


Nick Venenga  added the comment:

This script can reproduce the issue. 

The computer must be a Windows computer with volume shadow copy service enabled
The computer must have shadow storage added to the drive being used
This script changes the host machine by creating a shadow copy (permissions to 
create shadow copies are required)

--
Added file: https://bugs.python.org/file50626/shadow-repro.py

___
Python tracker 

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



[issue46733] pathlib.Path methods can raise NotImplementedError

2022-02-15 Thread Eryk Sun


Eryk Sun  added the comment:

> I'm planning to learn more heavily on posixpath + ntpath in 
> pathlib once bpo-44136 is done. I think that would be a good 
> time to introduce is_mount() support on Windows.

In the long run, it would be better to migrate the implementations in the other 
direction. Rewrite genericpath, ntpath, posixpath, and parts of shutil to use 
PurePath and Path objects. Using path objects instead of generic strings should 
improve the implementation of os.path and shutil, in addition to ensuring 
consistency with pathlib. However, that's a long-term goal that doesn't 
preclude using os.path and shutil as needed now, such as relying on 
os.path.ismount().

--

___
Python tracker 

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



[issue46763] os.path.samefile incorrect results for shadow copies

2022-02-15 Thread Nick Venenga


New submission from Nick Venenga :

shutil.copy fails to copy a file from a shadow copy back to its original file 
since os.path.samefile returns True. os.path.samefile doesn't reliably detect 
these files are different since it relies on ino which is the same for both 
files

>>> sc = 
>>> pathlib.Path('//?/GLOBALROOT/Device/HarddiskVolumeShadowCopy3/test.file')
>>> o = pathlib.Path("V:/test.file")
>>> os.path.samefile(sc, o)
True
>>> os.stat(sc)
os.stat_result(st_mode=33206, st_ino=3458764513820579328, st_dev=1792739134, 
st_nlink=1, st_uid=0, st_gid=0, st_size=1, st_atime=1644973968, 
st_mtime=1644974052, st_ctime=1644973968)
>>> os.stat(o)
os.stat_result(st_mode=33206, st_ino=3458764513820579328, st_dev=1792739134, 
st_nlink=1, st_uid=0, st_gid=0, st_size=2, st_atime=1644973968, 
st_mtime=1644974300, st_ctime=1644973968)
>>> open(sc, "r").read()
'1'
>>> open(o, "r").read()
'12'

In the above example, you can see the shadow copy file and the original file. 
Their mode and ino are the same, but their modified time and contents are 
different

--
components: Windows
messages: 413307
nosy: nijave, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: os.path.samefile incorrect results for shadow copies
type: behavior
versions: Python 3.9

___
Python tracker 

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



[issue46762] assertion failure in f-string parsing Parser/string_parser.c

2022-02-15 Thread Eric V. Smith


Change by Eric V. Smith :


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

___
Python tracker 

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



[issue46541] Replace _Py_IDENTIFIER() with statically initialized objects.

2022-02-15 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +29514
pull_request: https://github.com/python/cpython/pull/31364

___
Python tracker 

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



[issue46541] Replace _Py_IDENTIFIER() with statically initialized objects.

2022-02-15 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +29513
pull_request: https://github.com/python/cpython/pull/31363

___
Python tracker 

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



[issue46752] Introduce task groups to asyncio and change task cancellation semantics

2022-02-15 Thread Guido van Rossum


Guido van Rossum  added the comment:

Remaining TODO list:

- Add a test showing the need for the .uncancel() call in __aexit__()
  (currently on line 97). Dropping that line does not cause any tests
  to fail.
- Ensure the taskgroup tests are run with the C and Python Task
  implementations.
- Rename tests to have meaningful names.
- I have a few ideas for minor cleanups that I will do later.
- Documentation and What's New entry (in a separate PR, probably).
- Update the docs in a few places to de-prioritize asyncio.gather()
  and steer people towards TaskGroups.

(We could also add something like Trio's cancel scopes, e.g. based on
Andrew Svetlov's async-timeout, which has a mature API.
But that should be a separate bpo issue.)

--

___
Python tracker 

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



[issue46752] Introduce task groups to asyncio and change task cancellation semantics

2022-02-15 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset 602630ac1855e38ef06361c68f6e216375a06180 by Guido van Rossum in 
branch 'main':
bpo-46752: Add TaskGroup; add Task..cancelled(),.uncancel() (GH-31270)
https://github.com/python/cpython/commit/602630ac1855e38ef06361c68f6e216375a06180


--

___
Python tracker 

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



[issue46737] Default to the standard normal distribution

2022-02-15 Thread Raymond Hettinger


Change by Raymond Hettinger :


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



[issue44445] Add `site-include` install scheme path in sysconfig

2022-02-15 Thread Stefano Rivera


Change by Stefano Rivera :


--
nosy: +stefanor

___
Python tracker 

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



[issue46737] Default to the standard normal distribution

2022-02-15 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 08ec80113b3b7f7a9eaa3d217494536b63305181 by Zackery Spytz in 
branch 'main':
bpo-46737: Add default arguments to random.gauss and normalvariate (GH-31360)
https://github.com/python/cpython/commit/08ec80113b3b7f7a9eaa3d217494536b63305181


--

___
Python tracker 

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



[issue43976] Allow Python distributors to add custom site install schemes

2022-02-15 Thread Stefano Rivera


Change by Stefano Rivera :


--
nosy: +stefanor

___
Python tracker 

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



[issue46762] assertion failure in f-string parsing Parser/string_parser.c

2022-02-15 Thread Eric V. Smith


Eric V. Smith  added the comment:

Good catch! I'll have a patch tonight.

--

___
Python tracker 

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



Re: venv and executing other python programs

2022-02-15 Thread Peter J. Holzer
On 2022-02-15 06:35:18 +0100, Mirko via Python-list wrote:
> I have recently started using venv for my hobby-programming. There
> is an annoying problem. Since venv modifies $PATH, python programs
> that use the "#!/usr/bin/env python" variant of the hashbang often
> fail since their additional modules aren't install inside in venv.
> 
> How to people here deal with that?

Use the hashbang line to couple your scripts to their venvs.

For example, here's the start of one of my scripts:

#! /usr/local/usradm/venv/bin/python3

import json
import os
...
import psycopg2
import psycopg2.extras
import cx_Oracle
...

When this script is run, the python interpreter will inspect it's own
pathname and pull in the venv from /usr/local/usradm/venv automatically,
regardless of the environment it is started in. I could run this from
cron (which has only /usr/bin and /bin in its PATH) or from my normal
command line or from a different venv.

You could use a different venv for every script, but that's pretty
wasteful, so you probably want to organize your venvs so that several
scripts can share their environment. For example by project or product
(as in my example - "usradm" is a our in-house user administration
system) or by capabilities (for example you might want one venv with
pandas and all your favourite graph libraries for all your analytics
scripts and another with Qt5 for some gui tools).


> Please note: I'm not interested in discussing whether the
> env-variant is good or bad. ;-) It's not that *I* use it, but
> several progs in /usr/bin/.

Progs in /usr/bin should IMHO never use /usr/bin/env. They should always
use #!/usr/bin/python3. You might want to report that as a bug to your
distribution.

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


[issue46762] assertion failure in f-string parsing Parser/string_parser.c

2022-02-15 Thread Ammar Askar


New submission from Ammar Askar :

Similar to https://bugs.python.org/issue46503 found by the ast.literal_eval 
fuzzer

```
>>> f'{<'
python: Parser/string_parser.c:346: fstring_compile_expr: Assertion `*expr_end 
== '}' || *expr_end == '!' || *expr_end == ':' || *expr_end == '='' failed.
[1]14060 abort  ./python
```

--
assignee: eric.smith
components: Parser
messages: 413302
nosy: ammar2, eric.smith, gregory.p.smith, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: assertion failure in f-string parsing Parser/string_parser.c
type: crash
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



[issue46738] Allow http.server to emit HTML 5

2022-02-15 Thread Jelle Zijlstra


Jelle Zijlstra  added the comment:

Looks like this is a duplicate of issue46736. Seems like a good idea though!

--
nosy: +Jelle Zijlstra
resolution:  -> duplicate
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



[issue46318] asyncio and ssl: ResourceWarning: unclosed transport

2022-02-15 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

Please check against the latest master.
It has rewritten SSL protocol implementation borrowed from uvloop.
See #44011 for details

--

___
Python tracker 

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



[issue46761] functools.update_wrapper breaks the signature of functools.partial objects

2022-02-15 Thread Larry Hastings


New submission from Larry Hastings :

It's considered good hygiene to use functools.update_wrapper() to make your 
wrapped functions look like the original.  However, when using 
functools.partial() to pre-supply arguments to a function, if you then call 
functools.update_wrapper() to update that partial object, inspect.signature() 
returns the *original* function's signature, not the *wrapped* function's 
signature.

To be precise: if you wrap a function with functools.partial() to pre-provide 
arguments, then immediately call inspect.signature() on that partial object, it 
returns the correct signature with the pre-filled parameters removed.  If you 
then call functools.update_wrapper() to update the partial from the original 
function, inspect.signature() now returns the *wrong* signature. 

I looked into it a little.  The specific thing changing inspect.signature()'s 
behavior is the '__wrapped__' attribute added by functools.update_wrapper().  
By default inspect.signature() will unwrap partial objects, but only if it has 
a '__wrapped__' attribute.

This all looks pretty deliberate.  And it seems like there was some thought 
given to this wrinkle; inspect.signature() takes a "follow_wrapper_chains" 
parameter the user can supply to control this behavior.  But the default is 
True, meaning that by default it unwraps partial objects if they have a 
'__wrapped__'.

I admit I don't have any context for this.  Why do we want inspect.signature() 
to return the wrong signature by default?

--
components: Library (Lib)
files: update_wrapper.breaks.partial.signature.test.py
messages: 413299
nosy: larry
priority: normal
severity: normal
stage: test needed
status: open
title: functools.update_wrapper breaks the signature of functools.partial 
objects
type: behavior
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9
Added file: 
https://bugs.python.org/file50625/update_wrapper.breaks.partial.signature.test.py

___
Python tracker 

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



[issue46760] test_dis should test the dis module, not everything else

2022-02-15 Thread Jelle Zijlstra


Change by Jelle Zijlstra :


--
nosy: +Jelle Zijlstra

___
Python tracker 

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



Re: venv and executing other python programs

2022-02-15 Thread Barry Scott



> On 15 Feb 2022, at 12:36, Martin Di Paola  wrote:
> 
> I did a few experiments in my machine. I created the following foo.py
> 
>  import pandas
>  print("foo")
> 
> Now "pandas" is installed under Python 3 outside the venv. I can run it 
> successfully calling "python3 foo.py".
> 
> If I add the shebang "#!/usr/bin/env python3" (notice the 3), I can also run 
> it as "./foo.py".

> 
> Calling it as "python foo.py" or using the shebang "#!/usr/bin/env python" 
> does not work and it makes sense since "pandas" is installed
> only for python 3.
> 
> New I create a virtual env with "python3 -m venv xxx" and activate it.
> 
> Once inside I can run foo.py in 4 different ways:
> 
> - python foo.py
> - python3 foo.py
> - ./foo.py (using the shebang "#!/usr/bin/env python")
> - ./foo.py (using the shebang "#!/usr/bin/env python3")
> 
> Now all of that was with "pandas" installed outside of venv but not inside.
> 
> I did the same experiments with another library, "cryptonita" which it is not 
> installed outside but inside and I was able to executed in 4 different ways 
> too (inside the venv of course):
> 
> - python foo.py
> - python3 foo.py
> - ./foo.py (using the shebang "#!/usr/bin/env python")
> - ./foo.py (using the shebang "#!/usr/bin/env python3")

If you have activated the venv then any script that uses /usr/bin/env will use 
executables from the venv
bin folder.

I'm seeing the following in the venv I made on my mac:

 % ls venv.tmp/bin
Activate.ps1dmgbuild*   modulegraph*pyi-archive_viewer* 
pyinstaller*python3.10@
activateds_store*   pip*pyi-bindepend*  
pylupdate5* pyuic5*
activate.cshmacho_dump* pip3*   pyi-grab_version*   
pyrcc5* wheel*
activate.fish   macho_find* pip3.10*pyi-makespec*   
python@
colour-print*   macho_standalone*   py2applet*  pyi-set_version*
python3@

You can see that "python", "python3" and "python3.10" are present.

So it does not help to change the /usr/bin/env to use python3.
Indeed its a feature that if you use /usr/bin/env you obviously want to use the
executable from the activated venv.

I avoid all these issues by not activating the venv. Python has code to know
how to use the venv libraries that are installed in it when invoked. It does 
not 
depend on the activate script being run.

Barry


> 
> Do you have a particular context where you are having troubles? May be there 
> is something else going on...
> 
> Thanks,
> Martin.
> 
> On Tue, Feb 15, 2022 at 06:35:18AM +0100, Mirko via Python-list wrote:
>> Hi,
>> 
>> I have recently started using venv for my hobby-programming. There
>> is an annoying problem. Since venv modifies $PATH, python programs
>> that use the "#!/usr/bin/env python" variant of the hashbang often
>> fail since their additional modules aren't install inside in venv.
>> 
>> How to people here deal with that?
>> 
>> Please note: I'm not interested in discussing whether the
>> env-variant is good or bad. ;-) It's not that *I* use it, but
>> several progs in /usr/bin/.
>> 
>> Thanks for your time.
>> -- 
>> https://mail.python.org/mailman/listinfo/python-list
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

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


Re: venv and executing other python programs

2022-02-15 Thread Barry



> On 15 Feb 2022, at 14:30, Mirko via Python-list  
> wrote:
> 
> Well, it's not that I activate the venv *for* those troubling
> programs. I activate it to work on the particular project. ;-)

It is not necessary to activate the venv to use the python in it.
So your solution is to not do the activate.

You can run venv/bin/python without the activation.

Barry


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


[issue46733] pathlib.Path methods can raise NotImplementedError

2022-02-15 Thread Barney Gale


Barney Gale  added the comment:

I'm planning to learn more heavily on posixpath + ntpath in pathlib once 
bpo-44136 is done. I think that would be a good time to introduce is_mount() 
support on Windows.

--

___
Python tracker 

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



[issue46741] Docstring for asyncio.protocols.BufferedProtocol appears out of date

2022-02-15 Thread Andrew Svetlov


Change by Andrew Svetlov :


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



[issue46741] Docstring for asyncio.protocols.BufferedProtocol appears out of date

2022-02-15 Thread Andrew Svetlov


Andrew Svetlov  added the comment:


New changeset 72c46462aa9fd0a69317917ba127e62f94ce08d7 by Miss Islington (bot) 
in branch '3.10':
bpo-46741: Update `asyncio.protocols.BufferedProtocol` docstring (GH-31327) 
(GH-31362)
https://github.com/python/cpython/commit/72c46462aa9fd0a69317917ba127e62f94ce08d7


--

___
Python tracker 

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



[issue46741] Docstring for asyncio.protocols.BufferedProtocol appears out of date

2022-02-15 Thread miss-islington


miss-islington  added the comment:


New changeset c292118ef3528df85a9d76ad21029009b560b088 by Miss Islington (bot) 
in branch '3.9':
bpo-46741: Update `asyncio.protocols.BufferedProtocol` docstring (31327)
https://github.com/python/cpython/commit/c292118ef3528df85a9d76ad21029009b560b088


--

___
Python tracker 

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



[issue46741] Docstring for asyncio.protocols.BufferedProtocol appears out of date

2022-02-15 Thread miss-islington


Change by miss-islington :


--
pull_requests: +29512
pull_request: https://github.com/python/cpython/pull/31362

___
Python tracker 

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



[issue46741] Docstring for asyncio.protocols.BufferedProtocol appears out of date

2022-02-15 Thread Andrew Svetlov


Andrew Svetlov  added the comment:


New changeset 1d81fdc4c004511c25f74db0e04ddbbb8a04ce6d by Alex Waygood in 
branch 'main':
bpo-46741: Update `asyncio.protocols.BufferedProtocol` docstring (31327)
https://github.com/python/cpython/commit/1d81fdc4c004511c25f74db0e04ddbbb8a04ce6d


--

___
Python tracker 

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



[issue46741] Docstring for asyncio.protocols.BufferedProtocol appears out of date

2022-02-15 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue46744] installers on ARM64 suggest wrong folders

2022-02-15 Thread Steve Dower


Steve Dower  added the comment:

Yeah, currently the only detection that happens is OS version, and just 
so we can block (or at least log) users who are trying to install on 
supported versions. The install directories are unconditional.

Any dynamic detection code would have to go into 
Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp and would 
update variables defined in Tools/msi/bundle/bundle.wxs. If you find the 
code for getting the ProgramFiles(Arm) directory, you'll see an example 
(which is probably the right one to update to handle the range of 
platforms).

However, I think we should consider the 32/64-bit install directory 
names to be a compatibility concern, and shouldn't modify them generally 
out of some kind of sense of "fairness". If it's trivial and safe to 
detect 64-bit running on ARM64 (which, as you say, it ought to be), then 
we can update its directory name there by default.

We should probably also display a notice in the installer when 
installing the Intel builds on ARM. The 64-bit version is fine, but the 
32-bit version has issues, and my experience so far is that the native 
build is significantly faster than both. We can do that another time though.

--

___
Python tracker 

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



[issue46737] Default to the standard normal distribution

2022-02-15 Thread Zackery Spytz


Zackery Spytz  added the comment:

I have created a patch for this issue.  Please consider having a look.

--

___
Python tracker 

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



[issue46737] Default to the standard normal distribution

2022-02-15 Thread Zackery Spytz


Change by Zackery Spytz :


--
keywords: +patch
nosy: +ZackerySpytz
nosy_count: 2.0 -> 3.0
pull_requests: +29510
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31360

___
Python tracker 

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



[issue20923] [doc] Explain ConfigParser 'valid section name' and .SECTCRE

2022-02-15 Thread Vidhya


Vidhya  added the comment:

Thanks.
A pull request is created at https://github.com/python/cpython/pull/31359.

--

___
Python tracker 

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



[issue20923] [doc] Explain ConfigParser 'valid section name' and .SECTCRE

2022-02-15 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 10.0 -> 11.0
pull_requests: +29509
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/31359

___
Python tracker 

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



Re: venv and executing other python programs

2022-02-15 Thread Mirko via Python-list
Am 15.02.2022 um 08:53 schrieb Barry Scott:
> Or are you running the program from the command line after activating the
> venv?

This ...

Am 15.02.2022 um 11:18 schrieb Roel Schroeven:
> Suppose you're working on a program which, for example, prints json
> to stdout. And suppose you want to use a tool like jq (let's call it
> pjq as an example) to process that output, by piping the output of
> your program to it:

... and this.


Am 15.02.2022 um 08:21 schrieb Reto:
> Don't activate the venv for those programs then?
> The point of a venv is that you only enter it when you actually want
> that specific python stack.

Well, it's not that I activate the venv *for* those troubling
programs. I activate it to work on the particular project. ;-)

> Get yourself a terminal that can either multiplex, or add something like
> tmux or screen to the mix if you frequently need other python tools
> during development.

I already do that (terminator, since I don't get tmux to behave as I
want it).


Am 15.02.2022 um 13:36 schrieb Martin Di Paola:
> I did a few experiments in my machine. I created the following foo.py
[SNIP]
> Do you have a particular context where you are having troubles? May
> be there is something else going on...

It seems to me that on your system, venv includes the site-packages
by default. For that I've found a solution: Create the venv with
--system-site-packages or in the venv's pyvenv.cfg just set/add
"include-system-site-packages = true"

Without this, I get the following (Python 3.6.9, Linux Mint 19,
Pandas installed in /usr/lib/python3/dist-packages/pandas):


[2,  0] mirko@wizbox:~$ vim /home/mirko/bin/foo.py
[2,  0] mirko@wizbox:~$ chmod +x /home/mirko/bin/foo.py
[2,  0] mirko@wizbox:~$ cat /home/mirko/bin/foo.py
#!/usr/bin/env python3

import pandas
print("Works")

[2,  0] mirko@wizbox:~$ foo.py
Works

[2,  0] mirko@wizbox:~$ python3 -m venv xxx
[2,  0] mirko@wizbox:~$ source xxx/bin/activate

(xxx) [2,  0] mirko@wizbox:~$ foo.py
Traceback (most recent call last):
  File "/home/mirko/bin/foo.py", line 3, in 
import pandas
ModuleNotFoundError: No module named 'pandas'

(xxx) [2,  1] mirko@wizbox:~$ deactivate
[2,  0] mirko@wizbox:~$ foo.py
Works


So, the problem seems to be solved. Thanks all! :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46760] test_dis should test the dis module, not everything else

2022-02-15 Thread Mark Shannon


New submission from Mark Shannon :



This is getting really annoying.
It takes longer to fix all the heavily coupled and poorly written tests in 
test_dis than to make the real changes.

Tiny changes in the calling sequence, or reordering CFGs, cause huge diffs in 
the test_dis module.
No one ever checks these changes, they are just noise.

I've put this under "enhancement" as there is no "wastes a huge amount of time" 
category.



The test_dis should not:

Contain offsets; they turn one line diffs into 100 line diffs
Contain tests for the compiler; they belong elsewhere.
Contain big strings; write proper tests not just regex matches.
Tests for Instruction should should not depend on the compiler output; create 
the bytecode directly.


This is not a new problem, but it does seem to be getting progressively worse.

A lot of the irritation stems from
https://github.com/python/cpython/commit/b39fd0c9b8dc6683924205265ff43cc597d1dfb9
although the tests from before that still hardcode offsets.

--
components: Tests
messages: 413291
nosy: Mark.Shannon
priority: normal
severity: normal
status: open
title: test_dis should test the dis module, not everything else
type: enhancement

___
Python tracker 

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



Re: ERROR IN DOWNLOADING PYTHON

2022-02-15 Thread Eryk Sun
On 2/15/22, 11_Anindita Das_BCA  wrote:
>
> I have downloaded the latest 3.10.2 version of python for my 64×64 bit
> laptop but I'm unable to work on it as my system is showing that
> api-ms-win-crt-runtime-l1-1-0-dll is missing but it's not the case as i
> have also downloaded this file.

I guess that you're using Windows 7 since Windows 10+ includes the
Universal C Runtime (ucrt) as a required system component, for which
"api-ms-win-crt-runtime-l1-1-0-dll" is a virtual API set (mapped to
ucrtbase.dll), which can never be missing, and since Windows 8.1 is
relatively uncommon (2-3% of installations).

Python 3.10 requires Windows 8.1 and above. If you're using Windows 7,
you should be able to install and use Python 3.8.10:

https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe

If you need to install ucrt, here's the link for the update that was
released in 2016:

https://support.microsoft.com/kb/3118401
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue46728] Docstring of combinations_with_replacement for consistency

2022-02-15 Thread DongGeon Lee


DongGeon Lee  added the comment:

My pleasure :)

--

___
Python tracker 

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



[issue46541] Replace _Py_IDENTIFIER() with statically initialized objects.

2022-02-15 Thread Dong-hee Na


Change by Dong-hee Na :


--
pull_requests: +29508
pull_request: https://github.com/python/cpython/pull/31358

___
Python tracker 

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



[issue44011] Borrow asyncio ssl implementation from uvloop

2022-02-15 Thread Andrew Svetlov


Change by Andrew Svetlov :


--
priority: critical -> normal

___
Python tracker 

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



ERROR IN DOWNLOADING PYTHON

2022-02-15 Thread 11_Anindita Das_BCA
Dear Sir/Mam
I have downloaded the latest 3.10.2 version of python for my 64×64 bit
laptop but I'm unable to work on it as my system is showing that
api-ms-win-crt-runtime-l1-1-0-dll is missing but it's not the case as i
have also downloaded this file.
Please let me know what should be my immediate step.
Looking forward to an early response from you
Yours Sincerely
Anindita Das
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Saving/exporting plots from Jupyter-labs?

2022-02-15 Thread Martin Schöön
Den 2022-02-15 skrev Reto :
> On Mon, Feb 14, 2022 at 08:54:01PM +, Martin Schöön wrote:
>> 1) In notebooks I can save a plot by right-clicking on it and do
>> save image as. In Jupyter-lab that does not work and so far I
>> have not been able to figure out how to do it. Yes, I have looked
>> in the documentation.
>
> Shift + right click brings up the usual browser menu

Thanks,

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


[issue44011] Borrow asyncio ssl implementation from uvloop

2022-02-15 Thread Andrew Svetlov


Andrew Svetlov  added the comment:

The code had landed.
Need a follow-up PR with documentation update (mention new ssl_shutdown_timeout 
arguments)

--

___
Python tracker 

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



[issue44011] Borrow asyncio ssl implementation from uvloop

2022-02-15 Thread Andrew Svetlov


Andrew Svetlov  added the comment:


New changeset 13c10bfb777483c7b02877aab029345a056b809c by Kumar Aditya in 
branch 'main':
bpo-44011: New asyncio ssl implementation (#31275)
https://github.com/python/cpython/commit/13c10bfb777483c7b02877aab029345a056b809c


--

___
Python tracker 

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



[issue46541] Replace _Py_IDENTIFIER() with statically initialized objects.

2022-02-15 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



Re: venv and executing other python programs

2022-02-15 Thread Martin Di Paola

I did a few experiments in my machine. I created the following foo.py

  import pandas
  print("foo")

Now "pandas" is installed under Python 3 outside the venv. I can run it 
successfully calling "python3 foo.py".


If I add the shebang "#!/usr/bin/env python3" (notice the 3), I can also 
run it as "./foo.py".


Calling it as "python foo.py" or using the shebang "#!/usr/bin/env 
python" does not work and it makes sense since "pandas" is installed

only for python 3.

New I create a virtual env with "python3 -m venv xxx" and activate it.

Once inside I can run foo.py in 4 different ways:

 - python foo.py
 - python3 foo.py
 - ./foo.py (using the shebang "#!/usr/bin/env python")
 - ./foo.py (using the shebang "#!/usr/bin/env python3")

Now all of that was with "pandas" installed outside of venv but not 
inside.


I did the same experiments with another library, "cryptonita" which it 
is not installed outside but inside and I was able to executed in 
4 different ways too (inside the venv of course):


 - python foo.py
 - python3 foo.py
 - ./foo.py (using the shebang "#!/usr/bin/env python")
 - ./foo.py (using the shebang "#!/usr/bin/env python3")

Do you have a particular context where you are having troubles? May be 
there is something else going on...


Thanks,
Martin.

On Tue, Feb 15, 2022 at 06:35:18AM +0100, Mirko via Python-list wrote:

Hi,

I have recently started using venv for my hobby-programming. There
is an annoying problem. Since venv modifies $PATH, python programs
that use the "#!/usr/bin/env python" variant of the hashbang often
fail since their additional modules aren't install inside in venv.

How to people here deal with that?

Please note: I'm not interested in discussing whether the
env-variant is good or bad. ;-) It's not that *I* use it, but
several progs in /usr/bin/.

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

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


[issue46728] Docstring of combinations_with_replacement for consistency

2022-02-15 Thread Dong-hee Na


Dong-hee Na  added the comment:

Thank you DongGeon :)

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



[issue46728] Docstring of combinations_with_replacement for consistency

2022-02-15 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset ad47db34be23c5cd75ed5d5c220d4b56a9b5683c by DongGeon Lee in 
branch '3.9':
[3.9] bpo-46728: fix docstring of combinations_with_replacement for consistency 
(GH-31293). (GH-31356)
https://github.com/python/cpython/commit/ad47db34be23c5cd75ed5d5c220d4b56a9b5683c


--

___
Python tracker 

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



[issue46759] sys.excepthook documentation doesn't mention that it isn't called for SystemExit

2022-02-15 Thread Colin Watson


Change by Colin Watson :


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

___
Python tracker 

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



[issue46759] sys.excepthook documentation doesn't mention that it isn't called for SystemExit

2022-02-15 Thread Colin Watson


New submission from Colin Watson :

In https://bugs.debian.org/1005803, Matthew Vernon reports that the library 
documentation for sys.excepthook doesn't mention the detail that that 
sys.excepthook isn't called for uncaught SystemExit exceptions, although 
help(sys) does mention this.

(He also mentions that help(sys.excepthook) doesn't mention this.  I think this 
would make less sense, since that gets the docstring of a particular 
implementation of an excepthook - on a given system it might not be Python's 
built-in version, for instance.  But adding information to the main library 
documentation seems reasonable.)

--
assignee: docs@python
components: Documentation
messages: 413285
nosy: cjwatson, docs@python
priority: normal
severity: normal
status: open
title: sys.excepthook documentation doesn't mention that it isn't called for 
SystemExit
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



[issue46758] Incorrect behaviour creating a Structure with ctypes.c_bool bitfields

2022-02-15 Thread SIGSEG V


New submission from SIGSEG V :

Setting/getting values in a Structure containing multiple c_bool bitfields like:
_fields_ = [
  ('one', c_bool, 1),
  ('two', c_bool, 1),
  ]
results in an unexpected behavior.
Setting any one of these fields to `True` results in ALL of these fields being 
set to `True` (i.e.: setting `struct.one` to `True` causes both `struct.one` as 
well as `struct.two` to be set to `True`.
This also results in the binary representation of the struct to be incorrect. 
The only possible outcomes for `bytes(struct)` are `b'\x00` and `b'\x01'`

Expected behavior should be that when setting `struct.one` only sets the 
desired field.
This is achievable when defining the same Structure with `c_byte` rather than 
`c_bool`.
When defining the struct like:
_fields_ = [
  ('one', c_byte, 1),
  ('two', c_byte, 1),
  ]
setting `struct.one` only affects `struct.one` and not `struct.two`.
The binary representation of the structure is also correct. When setting 
`struct.two` to `True`, `bytes(struct)` returns `b'\x02'` (aka. 0b10).

I've attached a Minimal Runnable Example that hopefully helps outline the issue.

--
components: Windows, ctypes
files: mre.py
messages: 413284
nosy: dudenwatschn, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Incorrect behaviour creating a Structure with ctypes.c_bool bitfields
type: behavior
versions: Python 3.10, Python 3.9
Added file: https://bugs.python.org/file50624/mre.py

___
Python tracker 

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



[issue46757] dataclasses should define an empty __post_init__

2022-02-15 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +eric.smith

___
Python tracker 

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



[issue46757] dataclasses should define an empty __post_init__

2022-02-15 Thread Neil Girdhar


New submission from Neil Girdhar :

When defining a dataclass, it's possible to define a post-init (__post_init__) 
method to, for example, verify contracts.

Sometimes, when you inherit from another dataclass, that dataclass has its own 
post-init method.  If you want that method to also do its checks, you need to 
explicitly call it with super.  However, if that method doesn't exist calling 
it with super will crash.

Since you don't know whether your superclasses implement post-init or not, 
you're forced to check if the superclass has one or not, and call it if it does.

Essentially, post-init implements an "augmenting pattern" like __init__, 
___enter__, __exit__, __array_finalize__, etc.  All such methods define an 
empty method at the top level so that child classes can safely call super.

Please consider adding such an empty method to dataclasses so that children who 
implement __post_init__ can safely call super.

--
components: Library (Lib)
messages: 413283
nosy: NeilGirdhar
priority: normal
severity: normal
status: open
title: dataclasses should define an empty __post_init__

___
Python tracker 

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



Re: venv and executing other python programs

2022-02-15 Thread Chris Angelico
On Tue, 15 Feb 2022 at 21:19, Roel Schroeven  wrote:
>
> Op 15/02/2022 om 8:21 schreef Reto:
> > On Tue, Feb 15, 2022 at 06:35:18AM +0100, Mirko via Python-list wrote:
> > > How to people here deal with that?
> >
> > Don't activate the venv for those programs then?
> > The point of a venv is that you only enter it when you actually want
> > that specific python stack.
> >
> > Get yourself a terminal that can either multiplex, or add something like
> > tmux or screen to the mix if you frequently need other python tools
> > during development.
> > Or just install those in you venv, after all if you
> > do use them for dev they are part of your dependencies, so declare them
> > as such.
> Still feels like a problem to me though.
>
> Suppose you're working on a program which, for example, prints json to
> stdout. And suppose you want to use a tool like jq (let's call it pjq as
> an example) to process that output, by piping the output of your program
> to it:
>
>  python your-program.py | pjq
>
> That seems to me a very sensible thing to do. If pjq is written in C,
> C++, Rust, Ruby, PHP, Go, or whatever, itis not a problem at all. To the
> user of pjq, it shouldn't matter at all in what language it's written,
> and mostly it doesn't matter at all indeed.
>
> But if pjq happens to be written in Python, it suddenly matters very
> much: it won't work in your venv (unless your venv happens to have the
> right modules).
>
> There are ways around it of course:
> - install the tool in your venv, like you say
> - from outside the venv: venv/bin/python your_program.py | pjq
> - from inside the venv: python your_program.py |  interpreter> 
> Or something like that. At least I think those should work, I haven't
> tested it.
>
> But it feels to wrong to have to use such workarounds simply because pjq
> happens to be written in the same language as you're writing your
> program in.
>

The pjq shebang shouldn't specify /usr/bin/env unless you want it to
run in whatever Python is the current default. In other words, if it
matters, be more specific. That usually means either using
/usr/bin/python3 for your system Python, or the interpreter out of the
venv itself - /path/to/venv/bin/python3 - to specify that.

You're absolutely right, workarounds like that are wrong. But the
wrongness comes from using env when you don't want env :)

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


[issue46728] Docstring of combinations_with_replacement for consistency

2022-02-15 Thread Dong-hee Na


Dong-hee Na  added the comment:


New changeset ac55cea3cbee4d40cf7320bd691f5327cff30f13 by DongGeon Lee in 
branch '3.10':
[3.10] bpo-46728: fix docstring of combinations_with_replacement for 
consistency (GH-31293) (GH-31350)
https://github.com/python/cpython/commit/ac55cea3cbee4d40cf7320bd691f5327cff30f13


--

___
Python tracker 

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



[issue46728] Docstring of combinations_with_replacement for consistency

2022-02-15 Thread DongGeon Lee


Change by DongGeon Lee :


--
pull_requests: +29506
pull_request: https://github.com/python/cpython/pull/31356

___
Python tracker 

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



[issue46755] QueueHandler logs stack_info twice

2022-02-15 Thread Erik Montnemery


Change by Erik Montnemery :


--
keywords: +patch
nosy: +emontnemery
nosy_count: 1.0 -> 2.0
pull_requests: +29504
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31355

___
Python tracker 

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



Re: venv and executing other python programs

2022-02-15 Thread Roel Schroeven

Op 15/02/2022 om 8:21 schreef Reto:

On Tue, Feb 15, 2022 at 06:35:18AM +0100, Mirko via Python-list wrote:
> How to people here deal with that?

Don't activate the venv for those programs then?
The point of a venv is that you only enter it when you actually want
that specific python stack.

Get yourself a terminal that can either multiplex, or add something like
tmux or screen to the mix if you frequently need other python tools
during development.
Or just install those in you venv, after all if you
do use them for dev they are part of your dependencies, so declare them
as such.

Still feels like a problem to me though.

Suppose you're working on a program which, for example, prints json to 
stdout. And suppose you want to use a tool like jq (let's call it pjq as 
an example) to process that output, by piping the output of your program 
to it:


    python your-program.py | pjq

That seems to me a very sensible thing to do. If pjq is written in C, 
C++, Rust, Ruby, PHP, Go, or whatever, itis not a problem at all. To the 
user of pjq, it shouldn't matter at all in what language it's written, 
and mostly it doesn't matter at all indeed.


But if pjq happens to be written in Python, it suddenly matters very 
much: it won't work in your venv (unless your venv happens to have the 
right modules).


There are ways around it of course:
- install the tool in your venv, like you say
- from outside the venv: venv/bin/python your_program.py | pjq
- from inside the venv: python your_program.py | interpreter> 
Or something like that. At least I think those should work, I haven't 
tested it.


But it feels to wrong to have to use such workarounds simply because pjq 
happens to be written in the same language as you're writing your 
program in.


--
"A common mistake that people make when trying to design something completely
foolproof is to underestimate the ingenuity of complete fools."
-- Douglas Adams

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


[issue31084] QueueHandler not formatting messages

2022-02-15 Thread Erik Montnemery


Change by Erik Montnemery :


--
nosy: +emontnemery
nosy_count: 2.0 -> 3.0
pull_requests: +29505
pull_request: https://github.com/python/cpython/pull/31355

___
Python tracker 

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



[issue46728] Docstring of combinations_with_replacement for consistency

2022-02-15 Thread Dong-hee Na


Dong-hee Na  added the comment:

@LeeDongGeon1996

Please send the backported patch to 3.9 also

--

___
Python tracker 

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



[issue46728] Docstring of combinations_with_replacement for consistency

2022-02-15 Thread Dong-hee Na


Change by Dong-hee Na :


--
versions:  -Python 3.7, Python 3.8

___
Python tracker 

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



[issue46724] Odd Bytecode Generation in 3.10

2022-02-15 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +29503
pull_request: https://github.com/python/cpython/pull/31354

___
Python tracker 

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



[issue46756] Incorrect authorization check in urllib.request

2022-02-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
title: Incorrect -> Incorrect authorization check in urllib.request

___
Python tracker 

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



[issue46756] Incorrect

2022-02-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue46756] Incorrect

2022-02-15 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There is an error in determining a sub-URI in the urllib.request module. Due to 
it, if the user is authorized for example.org/foo, it gets also access to 
example.org/foobar.

--
components: Library (Lib)
messages: 413280
nosy: orsenthil, serhiy.storchaka
priority: high
severity: normal
status: open
title: Incorrect
type: security
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



[issue46724] Odd Bytecode Generation in 3.10

2022-02-15 Thread Mark Shannon


Change by Mark Shannon :


--
pull_requests: +29501
pull_request: https://github.com/python/cpython/pull/31352

___
Python tracker 

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



[issue46541] Replace _Py_IDENTIFIER() with statically initialized objects.

2022-02-15 Thread Erlend E. Aasland


Change by Erlend E. Aasland :


--
nosy: +erlendaasland
nosy_count: 5.0 -> 6.0
pull_requests: +29500
pull_request: https://github.com/python/cpython/pull/31351

___
Python tracker 

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



[issue46724] Odd Bytecode Generation in 3.10

2022-02-15 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 3be1a443ca8e7d4ba85f95b78df5c4122cae9ede by Mark Shannon in 
branch 'main':
bpo-46724: Use `JUMP_ABSOLUTE` for all backward jumps. (GH-31326)
https://github.com/python/cpython/commit/3be1a443ca8e7d4ba85f95b78df5c4122cae9ede


--

___
Python tracker 

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



[issue46728] Docstring of combinations_with_replacement for consistency

2022-02-15 Thread DongGeon Lee


Change by DongGeon Lee :


--
pull_requests: +29499
pull_request: https://github.com/python/cpython/pull/31350

___
Python tracker 

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



[issue46755] QueueHandler logs stack_info twice

2022-02-15 Thread Erik Montnemery


New submission from Erik Montnemery :

logging.handlers.QueueHandler logs stack twice when stack_info=True:

>>> import logging
>>> from logging.handlers import QueueHandler, QueueListener
>>> from queue import Queue
>>> q = Queue()
>>> logging.getLogger().addHandler(QueueHandler(q))
>>> listener = QueueListener(q, logging.StreamHandler())
>>> listener.start()
>>> _LOGGER.error("Hello", stack_info=True)
Hello
Stack (most recent call last):
  File "", line 1, in 
Stack (most recent call last):
  File "", line 1, in 


Reproduced on CPython 3.9.9, but the code is unchanged in 3.10 and 3.11, so the 
issue should exist there too.

Patching QueueHandler.prepare() to set stack_info to None seems to fix this:

diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index d42c48de5f..7cd5646d85 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -1452,6 +1452,7 @@ def prepare(self, record):
 record.args = None
 record.exc_info = None
 record.exc_text = None
+record.stack_info = None
 return record

 def emit(self, record):

Related issue: Issue34334, with patch 
https://github.com/python/cpython/pull/9537

--
components: Library (Lib)
messages: 413278
nosy: erik.montnemery
priority: normal
severity: normal
status: open
title: QueueHandler logs stack_info twice
type: behavior
versions: Python 3.9

___
Python tracker 

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