<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 16, 2016 at 11:58 AM, Nathaniel Smith <span dir="ltr"><<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class=""><p dir="ltr">[...] no one else be able to predict what session cookie I sent [...] In python 2.3-3.5, the most correct way to write this code is to use os.urandom. The question in this thread is whether we should break that in 3.6, so that conscientious users are forced to switch existing code over to using the secrets module if they want to continue to get the most correct available behavior, or whether we should preserve that in 3.6, so that code like my hypothetical web app that was correct on 2.3-3.5 remains correct on 3.6 </p></span></blockquote><div>This is kinda silly.  Unless you specifically wrote your code for Python 3.5.1, and NOT for 2.3.x through 3.4.x, your code is NO WORSE in 3.5.2 than it has been under all those prior versions.  The cases where the behavior in everything other than 3.5.0-3.5.1 is suboptimal are *extremely limited*, as you understand (things that run in Python very early in the boot process, and only on recent versions of Linux, no other OS).  This does not even remotely describe the web-server-with-cookies example that you outline.</div><div><br></div><div>Python 3.6 is introducing a NEW MODULE, with new APIs.  The 'secrets' module is the very first time that Python has ever really explicitly addressed cryptography in the standard library.  Yes, there have been third-party modules and libraries, but any cryptographic application of Python prior to 'secrets' is very much roll-your-own and know-what-you-are-doing.</div><div><br></div><div>Yes, there has been a history of telling people to "use os.urandom()" on StackOverflow and places like that.  That's about the best advice that was available prior to 3.6.  Adding a new module and API is specifically designed to allow for a better answer, otherwise there'd be no reason to include it.  And that advice that's been on StackOverflow and wherever has been subject to the narrow, edge-case flaw we've discussed here for at least a decade without anyone noticing or caring.</div><div><br></div><div>It seems to me that backporting 'secrets' and putting it on Warehouse would be a lot more productive than complaining about 3.5.2 reverting to (almost) the behavior of 2.3-3.4.</div><div><br></div><div><br></div></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons.  Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div></div>