Re: [Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Antoine Pitrou
Le 07/11/2013 22:42, Christian Heimes a écrit : Am 07.11.2013 21:45, schrieb Antoine Pitrou: I'm in favour but I think 3.5 is too early. Keep in mind SSLContext is quite young. It's available since 3.3 3.2 actually, while many code bases are still 2.x-compatible. There's no need to make migr

Re: [Python-Dev] [Python-checkins] cpython: Issue #19512: Add PyRun_InteractiveOneObject() function

2013-11-07 Thread Eric Snow
On Thu, Nov 7, 2013 at 4:55 PM, Victor Stinner wrote: > About the 72523 functions PyRun_xxx(), I don't understand something. > The PyRun_FileEx() is documented in the Python "very high" C API to > use Python. But this function is not part of the stable ABI. So there > is no "very high" function in

Re: [Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Christian Heimes
Somehow your mail didn't end up on Python-dev Am 08.11.2013 00:38, schrieb Nick Coghlan: > In that case, it sounds like you need *two* new options rather than > one. "verify_hostname", with the None/True/False behaviour and a > separate postverify hook. Mmmh, yes, you are making an intriguing poi

Re: [Python-Dev] [Python-checkins] cpython: Issue #19512: Add PyRun_InteractiveOneObject() function

2013-11-07 Thread Victor Stinner
2013/11/8 Victor Stinner : > Another question: it's not documented if a function is part or not > part of the stable ABI. So as an user of the API, it is hard to check > if a function is part of the stable ABI or not. A solution for that it maybe to split the documentation of the C API in two part

Re: [Python-Dev] [Python-checkins] cpython: Issue #19512: Add PyRun_InteractiveOneObject() function

2013-11-07 Thread Victor Stinner
2013/11/8 Nick Coghlan : >> [PyRun_InteractiveOneObject()] >> (...) >> > Also, if they're part of the stable ABI, they need a version guard. >> >> As most PyRun_xxx() functions, the function is declared in a "#ifndef >> Py_LIMITED_API" block. It means that it is not part of the stable ABI, >> is th

Re: [Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Christian Heimes
Am 08.11.2013 00:09, schrieb Barry Warsaw: > I'm sure you're considering this, but I want to explicitly preserve the > ability to register self-signed certificates. It's often necessary in > practice, but very useful for testing purposes. > > ssl.SSLContext.load_cert_chain() is the way to do this

Re: [Python-Dev] [Python-checkins] cpython: Issue #19512: Add PyRun_InteractiveOneObject() function

2013-11-07 Thread Nick Coghlan
On 8 Nov 2013 09:45, "Victor Stinner" wrote: > > Hi, > > [PyRun_InteractiveOneObject()] > > 2013/11/8 Nick Coghlan : > > New C APIs should either be documented or have an underscore prefix. > > I created the issue #19518 to add documentation (but also to add even > more functions :-)). > > > Also,

Re: [Python-Dev] [Python-checkins] cpython: Issue #19512: Add a new _PyDict_DelItemId() function, similar to

2013-11-07 Thread Victor Stinner
2013/11/8 Nick Coghlan : >> http://hg.python.org/cpython/rev/69071054b42f >> changeset: 86968:69071054b42f >> user:Victor Stinner >> date:Wed Nov 06 18:58:22 2013 +0100 >> summary: >> Issue #19512: Add a new _PyDict_DelItemId() function, similar to >> PyDict_DelItemString() but

Re: [Python-Dev] [Python-checkins] cpython: Issue #19512: Add PyRun_InteractiveOneObject() function

2013-11-07 Thread Victor Stinner
Hi, [PyRun_InteractiveOneObject()] 2013/11/8 Nick Coghlan : > New C APIs should either be documented or have an underscore prefix. I created the issue #19518 to add documentation (but also to add even more functions :-)). > Also, if they're part of the stable ABI, they need a version guard. As

Re: [Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Christian Heimes
Am 07.11.2013 23:25, schrieb Nick Coghlan: > Change this to create_default_context() (to make it clearer there is no > global context object) and I'm generally +1. Good idea! > This overlaps confusingly with "verify_mode". Perhaps just offer a > module level "verify_hostname" API that adapts betw

Re: [Python-Dev] [Python-checkins] cpython: Issue #19512: Add a new _PyDict_DelItemId() function, similar to

2013-11-07 Thread Nick Coghlan
On 7 Nov 2013 04:06, "victor.stinner" wrote: > > http://hg.python.org/cpython/rev/69071054b42f > changeset: 86968:69071054b42f > user:Victor Stinner > date:Wed Nov 06 18:58:22 2013 +0100 > summary: > Issue #19512: Add a new _PyDict_DelItemId() function, similar to > PyDict_Del

Re: [Python-Dev] [Python-checkins] cpython: Issue #19512: Add PyRun_InteractiveOneObject() function

2013-11-07 Thread Nick Coghlan
New C APIs should either be documented or have an underscore prefix. Also, if they're part of the stable ABI, they need a version guard. Wishlist item: an automated ABI checker that can diff the exported symbols against a reference list (Could ctypes or cffi be used for that?) As long as this ki

Re: [Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Barry Warsaw
On Nov 07, 2013, at 10:42 PM, Christian Heimes wrote: >You misunderstood me. I'm not proposing a global SSLContext object but a >factory function that creates a context for Python stdlib modules. Right >now every urllib, http.client, nntplib, asyncio, ftplib, poplib and >imaplib have duplicated co

Re: [Python-Dev] [Python-checkins] cpython: Fix _Py_normalize_encoding(): ensure that buffer is big enough to store "utf-8"

2013-11-07 Thread Benjamin Peterson
2013/11/7 Victor Stinner : > Calling strlen() at runtime may slow-down a function in the fast-path > of PyUnicode_Decode() and PyUnicode_AsEncodedString() which are > important functions. I know that some developers can execute strlen() > during compilation, but I don't see the need of replacing 6

Re: [Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Nick Coghlan
On 8 Nov 2013 04:18, "Christian Heimes" wrote: > > Hi, > > I'd like to simplify, unify and tighten SSL handling and verification > code in Python 3.5. Therefore I propose to deprecate some features for > Python 3.4. SSLContext objects are going to be the central instance for > configuration. > > I

Re: [Python-Dev] [Python-checkins] cpython: Fix _Py_normalize_encoding(): ensure that buffer is big enough to store "utf-8"

2013-11-07 Thread Eric V. Smith
On 11/7/2013 5:13 PM, Victor Stinner wrote: > 2013/11/7 Eric V. Smith : >> Then how about at least a comment about how 6 is derived? >> >> if (lower_len < 6) /* 6 == strlen("utf-8") + 1 */ >> return 0; > > Ok, I added the comment in changeset 9c929b9e0a2a. Thanks! Eric.

Re: [Python-Dev] [Python-checkins] cpython: Fix _Py_normalize_encoding(): ensure that buffer is big enough to store "utf-8"

2013-11-07 Thread Victor Stinner
2013/11/7 Eric V. Smith : > Then how about at least a comment about how 6 is derived? > > if (lower_len < 6) /* 6 == strlen("utf-8") + 1 */ > return 0; Ok, I added the comment in changeset 9c929b9e0a2a. Victor ___ Python-Dev mail

Re: [Python-Dev] Avoid formatting an error message on attribute error

2013-11-07 Thread Nick Coghlan
On 8 Nov 2013 04:44, "Brett Cannon" wrote: > On Thu, Nov 7, 2013 at 7:41 AM, Nick Coghlan wrote: >> >> The bigger problem is you can't change the constructor signature in a backwards incompatible way. You would need a new class method as an alternative constructor instead, or else use optional pa

Re: [Python-Dev] [Python-checkins] cpython: Fix _Py_normalize_encoding(): ensure that buffer is big enough to store "utf-8"

2013-11-07 Thread Eric V. Smith
On 11/7/2013 4:38 PM, Victor Stinner wrote: > 2013/11/7 Benjamin Peterson : >> 2013/11/7 victor.stinner : >>> http://hg.python.org/cpython/rev/99afa4c74436 >>> changeset: 86995:99afa4c74436 >>> user:Victor Stinner >>> date:Thu Nov 07 13:33:36 2013 +0100 >>> summary: >>> Fix _Py

Re: [Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Donald Stufft
On Nov 7, 2013, at 4:42 PM, Christian Heimes wrote: >>> >>> - deprecate implicit verify_mode=CERT_NONE. Python 3.5 will default >>> to CERT_REQUIRED. >> >> -0.9. This breaks compatibility and doesn't achieve anything, since >> there's no reliable story for CA certs. > > I'd like to move to

Re: [Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Christian Heimes
Am 07.11.2013 21:45, schrieb Antoine Pitrou: > I'm in favour but I think 3.5 is too early. Keep in mind SSLContext is > quite young. It's available since 3.3 >> - deprecate implicit verify_mode=CERT_NONE. Python 3.5 will default >>to CERT_REQUIRED. > > -0.9. This breaks compatibility and doe

Re: [Python-Dev] [Python-checkins] cpython: Fix _Py_normalize_encoding(): ensure that buffer is big enough to store "utf-8"

2013-11-07 Thread Victor Stinner
2013/11/7 Benjamin Peterson : > 2013/11/7 victor.stinner : >> http://hg.python.org/cpython/rev/99afa4c74436 >> changeset: 86995:99afa4c74436 >> user:Victor Stinner >> date:Thu Nov 07 13:33:36 2013 +0100 >> summary: >> Fix _Py_normalize_encoding(): ensure that buffer is big enou

Re: [Python-Dev] PEP 384 (stable api) question

2013-11-07 Thread Nick Coghlan
On 8 Nov 2013 04:42, Martin v. Löwis wrote: > > Am 07.11.13 13:44, schrieb Thomas Heller: > > > I thought that the stable API would keep exactly the same across > > releases - is this expectation wrong or is this a bug? > > Oscar is right - this change doesn't affect the ABI, just the API. > > Tha

Re: [Python-Dev] [Python-checkins] cpython: Fix _Py_normalize_encoding(): ensure that buffer is big enough to store "utf-8"

2013-11-07 Thread Benjamin Peterson
2013/11/7 victor.stinner : > http://hg.python.org/cpython/rev/99afa4c74436 > changeset: 86995:99afa4c74436 > user:Victor Stinner > date:Thu Nov 07 13:33:36 2013 +0100 > summary: > Fix _Py_normalize_encoding(): ensure that buffer is big enough to store > "utf-8" > if the input

Re: [Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Antoine Pitrou
Le 07/11/2013 19:13, Christian Heimes a écrit : Hi, I'd like to simplify, unify and tighten SSL handling and verification code in Python 3.5. Therefore I propose to deprecate some features for Python 3.4. SSLContext objects are going to be the central instance for configuration. In order to ar

Re: [Python-Dev] Avoid formatting an error message on attribute error

2013-11-07 Thread Brett Cannon
On Thu, Nov 7, 2013 at 2:20 PM, Eric Snow wrote: > On Thu, Nov 7, 2013 at 11:44 AM, Brett Cannon wrote: > > Lazy message creation through > > __str__ does leave the message out of `args`, though. > > If that's an issue you could make args a (settable) property that > dynmically returns str(self)

Re: [Python-Dev] Avoid formatting an error message on attribute error

2013-11-07 Thread Eric Snow
On Thu, Nov 7, 2013 at 11:44 AM, Brett Cannon wrote: > Lazy message creation through > __str__ does leave the message out of `args`, though. If that's an issue you could make args a (settable) property that dynmically returns str(self) if appropriate: @property def args(self): ac

Re: [Python-Dev] Avoid formatting an error message on attribute error

2013-11-07 Thread Brett Cannon
On Thu, Nov 7, 2013 at 7:41 AM, Nick Coghlan wrote: > > On 7 Nov 2013 21:34, "Victor Stinner" wrote: > > > > 2013/11/7 Steven D'Aprano : > > > My initial instinct here was to say that sounded like premature > > > optimization, but to my surprise the overhead of generating the error > > > message

Re: [Python-Dev] PEP 384 (stable api) question

2013-11-07 Thread Martin v. Löwis
Am 07.11.13 13:44, schrieb Thomas Heller: > I thought that the stable API would keep exactly the same across > releases - is this expectation wrong or is this a bug? Oscar is right - this change doesn't affect the ABI, just the API. That said, please file an issue reporting what change you see i

[Python-Dev] Simplify and unify SSL verification

2013-11-07 Thread Christian Heimes
Hi, I'd like to simplify, unify and tighten SSL handling and verification code in Python 3.5. Therefore I propose to deprecate some features for Python 3.4. SSLContext objects are going to be the central instance for configuration. In order to archive the goal I propose to - deprecate the key_fi

Re: [Python-Dev] PEP 384 (stable api) question

2013-11-07 Thread Oscar Benjamin
On 7 November 2013 12:44, Thomas Heller wrote: > PEP 384 describes the stable Python api, available when > Py_LIMITED_API is defined. > > However, there are some (small) changes in the function prototypes > available, one example is (in Python 3.3): > PyObject* PyObject_CallFunction(PyObject *cal

[Python-Dev] PEP 384 (stable api) question

2013-11-07 Thread Thomas Heller
PEP 384 describes the stable Python api, available when Py_LIMITED_API is defined. However, there are some (small) changes in the function prototypes available, one example is (in Python 3.3): PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...) which changed in Python 3.4 to

Re: [Python-Dev] Avoid formatting an error message on attribute error

2013-11-07 Thread Nick Coghlan
On 7 Nov 2013 21:34, "Victor Stinner" wrote: > > 2013/11/7 Steven D'Aprano : > > My initial instinct here was to say that sounded like premature > > optimization, but to my surprise the overhead of generating the error > > message is actually significant -- at least from pure Python 3.3 code. > >

Re: [Python-Dev] Issue 19332: Guard against changing dict during iteration

2013-11-07 Thread Nick Coghlan
On 7 Nov 2013 03:18, "Antoine Pitrou" wrote: > > Le 06/11/2013 06:41, Nick Coghlan a écrit : > >> >> The behaviour of mutating builtin containers while iterating over them >> is formally undefined beyond "it won't segfault" (one of the few such >> undefined behaviours in Python). The associated ex

Re: [Python-Dev] Avoid formatting an error message on attribute error

2013-11-07 Thread Serhiy Storchaka
07.11.13 00:32, Victor Stinner написав(ла): I'm trying to avoid unnecessary temporary Unicode strings when possible (see issue #19512). While working on this, I saw that Python likes preparing an user friendly message to explain why getting an attribute failed. The problem is that in most cases,

Re: [Python-Dev] Avoid formatting an error message on attribute error

2013-11-07 Thread Victor Stinner
2013/11/7 Steven D'Aprano : > My initial instinct here was to say that sounded like premature > optimization, but to my surprise the overhead of generating the error > message is actually significant -- at least from pure Python 3.3 code. I ran a quick and dirty benchmark by replacing the error me