[issue43898] Python fails to import .dylib but works when extension is changed to .so

2021-04-21 Thread Ned Deily


Ned Deily  added the comment:

Thanks for the clarification. On most platforms other than Windows, Python 
expects compiled extension modules (usually written in C or C++) to have an 
extension of .so. This is true as well on macOS. Typically, extension modules 
are compiled using Python's Distutils, or one of its newer derivatives, which 
takes care of creating the proper extension module file name. If you are 
building an extension module with something else, you'll need to ensure that 
the shared library file name has the expected format. Note that PEP 3149, 
implemented in Python 3.2, extends the filename extension to include the Python 
version (although unversioned .so file names are still accepted for 
compatibility); see 
https://docs.python.org/3/whatsnew/3.2.html#pep-3149-abi-version-tagged-so-files
 for more information.

$ python3 -c 'import sysconfig;print(sysconfig.get_config_var("EXT_SUFFIX"))'
.cpython-39-darwin.so

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



[issue27763] Add complex case to test_builtin abs()

2021-04-21 Thread Sergey B Kirpichev


Sergey B Kirpichev  added the comment:

> We're testing the cmath functions on complex number inputs

Indeed.  Also, for abs(complex) - there is test_abs() in the test_complex.py.

> The complex number creation from both strings and pairs of floats should be 
> tested independently, of course.

It seems, there are such tests as well.  E.g. test_constructor() in the same 
file.

Mark, perhaps this can be closed?

--
nosy: +Sergey.Kirpichev

___
Python tracker 

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



[issue28724] Add method send_io, recv_io to the socket module.

2021-04-21 Thread Inada Naoki


Change by Inada Naoki :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.9 -Python 3.7

___
Python tracker 

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



[issue28724] Add method send_io, recv_io to the socket module.

2021-04-21 Thread miss-islington


miss-islington  added the comment:


New changeset 87a392db40d52cba18ffc67730856e11cb8cf945 by Miss Islington (bot) 
in branch '3.9':
bpo-28724: Doc: Move socket.send_fds and socket.recv_fds docs to right section 
(GH-22608)
https://github.com/python/cpython/commit/87a392db40d52cba18ffc67730856e11cb8cf945


--

___
Python tracker 

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



[issue43909] Fuzz dis module and find crashes for dis.dis(), dis.get_instructions() dis.show_code()

2021-04-21 Thread Xinmeng Xia


New submission from Xinmeng Xia :

We write a fuzz tool to fuzz Python standard libraries, and find three crashes: 
dis.dis(),  dis.get_instructions() dis.show_code() in dis module. 


dis.dis()
==
xiaxinmeng:~ xiaxinmeng$ python3.10
Python 3.10.0a3 (v3.10.0a3:8bae2a958e, Dec  7 2020, 15:31:51) 
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dis
>>> dis.dis("s%-yPdrns"*100)
Segmentation fault: 11
=


dis.get_instructions()
=
Python 3.10.0a3 (v3.10.0a3:8bae2a958e, Dec  7 2020, 15:31:51) 
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dis
>>> dis.get_instructions("c/f/x"*100)
Segmentation fault: 11
==


dis.show_code()
===
Python 3.10.0a3 (v3.10.0a3:8bae2a958e, Dec  7 2020, 15:31:51) 
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dis
>>> dis.show_code("G/7/K"*100)
Segmentation fault: 11


--
components: Library (Lib)
messages: 391574
nosy: xxm
priority: normal
severity: normal
status: open
title: Fuzz dis module and find crashes for dis.dis(),  dis.get_instructions() 
dis.show_code()
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



[issue28724] Add method send_io, recv_io to the socket module.

2021-04-21 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 8.0 -> 9.0
pull_requests: +24235
pull_request: https://github.com/python/cpython/pull/25517

___
Python tracker 

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



[issue28724] Add method send_io, recv_io to the socket module.

2021-04-21 Thread Inada Naoki


Inada Naoki  added the comment:


New changeset 660592f67c0d825b06eb4a38ccc04b34a1f01f00 by Saiyang Gou in branch 
'master':
bpo-28724: Doc: Move socket.send_fds and socket.recv_fds docs to right section 
(GH-22608)
https://github.com/python/cpython/commit/660592f67c0d825b06eb4a38ccc04b34a1f01f00


--

___
Python tracker 

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



[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Guido van Rossum

Guido van Rossum  added the comment:

I’d say that best practices for 3.9+ are more useful.

There seem to be several contradictions in your remarks, but we’ll get to those 
in the review.

--
nosy: +Guido.van.Rossum

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Ethan Furman


Ethan Furman  added the comment:

Actually, I think that fixed the refleak issue as well.

Thanks, Ammar!

--

___
Python tracker 

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



[issue30800] zlib.compressobj took too much memory on window

2021-04-21 Thread Inada Naoki


Change by Inada Naoki :


--
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 37b173c5231b7b202859af97c17bc3d04b1e4c75 by Ammar Askar in branch 
'master':
bpo-38659: Properly re-intialize module variables in test_enum (GH-25516)
https://github.com/python/cpython/commit/37b173c5231b7b202859af97c17bc3d04b1e4c75


--

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Ethan Furman


Ethan Furman  added the comment:

`format` issue resolved, but not the refleak issue.

--

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Ammar Askar


Change by Ammar Askar :


--
pull_requests: +24234
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/25516

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Ammar Askar


Ammar Askar  added the comment:

Looks like this is the issue described in the comment here: 
https://github.com/python/cpython/blob/master/Lib/test/test_enum.py#L3691-L3692

On the first run you have the correct

  ('CONVERT_STRING_TEST_NAME_A', 5)

but later it turns into

  ('CONVERT_STRING_TEST_NAME_A', test.test_enum.CONVERT_STRING_TEST_NAME_A)

causing double-conversions of the enum elements. This causes the format(x) test 
to fail. You can re-create the same issue outside of the refleak by adding a 
simple:

def test_convert_repr_and_str_again(self):
self.test_convert_repr_and_str()

method.

--
nosy: +ammar2

___
Python tracker 

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



[issue38692] add a pidfd child process watcher

2021-04-21 Thread Chih-Hsuan Yen


Change by Chih-Hsuan Yen :


--
nosy:  -yan12125

___
Python tracker 

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



[issue42422] types.CodeType() has no bytecode verifier

2021-04-21 Thread Benjamin Peterson


Change by Benjamin Peterson :


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



[issue38692] add a pidfd child process watcher

2021-04-21 Thread Saiyang Gou


Change by Saiyang Gou :


--
nosy: +gousaiyang
nosy_count: 10.0 -> 11.0
pull_requests: +24233
pull_request: https://github.com/python/cpython/pull/25515

___
Python tracker 

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



[issue28724] Add method send_io, recv_io to the socket module.

2021-04-21 Thread Saiyang Gou


Change by Saiyang Gou :


--
nosy: +gousaiyang
nosy_count: 7.0 -> 8.0
pull_requests: +24232
pull_request: https://github.com/python/cpython/pull/22608

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Can someone take a look?

As per the buildbot policy 
(https://discuss.python.org/t/policy-to-revert-commits-on-buildbot-failure/404) 
we may need to revert it if is not fixed in 24 because of the risk of masking 
errors.

--

___
Python tracker 

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



[issue12403] Mention sys.displayhook in code module docs and the compile builtin docs

2021-04-21 Thread Irit Katriel


Irit Katriel  added the comment:

The patch for the code module doc needs to be converted into a github PR.

A new patch is needed for the compile builtin documentation: 
https://docs.python.org/3/library/functions.html#compile
This could be added at the end of the third paragraph, where it says that in 
'single' mode non-None results are printed - clarify that sys.displayhook is 
used for that.

(See these unit tests for examples: 
https://github.com/python/cpython/blob/09b90a037d18f5d4acdf1b14082e57bda78e85d3/Lib/test/test_sys.py#L26)

--
keywords: +easy -patch
nosy: +iritkatriel
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.1, Python 
3.3

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
priority: normal -> release blocker

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

Commit a02cb474f9c097c83cd444a47e9fb5f99b4aaf45 fails to build in the refleak 
buildbots:

https://buildbot.python.org/all/#/builders/75/builds/2/steps/5/logs/stdio

Example failure:

❯ ./python  -m test test_enum -R :
0:00:00 load avg: 1.81 Run tests sequentially
0:00:00 load avg: 1.81 [1/1] test_enum
beginning 9 repetitions
123456789
.test test_enum failed -- Traceback (most recent call last):
  File "/home/pablogsal/github/python/master/Lib/test/test_enum.py", line 3700, 
in test_convert_repr_and_str
self.assertEqual(format(test_type.CONVERT_STRING_TEST_NAME_A), '5')
AssertionError: 'CONVERT_STRING_TEST_NAME_A' != '5'
- CONVERT_STRING_TEST_NAME_A
+ 5


test_enum failed

== Tests result: FAILURE ==

1 test failed:
test_enum

Total duration: 586 ms
Tests result: FAILURE

--
nosy: +pablogsal
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue26227] Windows: socket.gethostbyaddr(name) fails for non-ASCII hostname

2021-04-21 Thread miss-islington


miss-islington  added the comment:


New changeset d8576b1d15155688a67baac24c15254700bdd3b7 by Miss Islington (bot) 
in branch '3.9':
bpo-26227: Fixes decoding of host names on Windows from ANSI instead of UTF-8 
(GH-25510)
https://github.com/python/cpython/commit/d8576b1d15155688a67baac24c15254700bdd3b7


--

___
Python tracker 

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



[issue26227] Windows: socket.gethostbyaddr(name) fails for non-ASCII hostname

2021-04-21 Thread miss-islington


miss-islington  added the comment:


New changeset f7bc44170b4bdd16c46b4b6acf7673ffc24dfb19 by Miss Islington (bot) 
in branch '3.8':
bpo-26227: Fixes decoding of host names on Windows from ANSI instead of UTF-8 
(GH-25510)
https://github.com/python/cpython/commit/f7bc44170b4bdd16c46b4b6acf7673ffc24dfb19


--

___
Python tracker 

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



[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Larry Hastings


Larry Hastings  added the comment:

> * Never modify o.__annotations__.

Let me revise that to:

* If o.__annotations__ is a dict, never modify the contents of that dict.

--

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread STINNER Victor


STINNER Victor  added the comment:

IMO we spent enough time micro-optimizing _functools and 
_PyType_GetModuleByDef(). I don't think that it's worth it to spend too much 
time trying to investigate differences between benchmarks around +- 1 ns on ~40 
ns. I close the issue.

Thanks Raymond for fixing the slowdown ;-)

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread STINNER Victor


STINNER Victor  added the comment:

msg391004 benchmark comparing master with Raymond's optimization (commit 
139c232f3851b393798d0ea4e65f1298bfbcd9cf) compared to Python 3.9:

Mean +- std dev: [py39] 38.8 ns +- 0.5 ns -> [obj_cache] 40.3 ns +- 0.1 ns: 
1.04x slower

For me, these numbers make no sense :-D Getting kwd_mark from the instance 
(Raymond's new code) *must* be faster than calling _PyType_GetModuleByDef() on 
the instance.

As I wrote in my previous comment, my bet is that PGO is not reproducible and 
so we should not pay too much attention to differences of a few nanoseconds.

--

___
Python tracker 

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



[issue43756] About updating audit events when function gains new arguments

2021-04-21 Thread Steve Dower


Change by Steve Dower :


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

___
Python tracker 

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



[issue26227] Windows: socket.gethostbyaddr(name) fails for non-ASCII hostname

2021-04-21 Thread Steve Dower


Change by Steve Dower :


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

___
Python tracker 

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



[issue26227] Windows: socket.gethostbyaddr(name) fails for non-ASCII hostname

2021-04-21 Thread Steve Dower


Steve Dower  added the comment:


New changeset dc516ef8395d15da0ab225eb0dceb2e0581f51ca by Steve Dower in branch 
'master':
bpo-26227: Fixes decoding of host names on Windows from ANSI instead of UTF-8 
(GH-25510)
https://github.com/python/cpython/commit/dc516ef8395d15da0ab225eb0dceb2e0581f51ca


--

___
Python tracker 

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



[issue26227] Windows: socket.gethostbyaddr(name) fails for non-ASCII hostname

2021-04-21 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24231
pull_request: https://github.com/python/cpython/pull/25513

___
Python tracker 

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



[issue26227] Windows: socket.gethostbyaddr(name) fails for non-ASCII hostname

2021-04-21 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 11.0 -> 12.0
pull_requests: +24230
pull_request: https://github.com/python/cpython/pull/25512

___
Python tracker 

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



[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Larry Hastings


Larry Hastings  added the comment:

It occurs to me that part of this work should also be a new "best practices for 
__annotations__" entry in the Python docs.


Best practices for working with annotations, for code that requires a minimum 
Python version of 3.10+:

Best practice is to call either inspect.get_annotations() or 
typing.get_type_hints() to access annotations.  But if you want to access 
'__annotations__' on an object directly:

* Always access the annotations on an object using the attribute interface, 
either o.__annotations__ or getattr(o, '__annotations__').  Accessing 
'__annotations__' through other mechanisms (e.g. looking in the class dict) is 
unsupported.
* Assume that o.__annotations__ is always either a dict or None.
* It's best to not assign to o.__annotations__.  But if you must, always set it 
to either a dict or None.
* Never delete o.__annotations__.
* Never modify o.__annotations__.

--

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread STINNER Victor


STINNER Victor  added the comment:

New microbenchmark on the functools.lru_cache(lambda: 42) function using my 3 
optimizations on _PyType_GetModuleByDef():

* commit d4aaa34798f0dd8402f412e2aa9d6fa2d6cff5fa
* commit 760da626ff4124e1344fd8b7dbeb83b2c4b7c12c
* commit cdad2724e6f7426372901cc5dedd8a462ba046a6
* I didn't pick Raymond's optimization for this benchmark, so I can still use 
_functools for my benchmark.

$ python3 -m pyperf compare_to py39.json master.json 
Mean +- std dev: [py39] 38.8 ns +- 0.5 ns -> [master] 39.2 ns +- 0.9 ns: 1.01x 
slower

The _PyType_GetModuleByDef() overhead in _functools is now about +0.4 ns, it's 
better than my previous measurement before optimization: +5.7 ns (37.5 ns +- 
1.0 ns -> 43.2 ns +- 0.7 ns).

These timings are really tiny, it's really hard to get reliable timing even 
with CPU isolation. For example, two measurements on Python 3.9:

* Old measurement: 37.5 ns +- 1.0 ns
* New measurement: 38.8 ns +- 0.5 ns

I guess that for timings under 100 ns, the PGO build is no longer reliable 
enough. Moreover, the std dev is around to 1 ns on 40 ns.

--

___
Python tracker 

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



[issue42737] PEP 563: drop annotations for complex assign targets

2021-04-21 Thread Saiyang Gou


Change by Saiyang Gou :


--
pull_requests: +24229
pull_request: https://github.com/python/cpython/pull/25511

___
Python tracker 

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



[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Larry Hastings


Larry Hastings  added the comment:

By the way, here's a tidbit I never got around to posting in c.l.p-d.

I noted in the conversation in January that attrs is an outlier here: it 
*doesn't* look in the class dict for __annotations__.  Instead, it has some 
complicated code where it asks the class for its annotations, then iterates 
over the __mro__ and asks every base class for *its* annotations.  If the class 
and a base class have the same class dict (using the "is" operator iirc) then 
attrs says "oh, that class doesn't have its own annotations, it's inheriting 
them" and reacts appropriately.

I emailed Hynek to ask him why he did it that way.  It turns out, he did that 
because at the time he didn't know you could peek in the class dict for 
__annotations__.  He literally had a todo item saying "change to looking in the 
class dict".

--

___
Python tracker 

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



[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Larry Hastings


Larry Hastings  added the comment:

> - Is it possible to create __annotations__ lazily? (IIRC in January we came 
> to a conclusion about this, something like yes for modules but for classes, 
> or the other way around?)

Maybe for modules, definitely not for classes.  The problem is that best 
practice for classes is to look in the class dict for __annotations__.  That 
sidesteps the inheritance problem.

Functions already lazily create a dict __annotations__ if not set.  And it's 
not stored in the function dict.  So nobody ever looks in the function dict for 
__annotations__.  That all works fine.

Would you prefer that *just classes* lazily create __annotations__?  It's not 
hard code to write, but I was being cautious.  "always set __annotations__ to 
an empty dict" is the easiest code to write and get correct.  And since modules 
are not all that numerous even in the largest projects, it seemed like this 
un-optimized approach would have a minimal contribution to the heat death of 
the universe.

It's also remotely possible that someone out there does look in the module dict 
for __annotations__, though I admit I've never seen it.  It seems like it'd be 
tempting to write your code that way though:

if isinstance(o, (type, types.ModuleType)):
ann = o.__dict__.get("__annotations__", None)
elif callable(o):
ann = o.__annotations__
else:
raise ValueError(f"{o!r} doesn't support annotations")


> - Why would __annotations__ ever be None?

Simply because it's the cheapest sensible way to indicate "this object has no 
annotations".  It would be nice if the world accepted __annotations__ being 
None to mean "no annotations".  But I don't think we're there.

I note that the function object has a special setter for __annotations__ 
(func_set_annotations()), since at least Python 3.1, which explicitly only 
allows setting __annotations__ to either a dict or None.  (I didn't have 3.0 
handy.)


> Why do you allow setting it to None?

Me?  I've never contributed code to Python that restricts the permissible types 
of values one is allowed to set on __annotations__.

Function objects are opinionated as mentioned (either dict or None), classes 
and modules have no opinion whatsoever, and allow you to set __annotations__ to 
any value.  That was all true long before I started working on annotations.


> Do we know of people ever write '__annotations__ = None' in their class or 
> write 'cls.__annotations__ = None'?

AFAIK I've never seen anyone set __annotations__ to None.


> - And where's your PR?

Not done yet.  I only started it last night, and there were a lot of test 
failures--it turns out, a *lot* of regression tests do a sanity check that 
__annotations__ isn't set on classes (and maybe modules too).  For example, I 
was surprised that test_opcodes has two such test failures.

--

___
Python tracker 

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



[issue43472] [security][subinterpreters] Add auditing hooks to subinterpreter module

2021-04-21 Thread miss-islington


miss-islington  added the comment:


New changeset 602eefef0bd0187049c2ab9071390f8573fc299a by Miss Islington (bot) 
in branch '3.8':
bpo-43472: Ensure PyInterpreterState_New audit events are raised when called 
through _xxsubinterpreters module (GH-25506)
https://github.com/python/cpython/commit/602eefef0bd0187049c2ab9071390f8573fc299a


--

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset cdad2724e6f7426372901cc5dedd8a462ba046a6 by Victor Stinner in 
branch 'master':
bpo-40137: Add pycore_moduleobject.h internal header (GH-25507)
https://github.com/python/cpython/commit/cdad2724e6f7426372901cc5dedd8a462ba046a6


--

___
Python tracker 

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



[issue43756] About updating audit events when function gains new arguments

2021-04-21 Thread Steve Dower


Steve Dower  added the comment:


New changeset a32f8fe7133aad4f3cf8946534e3b79a5f2659da by Saiyang Gou in branch 
'master':
bpo-43756: Add new audit event for new arguments added to glob.glob (GH-25239)
https://github.com/python/cpython/commit/a32f8fe7133aad4f3cf8946534e3b79a5f2659da


--

___
Python tracker 

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



[issue26227] Windows: socket.gethostbyaddr(name) fails for non-ASCII hostname

2021-04-21 Thread Steve Dower


Change by Steve Dower :


--
assignee:  -> steve.dower

___
Python tracker 

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



[issue26227] Windows: socket.gethostbyaddr(name) fails for non-ASCII hostname

2021-04-21 Thread Steve Dower


Change by Steve Dower :


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

___
Python tracker 

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



[issue43472] [security][subinterpreters] Add auditing hooks to subinterpreter module

2021-04-21 Thread Steve Dower


Change by Steve Dower :


--
assignee:  -> steve.dower
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.8, Python 3.9

___
Python tracker 

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



[issue43472] [security][subinterpreters] Add auditing hooks to subinterpreter module

2021-04-21 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24227
pull_request: https://github.com/python/cpython/pull/25509

___
Python tracker 

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



[issue43472] [security][subinterpreters] Add auditing hooks to subinterpreter module

2021-04-21 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue43472] [security][subinterpreters] Add auditing hooks to subinterpreter module

2021-04-21 Thread Steve Dower


Steve Dower  added the comment:


New changeset 7b86e47617d81a4b14d929743425f448971e8c86 by Steve Dower in branch 
'master':
bpo-43472: Ensure PyInterpreterState_New audit events are raised when called 
through _xxsubinterpreters module (GH-25506)
https://github.com/python/cpython/commit/7b86e47617d81a4b14d929743425f448971e8c86


--

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 139c232f3851b393798d0ea4e65f1298bfbcd9cf by Raymond Hettinger in 
branch 'master':
bpo-40137: Move state lookups out of the critical path (GH-25492)
https://github.com/python/cpython/commit/139c232f3851b393798d0ea4e65f1298bfbcd9cf


--

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24225
pull_request: https://github.com/python/cpython/pull/25507

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 760da626ff4124e1344fd8b7dbeb83b2c4b7c12c by Victor Stinner in 
branch 'master':
bpo-40137: Optimize _PyType_GetModuleByDef() loop (GH-25505)
https://github.com/python/cpython/commit/760da626ff4124e1344fd8b7dbeb83b2c4b7c12c


--

___
Python tracker 

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



[issue43472] [security][subinterpreters] Add auditing hooks to subinterpreter module

2021-04-21 Thread Steve Dower


Change by Steve Dower :


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

___
Python tracker 

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



[issue43472] [security][subinterpreters] Add auditing hooks to subinterpreter module

2021-04-21 Thread Steve Dower


Steve Dower  added the comment:

I'll need Eric to confirm, but I think the best thing to do here is to not 
release the thread state in _xxsubinterpreters.interp_create, but let 
_Py_NewInterpreter() do it. That way the existing event will be raised in 
interpreter-level hooks, rather than only the process-wide hook.

PR incoming.

--

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24223
pull_request: https://github.com/python/cpython/pull/25505

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d4aaa34798f0dd8402f412e2aa9d6fa2d6cff5fa by Victor Stinner in 
branch 'master':
bpo-40137: _PyType_GetModuleByDef() doesn't check tp_flags (GH-25504)
https://github.com/python/cpython/commit/d4aaa34798f0dd8402f412e2aa9d6fa2d6cff5fa


--

___
Python tracker 

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



[issue42737] PEP 563: drop annotations for complex assign targets

2021-04-21 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

> Hum, there seems to be an actual bug here: even with PEP 563, the annotations 
> for "complex targets" are evaluated. For example:

Yes, that is what this issue is about. This bug only surfaced while doing other 
stuff and PEP 563 being the default

> I think the "LOAD_NAME(x), POP_TOP" part is correct, but "LOAD_NAME(z), 
> LOAD_ATTR(w), POP_TOP" should not be generated at all.

Agreed, which is what the PR 23952 has proposed.

I'll proceed with the PR and update it according to the revert of PEP 563, 
which should hopefully fix this only when the future flag is activated.

--

___
Python tracker 

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



[issue42737] PEP 563: drop annotations for complex assign targets

2021-04-21 Thread Guido van Rossum


Guido van Rossum  added the comment:

The same thing happens at the module level. However in functions all is well 
(because inside functions annotations are never evaluated, apparently).

It may be as simple as the code forgetting to check the PEP 563 bit when 
generating code for complex annotations in classes and at the top (module) 
level.

--

___
Python tracker 

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



[issue42737] PEP 563: drop annotations for complex assign targets

2021-04-21 Thread Guido van Rossum


Guido van Rossum  added the comment:

Hum, there seems to be an actual bug here: even with PEP 563, the annotations 
for "complex targets" are evaluated. For example:

from __future__ import annotations
class C:
x.y: z.w
a: b.c

The relevant parts of the disassembly of the code for the class object are:

  3  10 LOAD_NAME3 (x)
 12 POP_TOP
 14 LOAD_NAME4 (z)
 16 LOAD_ATTR5 (w)
 18 POP_TOP

  4  20 LOAD_CONST   1 ('b.c')
 22 LOAD_NAME6 (__annotations__)
 24 LOAD_CONST   2 ('a')
 26 STORE_SUBSCR

So for x.y: z.w, not only do we evaluate x, we also evaluate z.w; whereas b.c 
is not evaluated (the stringified version is added as __annotations__['a']).

I think the "LOAD_NAME(x), POP_TOP" part is correct, but "LOAD_NAME(z), 
LOAD_ATTR(w), POP_TOP" should not be generated at all.

--

___
Python tracker 

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



[issue38119] resource tracker destroys shared memory segments when other processes should still have valid access

2021-04-21 Thread David Felsen


Change by David Felsen :


--
nosy: +davfelsen

___
Python tracker 

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



[issue40137] TODO list when PEP 573 "Module State Access from C Extension Methods" will be implemented

2021-04-21 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24222
pull_request: https://github.com/python/cpython/pull/25504

___
Python tracker 

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



[issue43908] array.array should remain immutable

2021-04-21 Thread STINNER Victor


Change by STINNER Victor :


--
components: +Library (Lib)
nosy: +corona10, shihai1991

___
Python tracker 

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



[issue42737] PEP 563: drop annotations for complex assign targets

2021-04-21 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

> Batuhan, can you summarize the argument from the thread? What do you think 
> yourself? Myself, I'm not sure either way, but it seems okay to remove the 
> remnant bytecode.

I feel like we shouldn't generate code for these annotations at all, and only 
evaluate the targets. Since this is one of the things that blocks us right now 
regarding the bugfix of different issues (e.g annotations have side effects on 
symbol table).

Even though the PEP 563 being default change is reverted, I think we should 
move forward with this change but only do it under the future_annotations flag. 
@gvanrossum @pablogsal what do you think about this?

--

___
Python tracker 

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



[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Guido van Rossum


Guido van Rossum  added the comment:

Sounds like a plan, I agree that the original design misfired here (we were 
probably worried about million-line code bases with tens of thousands of 
classes having to pay the price of tens of thousands of empty dicts, but I now 
think that was an unnecessary worry -- that should be a few megabytes on a very 
much larger total).

But given that you're not done yet:

- Is it possible to create __annotations__ lazily? (IIRC in January we came to 
a conclusion about this, something like yes for modules but for classes, or the 
other way around?)

- Why would __annotations__ ever be None? Why do you allow setting it to None? 
Do we know of people ever write '__annotations__ = None' in their class or 
write 'cls.__annotations__ = None'?

- And where's your PR?

--

___
Python tracker 

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



[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy: +gvanrossum

___
Python tracker 

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



[issue43904] Documentation for argparse, missed opportunity

2021-04-21 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

It's a cute suggestion but I think it would be a distraction that makes the 
docs slightly worse.  The example "works" because the eye has to search to see 
what makes the text special, the indentation.  If you add a second special but 
irrelevant text feature, it makes it less likely that the first will succeed.

Thanks for the cute and entertaining submission, but I'll decline because 
clarity comes first.

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

___
Python tracker 

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



[issue43908] array.array should remain immutable

2021-04-21 Thread Guido van Rossum


Change by Guido van Rossum :


--
nosy: +Mark.Shannon

___
Python tracker 

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



[issue43908] array.array should remain immutable

2021-04-21 Thread Guido van Rossum


New submission from Guido van Rossum :

Hi Victor,

Sorry for making this a deferred blocker. I recall that we had a brief 
discussion somewhere about an accidental change to the array.array type -- this 
is now a heap type (Py_TPFLAGS_HEAPTYPE is set), and as a consequence it is no 
longer immutable.

In 3.9 this is an error:

>>> import array
>>> array.array.foo = 1
Traceback (most recent call last):
  File "", line 1, in 
TypeError: can't set attributes of built-in/extension type 'array.array'
>>>

But in 3.10a7 it passes:

>>> array.array.foo = 1
>>> array.array.foo
1
>>>

I would like this type (and other types that have been or will be converted to 
heap types) to remain immutable. How can we do that? I think we may need a new 
flag bit meaning "built-in type, immutable". This bit should not be inherited 
of course.

What do you think? (Feel free to close if this is a duplicate -- I couldn't 
find where we discussed this previously, sorry.)

--
assignee: vstinner
messages: 391540
nosy: gvanrossum, vstinner
priority: deferred blocker
severity: normal
status: open
title: array.array should remain immutable
type: behavior
versions: Python 3.10, Python 3.11

___
Python tracker 

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



[issue43902] ssl module: add getter for SSL_CTX* and SSL*

2021-04-21 Thread Steve Dower


Steve Dower  added the comment:

There's a working POC out there for modifying tuple elements that relies on the 
fact that id() returns real memory addresses, so I don't see it as a harmless 
thing. Also, Rust is only worrying about code that's put into its compiler, 
whereas Python has to worry about any code that might be injected into a 
running process, which is vastly easier than in Rust. The situations don't 
really compare.

It's also part of defense-in-depth. If there's no good reason to make it 
trivial for people to locate TLS-specific data structures in memory, why make 
it trivial? It's probably still possible (turns out everything is...), but it's 
worth raising the complexity and lowering the reliability by making someone 
jump through crazy hoops to get it.

> The second issue seems like the big blocker. Your example does 
> `ctypes.CDLL("libssl.so.1.1")`, but there's no guarantee that this will find 
> the same libssl that the `ssl` module is linked against.

On Windows, it's spelled "libssl-1_1", but it *is* guaranteed to load the right 
one. However, I'd rather encode this information somewhere inside _ssl than 
making it a guarantee (as presumably OpenSSL 3.0 will change this name 
structure).

Also, this is not the same as ssl._ssl.__file__. So yeah, this aspect is not 
very portable, which is why I'd rather it just be exposed as a "call OpenSSL 
function on this context by name".

> I don't want to import ctypes from the ssl module code.

Import it in the function when it's called, then. Reimports are so close to 
free they're basically irrelevant, and if your tight inner loop includes TLS 
then it's not actually a tight inner loop, so looking in sys.modules isn't 
going to hurt anyone.

I would definitely push back on importing it eagerly in ssl.py :)

--

___
Python tracker 

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



[issue42422] types.CodeType() has no bytecode verifier

2021-04-21 Thread Sofian Brabez


Sofian Brabez  added the comment:

Thanks Victor, it's clear now.

About the updates of the crashers, I sent the updated patches to update them in 
PR [3] before the following issue [1] and PR [2] but the other seems to have 
been merged already. 

It seems my submission was totally forgot and now obsolete. So I'm gonna close 
this ticket.

[1] https://bugs.python.org/issue42734
[2] https://github.com/python/cpython/pull/23939
[3] https://github.com/python/cpython/pull/23448

--

___
Python tracker 

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



[issue43907] pickle.py bytearray memoization bug with protocol 5

2021-04-21 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +pitrou

___
Python tracker 

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



[issue43907] pickle.py bytearray memoization bug with protocol 5

2021-04-21 Thread Carl Friedrich Bolz-Tereick


Change by Carl Friedrich Bolz-Tereick :


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

___
Python tracker 

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



[issue43907] pickle.py bytearray memoization bug with protocol 5

2021-04-21 Thread Carl Friedrich Bolz-Tereick


New submission from Carl Friedrich Bolz-Tereick :

The new codepath for the BYTEARRAY8 bytecode is missing memoization:

>>> import pickletools, pickle
>>> b = (bytearray(b"abc"), ) * 2
>>> b1, b2 = pickle.loads(pickle.dumps(b, 5)) # C version
>>> b1 is b2
True
(bytearray(b'abc'), bytearray(b'abc'))
>>> b1, b2 = pickle.loads(pickle._dumps(b, 5)) # python version
>>> b1 is b2 # :-(
False

Found it because PyPy is using pickle.py with no C implementation. I'm 
preparing a patch.

--
messages: 391537
nosy: Carl.Friedrich.Bolz
priority: normal
severity: normal
status: open
title: pickle.py bytearray memoization bug with protocol 5

___
Python tracker 

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



[issue43902] ssl module: add getter for SSL_CTX* and SSL*

2021-04-21 Thread Nathaniel Smith


Nathaniel Smith  added the comment:

Python's 'id' function exposes raw memory addresses constantly. As long as 
they're just integers, they can't do much harm.

(In Rust, taking a pointer to a random object is considered totally safe, can 
be done anywhere. It's *dereferencing* a pointer where you need special 
'unsafe' annotations.)

Addresses can potentially reveal ASLR slides or heap layout to an attacker, but 
I think the marginal risk here is pretty low. You'd need a situation where 
someone is like, tricking your program into calling ctx._ssl_ctx_addr() and 
then sending the result to the attacker? Seems unlikely, and not something 
anyone worries about with 'id'.

--

___
Python tracker 

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



[issue43902] ssl module: add getter for SSL_CTX* and SSL*

2021-04-21 Thread Christian Heimes


Christian Heimes  added the comment:

Funny, I was looking into the same issue with CDLL(). :)

The trick with ssl._ssl.__file__ may even break if users change 
sys.setdlopenflag() from RTLD_GLOBAL to RTLD_LOCAL. Static linking will also 
influence which symbols are available.

Python/dynload_shlib.c keeps a list of dlopen handles around, but there is no 
way to access the list of handles. Mmh ... tricky.

--

___
Python tracker 

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



[issue43902] ssl module: add getter for SSL_CTX* and SSL*

2021-04-21 Thread Christian Heimes


Christian Heimes  added the comment:

I don't want to import ctypes from the ssl module code.

PyCapsule could be a solution for the problem. Users would have to call 
PyCapsule_Import("_ssl.capsule") and PyCapsule_GetPointer() to access a struct 
with additional methods. It's a bit more work to implement and slightly harder 
to use, but safer than exposing raw memory addresses.

--

___
Python tracker 

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



[issue43902] ssl module: add getter for SSL_CTX* and SSL*

2021-04-21 Thread Nathaniel Smith


Nathaniel Smith  added the comment:

Funny, I was actually looking at this a bit last week, because I was trying to 
figure out if I could trick `ssl` into doing DTLS...

The two big problems I ran into are:

- for DTLS you need to instantiate the SSLContext with PROTOCOL_DTLS, and idk 
how you create a Python ssl._SSLMethod object for a random pointer.

- You need to somehow find the libssl symbols, and it's not clear how to do 
that in a safe and portable way.

The second issue seems like the big blocker. Your example does 
`ctypes.CDLL("libssl.so.1.1")`, but there's no guarantee that this will find 
the same libssl that the `ssl` module is linked against. (And if you get the 
wrong one then everything will probably explode.)

And like you say, `ctypes.CDLL(ssl._ssl.__file__)` also works, by taking 
advantage of how ELF shared libraries tend to reexport all the symbols they 
import, but... this is an ELF-specific thing. It doesn't work on Windows or 
macOS.

So to me the first question would be: is it possible to offer a utility 
function that reliably gives users a handle to the right libssl, on all systems 
and build configurations? If not then I don't see how this could work.

--

___
Python tracker 

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



[issue43906] turtle graphics don't work

2021-04-21 Thread Eric V. Smith


Change by Eric V. Smith :


--
status: open -> closed

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Ethan Furman


Change by Ethan Furman :


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

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset a02cb474f9c097c83cd444a47e9fb5f99b4aaf45 by Ethan Furman in 
branch 'master':
bpo-38659: [Enum] add _simple_enum decorator (GH-25497)
https://github.com/python/cpython/commit/a02cb474f9c097c83cd444a47e9fb5f99b4aaf45


--

___
Python tracker 

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



[issue40642] Cpython "pystate.h" subdirectory wrong

2021-04-21 Thread Xi Ruoyao


Xi Ruoyao  added the comment:

Dup of #39026.  And the proposed fix is nack'ed in #39026.

--

___
Python tracker 

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



[issue43906] turtle graphics don't work

2021-04-21 Thread Steven D'Aprano


New submission from Steven D'Aprano :

You have a bug in your code.

This is a bug tracker for bugs in Python, not a help desk for solving errors in 
your own code. In this case, the problem is that you have created a file called 
"turtle.py" which is shadowing the original turtle module. Rename your file and 
try again.

If you still have problems, please don't create bug reports here. Please 
discuss them at any of the many forums where you can get help, such as Reddit's 
r/learnpython, the Python mailing lists, or the Python Discuss. Thank you.

Also, in future please don't post screen shots of error messages. They are 
text: please copy and paste the text into your bug report. Thank you.

--
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
type: compile error -> behavior

___
Python tracker 

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



[issue43902] ssl module: add getter for SSL_CTX* and SSL*

2021-04-21 Thread Steve Dower


Steve Dower  added the comment:

Could we have the address exposed in a way that can only be passed back into 
ctypes? Or alternatively, doesn't function if ctypes is missing?

I don't like offering ways to get real memory addresses, especially for 
interesting objects. At the same time, I see the value of it being available 
raw for CFFI and other tools that can use it.

Maybe it would be better to expose it as 
ctx._call_with_ctypes("SSL_CTX_set_ciphersuites", 
b"TLS_CHACHA20_POLY1305_SHA256")? That also leaves the opportunity to 
special-case certain functions in the future.

--

___
Python tracker 

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



[issue43906] turtle graphics don't work

2021-04-21 Thread кофеёк

Change by кофеёк :


--
components: Build
files: Screenshot_16.png
nosy: antiendershow221
priority: normal
severity: normal
status: open
title: turtle graphics don't work
type: compile error
versions: Python 3.8
Added file: https://bugs.python.org/file49969/Screenshot_16.png

___
Python tracker 

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



[issue43284] sys.getwindowsversion().platform_version is incorrect

2021-04-21 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

PR opened against master branch.

--

___
Python tracker 

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



[issue43284] sys.getwindowsversion().platform_version is incorrect

2021-04-21 Thread Shreyan Avigyan


Change by Shreyan Avigyan :


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

___
Python tracker 

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



[issue30069] External library behave differently when loaded by Python (maybe thread issue)

2021-04-21 Thread Irit Katriel


Irit Katriel  added the comment:

I'm closing this as out of date because the links no longer work and both 
Python 2.7/3.6 are no longer maintained. If you are still having this problem 
with more recent versions of Python, please create a new issue with up-to-date 
reproduction information.

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

___
Python tracker 

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



[issue41701] Buildbot web page: connection lost after 1 minute, then display "Connection restored" popup

2021-04-21 Thread STINNER Victor


STINNER Victor  added the comment:

> Can someone confirm if they still have this problem on the buildbot server?

Oh wow, I don't have the issue anymore! Thank you very much :-) Previously, the 
website was barely usable :-(

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



[issue43817] Add inspect.get_annotations()

2021-04-21 Thread Eric V. Smith


Eric V. Smith  added the comment:

> And since there are definitely circumstances in which it can't return 
> __annotations__ directly, that indicates that it should never return 
> __annotations__ directly.

And the follow on here is that get_annotations() shouldn't set __annotations__ 
if it's None. I realize I'm just stating the obvious.

--

___
Python tracker 

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



[issue41701] Buildbot web page: connection lost after 1 minute, then display "Connection restored" popup

2021-04-21 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Can someone confirm if they still have this problem on the buildbot server?

--

___
Python tracker 

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



[issue43859] Improve syntax error for indentation errors

2021-04-21 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue43859] Improve syntax error for indentation errors

2021-04-21 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 56c95dfe271b1242bdc8163d4677e311552c00cb by Pablo Galindo in 
branch 'master':
bpo-43859: Improve the error message for IndentationError exceptions (GH-25431)
https://github.com/python/cpython/commit/56c95dfe271b1242bdc8163d4677e311552c00cb


--

___
Python tracker 

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



[issue40222] "Zero cost" exception handling

2021-04-21 Thread Guido van Rossum

Guido van Rossum  added the comment:

I like Serhiy’s idea.

BTW, what are the three POP_TOP op codes in a row popping?

--
nosy: +Guido.van.Rossum

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Ethan Furman


Change by Ethan Furman :


--
pull_requests: +24219
pull_request: https://github.com/python/cpython/pull/25497

___
Python tracker 

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



[issue38659] enum classes cause slow startup time

2021-04-21 Thread Ethan Furman


Change by Ethan Furman :


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



[issue42854] OpenSSL 1.1.1: use SSL_write_ex() and SSL_read_ex()

2021-04-21 Thread Ethan Furman


Ethan Furman  added the comment:

False alarm, sorry.  Still getting used to merging, rebasing, etc.

Current tests run fine.

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

___
Python tracker 

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



[issue42854] OpenSSL 1.1.1: use SSL_write_ex() and SSL_read_ex()

2021-04-21 Thread Ethan Furman


Change by Ethan Furman :


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

___
Python tracker 

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



[issue43905] dataclasses.astuple does deepcopy on all fields

2021-04-21 Thread Eric V. Smith


Eric V. Smith  added the comment:

The reason for the deep copying was to support changing a hierarchy of 
dataclasses into something that could be JSON serialized. But it didn't really 
work out. It recurses into dataclasses, namedtuples, lists, tuples, and dicts, 
and deep copies everything else.

As I said, it's a design flaw.

--

___
Python tracker 

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



[issue43905] dataclasses.astuple does deepcopy on all fields

2021-04-21 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Why deepcopy is used at all? It is a very specific feature which should not be 
used by default. If you want to make a deep copy of fields, you can call 
copy.deepcopy() explicitly.

copy.deepcopy(dataclasses.astuple(obj))

or

dataclasses.astuple(copy.deepcopy(obj))

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue43905] dataclasses.astuple does deepcopy on all fields

2021-04-21 Thread Eric V. Smith


Eric V. Smith  added the comment:

Unfortunately this can't be changed, although I suppose it should be documented.

In general I think this API was a mistake, and should not have been added. 
There are just too many cases where it doesn't do what you want, or where it 
fails.

I'd like to deprecate it and remove it (along with asdict), but I fear that 
would be too disruptive.

Your approach seems reasonable to me for your use case.

--
assignee:  -> eric.smith
nosy: +eric.smith

___
Python tracker 

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



[issue43904] Documentation for argparse, missed opportunity

2021-04-21 Thread Eric V. Smith


Eric V. Smith  added the comment:

If we're trying to be poetic, I think the last line should be "I intended it".

--
nosy: +eric.smith

___
Python tracker 

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



[issue43905] dataclasses.astuple does deepcopy on all fields

2021-04-21 Thread Erik Carstensen


New submission from Erik Carstensen :

It seems that the 'dataclass.astuple' function does a deepcopy of all fields. 
This is not documented. Two problems:

1. Dictionary keys that rely on object identity are ruined:
import dataclasses
@dataclasses.dataclass
class Foo:
key: object
key = object()
lut = {key: 5}
(y,) = dataclasses.astuple(Foo(x))
# KeyError
lut[y]

2. dataclasses can only be converted to a tuple if all fields are serializable:

import dataclasses
@dataclasses.dataclass
class Foo:
f: object
foo = Foo(open('test.py'))
dataclasses.astuple(foo)

->

TypeError: cannot pickle '_io.TextIOWrapper' object


In my use case, I just want a list of all fields. I can do the following as a 
workaround:
  (getattr(foo, field.name) for field in dataclasses.fields(foo))

Tested on Python 3.8.7 and 3.7.9.

--
components: Library (Lib)
messages: 391516
nosy: mandolaerik
priority: normal
severity: normal
status: open
title: dataclasses.astuple does deepcopy on all fields
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



[issue38605] [typing] PEP 563: Postponed evaluation of annotations: enable it by default in Python 3.11

2021-04-21 Thread STINNER Victor


STINNER Victor  added the comment:

> New changeset b0544ba77cf86074fb1adde00558c67ca75eeea1 by Pablo Galindo in 
> branch 'master':

Copy of the NEWS entry:

Revert making ``from __future__ import annotations`` the default. This follows
the Steering Council decision to postpone PEP 563 changes to at least Python
3.11. See the original email for more information regarding the decision:
https://mail.python.org/archives/list/python-...@python.org/thread/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/.
Patch by Pablo Galindo.

--

___
Python tracker 

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



  1   2   >