<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Oct 9, 2018 at 7:49 PM Chris Jerdonek <<a href="mailto:chris.jerdonek@gmail.com">chris.jerdonek@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Oct 9, 2018 at 7:13 PM Benjamin Peterson <<a href="mailto:benjamin@python.org" target="_blank">benjamin@python.org</a>> wrote:<br>
> On Tue, Oct 9, 2018, at 17:14, Barry Warsaw wrote:<br>
> > On Oct 9, 2018, at 16:21, Steven D'Aprano <<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>> wrote:<br>
> > ><br>
> > > On Tue, Oct 09, 2018 at 10:26:50AM -0700, Guido van Rossum wrote:<br>
> > >> My feeling is that limiting it to strings is fine, but checking those<br>
> > >> strings for resembling identifiers is pointless and wasteful.<br>
> > ><br>
> > > Sure. The question is, do we have to support uses where people<br>
> > > intentionally smuggle non-identifier strings as keys via **kwargs?<br>
> ><br>
> > I would not be in favor of that.  I think it doesn’t make sense to be<br>
> > able to smuggle those in via **kwargs when it’s not supported by<br>
> > Python’s grammar/syntax.<br>
><br>
> Can anyone think of a situation where it would be advantageous for an implementation to reject non-identifier string kwargs? I can't.<br>
<br>
One possibility is that it could foreclose certain security bugs from<br>
happening. For example, if someone has an API that accepts **kwargs,<br>
they might have the mistaken assumption that the keys are identifiers<br>
without special characters like ";" etc, and so they could make the<br>
mistake of thinking they don't need to escape / sanitize them.<br></blockquote><div><br></div><div>Hm, that's not an entirely unreasonable concern. How would an attacker get such keys *into* the dict? One possible scenario would be something that parses a traditional web query string into a dict, passes it down through **kwds, and then turns it back into another query string without proper quoting. But the most common (and easiest) way to turn a dict into a query string is calling urlencode(), which quotes unsafe characters.</div><div><br></div><div>I think we needn't rush this (and when in doubt, status quo wins, esp. when there's no BDFL :-).<br></div></div><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div></div>