[issue31242] Add SSLContext.set_verify_callback()

2022-02-17 Thread Adrian Freund


Change by Adrian Freund :


--
nosy: +freundTech

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



[issue31242] Add SSLContext.set_verify_callback()

2022-02-17 Thread Adrian Freund


Change by Adrian Freund :


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

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



[issue46779] Add ssl.CERT_REQUIRED_NO_VERIFY as possible value for ssl.SSLContext.verify_mode

2022-02-17 Thread Adrian Freund


New submission from Adrian Freund :

Some networked applications might require connecting to client with invalid 
certificates but still requiring the client to send a certificate.

ssl.SSLContext.verify_mode currently supports the following options:
ssl.CERT_NONE: Don't require the client to send a certificate and don't 
validate it if they send one anyways.
ssl.CERT_OPTIONAL: Don't require the client to send a certificate but validate 
it if they send one.
ssl.CERT_REQUIRED: Require the client to send a certificate and validate it.

There is currently no option for servers that want to require the client to 
send a certificate but don't validate it.

This would for example be needed it a server should accept clients with 
self-signed certificates and then store their certificates to recognize them 
again later.

A concrete example is the KDEConnect protocol.

An alternative solution would be bpo-31242. That would also solve this problem 
is a more general, but also more complicated way.

I think that the solution proposed here this issue is better for it's 
simplicity and also solves most usecases for bpo-31242.


Note that a ssl.CERT_REQUIRED_NO_VERIFY was already proposed in bpo-18293, but 
that issue was closed because it was specifically in relation to a deprecated 
api. The mentioned values are however also used in modern asyncio apis.

--
assignee: christian.heimes
components: SSL
messages: 413416
nosy: christian.heimes, freundTech
priority: normal
severity: normal
status: open
title: Add ssl.CERT_REQUIRED_NO_VERIFY as possible value for 
ssl.SSLContext.verify_mode
type: enhancement
versions: Python 3.11

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



[issue31242] Add SSLContext.set_verify_callback()

2022-02-17 Thread Adrian Freund


Adrian Freund  added the comment:

I also need this feature for something I'm working on, so I looked into it a 
bit and pushed a small proof of concept implementation to GitHub (See PR 31391).

I'm not sure if I'll have enough time to finish and clean up this 
implementation, but at least there is a starting point.

I also opened bpo-46779 as a simpler method to solve most of the usecases  that 
would be solved by this api.

--
versions: +Python 3.11 -Python 3.8

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



[issue42128] Structural Pattern Matching (PEP 634)

2021-03-12 Thread Adrian Freund


Adrian Freund  added the comment:

For the last few days I've been working with pattern matching and it's ast for 
a bit, while trying to add support for it to mypy.

During this I noticed an inconsistency in the ast:

ast.MatchAs has an attribute name which is of type identifier (in C) and type 
str (in python).

This seams really inconsistent with the rest of the ast, where identifiers are 
always wrapped in a ast.Name object. The only other exception to this is 
ast.Attribute.

Judging from Grammar/python.gram this seems deliberate:

as_pattern[expr_ty]:
| pattern=or_pattern 'as' target=capture_pattern {
_Py_MatchAs(pattern, target->v.Name.id, EXTRA) }

Could someone shed some light on why MatchAs directly references an identifier 
instead of an ast.Name?

--
nosy: +freundTech

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



[issue42128] Structural Pattern Matching (PEP 634)

2021-03-12 Thread Adrian Freund


Adrian Freund  added the comment:

Thanks for the response. Looks like I overlooked the imports, global, nonlocal, 
... because I only searched for usages of identifier, but they use lists of 
identifiers.

In that case I agree that it isn't inconsistent.

--

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-07 Thread Adrian Freund


New submission from Adrian Freund :

PEP 634 structural pattern matching adds an auto-generated __match_args__ 
attribute to classes with the dataclass decorator and to namedtuples.

This change is currently not documented in the dataclass and namedtuple 
documentation, nor is it mentioned in PEP 557 Data Classes.


I would suggest adding mentions of this behaviour in those three places.

Additionally I think adding a new parameter to switch off generating 
__match_args__ to dataclass should be considered, as everything else generated 
by dataclass can be switched off using a parameter.

--
assignee: docs@python
components: Documentation
messages: 390413
nosy: brandtbucher, docs@python, freundTech, gvanrossum
priority: normal
severity: normal
status: open
title: Documenting dataclass and namedtuple changes for structural pattern 
matching
versions: Python 3.10

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



[issue43764] Turning off generation of __match_args__ for dataclasses

2021-04-07 Thread Adrian Freund


New submission from Adrian Freund :

The dataclass decorator can take multiple parameters to enable or disable the 
generation of certain methods.

PEP 634 Structural Pattern Matching extends dataclasses to also generate a 
__match_args__ attribute.

I think adding a parameter to enable and disable generation of __match_args__ 
should be to dataclass should also be considered for consistency.

Note that setting compare=False on a dataclass.field already excludes that 
field from __match_args__, but there is no way to disable generation of 
__match_args__ completely.

--
components: Library (Lib)
messages: 390429
nosy: brandtbucher, eric.smith, freundTech, gvanrossum
priority: normal
severity: normal
status: open
title: Turning off generation of __match_args__ for dataclasses
versions: Python 3.10

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-07 Thread Adrian Freund


Adrian Freund  added the comment:

Ok. I created https://bugs.python.org/issue43764 for that.

--

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



[issue43764] Turning off generation of __match_args__ for dataclasses

2021-04-09 Thread Adrian Freund


Adrian Freund  added the comment:

> I assume the OP wants to have a class that doesn't allow positional patterns. 
> The right way to spell that is indeed to add
>
>__match_args__ = ()
>
>to the class, there's no need to add another flag to @dataclass.

The same however is also true for all the other stuff generated by @dataclass. 
You can for example disable generation of the init method using

def __init__(self): pass

and dataclass still has a parameter to disable it.

I agree that a new parameter isn't strictly required to achieve functionality, 
however I would still argue that it should be added for consistency with the 
rest of the dataclass api.

--

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-09 Thread Adrian Freund


Adrian Freund  added the comment:

I agree that __match_args__ shouldn't have to be added to the documentation of 
any class that supports it, however dataclass and (maybe to a lesser extend) 
NamedTuple aren't themselves classes, but aid in creating own classes. Their 
effects on classes generated by them should be documented.
The documentation also mentions other fields/methods generated by dataclass and 
NamedTyple.

--

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



[issue43761] Documenting dataclass and namedtuple changes for structural pattern matching

2021-04-10 Thread Adrian Freund


Adrian Freund  added the comment:

I think for namedtuple a short mention in the opening paragraph, where it also 
mentions the generation of a docstring and __repr__ method should be enough.

--

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



[issue43892] Make match patterns explicit in the AST

2021-04-20 Thread Adrian Freund


Change by Adrian Freund :


--
nosy: +freundTech

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



[issue43994] change representation of match as / capture as `Name(..., ctx=Store())`

2021-04-30 Thread Adrian Freund


Adrian Freund  added the comment:

I already brought this up on the main pattern matching issue some time ago 
(https://bugs.python.org/issue42128#msg388554), where the consensus was that 
not using a Name is consistent with other parts of the ast, such as `import ... 
as identifier`, `except ... as identifier` and others.

For mypy having a Name node there would slightly simplify the code (I'm 
currently inserting a dummy NameExpr at AST-Conversion.

+0 from me.

--

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