Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Ronald Oussoren
On 16 Jul, 2013, at 14:02, Thomas Wouters wrote: > On Tue, Jul 16, 2013 at 1:40 PM, Nick Coghlan wrote: > >> PEP 8 advises developers to use absolute imports rather than explicit >> relative imports. >> >> Why? Using absolute imports couple the internal implementation of a >> package to its p

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Stephen J. Turnbull
Terry Reedy writes: > On 7/15/2013 10:20 PM, Guido van Rossum wrote: > > >> Or is this something deeper, that a group *is* a new object in > >> principle? > > > > No, I just think of it as returning "a string" > > That is exactly what the doc says it does. See my other post. The problem

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Guido van Rossum
If sounds like the main problem with relative imports (even explicit) is caused by ignoring the package structure and running modules inside a package as a script, without using -m. Maybe we should update the PEP to make this abundantly clear? I note that an additional problem with informational

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Nick Coghlan
On 17 July 2013 11:55, Steven D'Aprano wrote: > On 16/07/13 22:02, Thomas Wouters wrote: > As I see it, if relative imports are a bad idea for the std lib, they're a > bad idea for everyone. (What am I missing?) So why do we have relative > imports? Was it a mistake? I don't think so. > > It seems

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Guido van Rossum
I have to say that a long time ago, when you couldn't tell a relative import from a top-level import, the ban on relative imports made more sense. -- --Guido van Rossum (python.org/~guido) ___ Python-Dev mailing list Python-Dev@python.org http://mail.py

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Steven D'Aprano
On 16/07/13 22:02, Thomas Wouters wrote: On Tue, Jul 16, 2013 at 1:40 PM, Nick Coghlan wrote: PEP 8 advises developers to use absolute imports rather than explicit relative imports. Why? Using absolute imports couple the internal implementation of a package to its public name - you can't just

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 On Jul 16, 2013, at 07:34 PM, Tres Seaver wrote: >On 07/16/2013 07:09 AM, Nick Coghlan wrote: > >> I did find it interesting that we *don't* explicitly advise against >> the use of "import *" for anything other than optional accelerator >> modules

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/16/2013 07:09 AM, Nick Coghlan wrote: > I did find it interesting that we *don't* explicitly advise against > the use of "import *" for anything other than optional accelerator > modules or republishing internal interfaces through a public API

Re: [Python-Dev] Is it safe to call PyEval_EvalFrameEx() with an exception set?

2013-07-16 Thread Victor Stinner
2013/7/16 Victor Stinner : > I would like to add assertions in Python/ceval.c to detect such bugs > earlier. The problem is that some functions rely on the ability to > call PyEval_EvalFrameEx() with an exception set. Is it expected? > Should it be avoided? The current exception can be replaced wit

Re: [Python-Dev] cpython: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure

2013-07-16 Thread Victor Stinner
2013/7/17 Serhiy Storchaka : > Oh, I meaned Py_XDECREF. Ah ok :-) Well, for this specific code, it can probably be replaced with: if (_PyBytes_Resize(&bytes, n) < 0) return NULL; I'm not sure that _PyBytes_Resize() *always* decref bytes and then set bytes to NULL. I was too

Re: [Python-Dev] cpython: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure

2013-07-16 Thread Christian Heimes
Am 17.07.2013 00:03, schrieb Victor Stinner: > 2013/7/16 Serhiy Storchaka : >>> http://hg.python.org/cpython/rev/533eb9ab895a >>> summary: >>>Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure >>> >>> bytes is NULL on _PyBytes_Resize() failure >> >> Why not Py_DECREF? > > Because Py_

Re: [Python-Dev] cpython: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure

2013-07-16 Thread Serhiy Storchaka
17.07.13 01:03, Victor Stinner написав(ла): 2013/7/16 Serhiy Storchaka : http://hg.python.org/cpython/rev/533eb9ab895a summary: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure bytes is NULL on _PyBytes_Resize() failure Why not Py_DECREF? Because Py_DECREF(NULL) does crash.

Re: [Python-Dev] cpython: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure

2013-07-16 Thread Victor Stinner
2013/7/16 Serhiy Storchaka : >> http://hg.python.org/cpython/rev/533eb9ab895a >> summary: >>Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure >> >> bytes is NULL on _PyBytes_Resize() failure > > Why not Py_DECREF? Because Py_DECREF(NULL) does crash. Victor _

Re: [Python-Dev] cpython: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure

2013-07-16 Thread Serhiy Storchaka
17.07.13 00:09, victor.stinner написав(ла): http://hg.python.org/cpython/rev/533eb9ab895a changeset: 84669:533eb9ab895a user:Victor Stinner date:Tue Jul 16 21:36:02 2013 +0200 summary: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure bytes is NULL on _PyBytes_Re

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Terry Reedy
On 7/16/2013 9:39 AM, R. David Murray wrote: On Tue, 16 Jul 2013 23:19:21 +1000, Steven D'Aprano wrote: For example, pkgutil includes classes with single-underscore methods, which I take as private. It also has a function simplegeneric, which is undocumented and not listed in __all__. In in

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Terry Reedy
On 7/16/2013 7:40 AM, Nick Coghlan wrote: PEP 8 advises developers to use absolute imports rather than explicit relative imports. Why? Using absolute imports couple the internal implementation of a package to its public name - you can't just change the top level directory name any more, you have

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Guido van Rossum
On Tue, Jul 16, 2013 at 12:55 AM, Antoine Pitrou wrote: > Is there a strong enough use case to change it? I can't say the current > behaviour seems very useful either, but some people may depend on it. This is the crucial question. I personally see the current behavior as an artifact of the (lack

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Barry Warsaw
On Jul 16, 2013, at 04:10 PM, Nick Coghlan wrote: >Yeah, we should probably be a bit more vocal in pointing out that PEP >8 is something to be applied judiciously, *not* treated as "sacred >writ, never to be questioned". It's very tempting to just sigh and >ignore it, instead of explicitly pointin

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Barry Warsaw
On Jul 16, 2013, at 11:48 PM, Nick Coghlan wrote: >For the general case, the patch I posted to the issue tracker sets the >precedence as docs -> __all__ -> leading underscore. +1 -Barry ___ Python-Dev mailing list Python-Dev@python.org http://mail.pyth

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Barry Warsaw
On Jul 16, 2013, at 11:28 AM, Richard Oudkerk wrote: >BTW, how does the use of __all__ effect things? Somewhere I got the idea >that if a module uses __all__ then anything not listed is internal. I take >it that is wrong? Purely technically, __all__ is there to affect how from-import-* works.

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Barry Warsaw
On Jul 15, 2013, at 11:02 PM, Chris McDonough wrote: >Given that misunderstanding, is there a way to divorce stdlib-centric >guidelines like the one being discussed now from "PEP8"-ness? I don't >think any amount of marketing effort or reasoned explanation is going to >separate "PEP8" from "corre

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Barry Warsaw
On Jul 16, 2013, at 02:02 PM, Thomas Wouters wrote: >In my experience changing the name of a package is problematic for more >reasons than just 'import'. We used to do the put-in-a-package thing for >third-party packages at Google, and we quit doing it because it was just >too painful: it's hard t

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Nick Coghlan
On 16 July 2013 23:39, R. David Murray wrote: > On Tue, 16 Jul 2013 23:19:21 +1000, Steven D'Aprano > wrote: >> On 16/07/13 20:28, Richard Oudkerk wrote: >> > On 16/07/2013 6:44am, Nick Coghlan wrote: >> >> Clarifying what constitutes an internal interface in a way that >> >> doesn't require ren

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread R. David Murray
On Tue, 16 Jul 2013 23:19:21 +1000, Steven D'Aprano wrote: > On 16/07/13 20:28, Richard Oudkerk wrote: > > On 16/07/2013 6:44am, Nick Coghlan wrote: > >> Clarifying what constitutes an internal interface in a way that > >> doesn't require renaming anything is a necessary prerequisite for > >> bund

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Steven D'Aprano
On 16/07/13 20:28, Richard Oudkerk wrote: On 16/07/2013 6:44am, Nick Coghlan wrote: Clarifying what constitutes an internal interface in a way that doesn't require renaming anything is a necessary prerequisite for bundling or bootstrapping the pip CLI in Python 3.4 (as pip exposes its internal i

Re: [Python-Dev] Python 3.4 and Windows XP: just 45 days until EOL

2013-07-16 Thread Tim Golden
On 12/07/2013 00:58, Christian Heimes wrote: > Hi, > > how do you feel about dropping Windows XP support for Python 3.4? It > would enable us to use some features that are only available on Windows > Vista and newer, for example http://bugs.python.org/issue6926 and > http://bugs.python.org/issue17

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Nick Coghlan
On 16 July 2013 22:27, Nick Coghlan wrote: > These are good reasons, but they're not the reasons the PEP currently > gives. "Better failure modes" is a good practical benefit :) I have now included an updated rationale for this rule in the patch attached to http://bugs.python.org/issue18472 (the

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Nick Coghlan
On 16 July 2013 22:02, Thomas Wouters wrote: > On Tue, Jul 16, 2013 at 1:40 PM, Nick Coghlan wrote: >> >> PEP 8 advises developers to use absolute imports rather than explicit >> relative imports. >> >> Why? Using absolute imports couple the internal implementation of a >> package to its public n

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Nick Coghlan
On 16 July 2013 21:10, Nick Coghlan wrote: > On 16 July 2013 20:28, Richard Oudkerk wrote: >> On 16/07/2013 6:44am, Nick Coghlan wrote: >>> >>> Clarifying what constitutes an internal interface in a way that >>> doesn't require renaming anything is a necessary prerequisite for >>> bundling or boo

Re: [Python-Dev] Python 3.4 and Windows XP: just 45 days until EOL

2013-07-16 Thread Martin v. Löwis
Am 12.07.13 01:58, schrieb Christian Heimes: > For Python 3.4 is going to be a very close call. According to PEP 429 > 3.4.0 final is scheduled for February 22, 2014. The extended support > phase of Windows XP ends merely 45 days later on April 8, 2014. Do we > really have to restrict ourselves to

Re: [Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Thomas Wouters
On Tue, Jul 16, 2013 at 1:40 PM, Nick Coghlan wrote: > PEP 8 advises developers to use absolute imports rather than explicit > relative imports. > > Why? Using absolute imports couple the internal implementation of a > package to its public name - you can't just change the top level > directory n

[Python-Dev] Why does PEP 8 advise against explicit relative imports?

2013-07-16 Thread Nick Coghlan
PEP 8 advises developers to use absolute imports rather than explicit relative imports. Why? Using absolute imports couple the internal implementation of a package to its public name - you can't just change the top level directory name any more, you have to go through and change all the absolute i

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Nick Coghlan
On 16 July 2013 20:28, Richard Oudkerk wrote: > On 16/07/2013 6:44am, Nick Coghlan wrote: >> >> Clarifying what constitutes an internal interface in a way that >> doesn't require renaming anything is a necessary prerequisite for >> bundling or bootstrapping the pip CLI in Python 3.4 (as pip expose

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Nick Coghlan
On 16 July 2013 18:41, Terry Reedy wrote: > On 7/15/2013 11:11 PM, Nick Coghlan wrote: > >> I'll look into adding some stronger wording at the top making it clear >> that while PEP 8 is a useful starting point and a good default if a >> project doesn't have a defined style guide of it's own, it is

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Nick Coghlan
On 16 July 2013 19:18, Terry Reedy wrote: > I wonder if the change was an artifact of changing the code to prohibit > mixing Unicode and bytes. I'm pretty sure we the only thing we changed in 3.x is to migrate re to the PEP 3118 buffer API, and the behavioural change Guido is seeing is actually t

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Richard Oudkerk
On 16/07/2013 6:44am, Nick Coghlan wrote: Clarifying what constitutes an internal interface in a way that doesn't require renaming anything is a necessary prerequisite for bundling or bootstrapping the pip CLI in Python 3.4 (as pip exposes its internal implemetnation API as "import pip" rather th

Re: [Python-Dev] Is it safe to call PyEval_EvalFrameEx() with an exception set?

2013-07-16 Thread Victor Stinner
2013/7/16 Antoine Pitrou : > Le Tue, 16 Jul 2013 02:34:49 +0200, > Victor Stinner a écrit : >> I would like to add assertions in Python/ceval.c to detect such bugs >> earlier. The problem is that some functions rely on the ability to >> call PyEval_EvalFrameEx() with an exception set. Is it expect

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Terry Reedy
On 7/15/2013 10:20 PM, Guido van Rossum wrote: Or is this something deeper, that a group *is* a new object in principle? No, I just think of it as returning "a string" That is exactly what the doc says it does. See my other post. -- Terry Jan Reedy _

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Terry Reedy
On 7/15/2013 7:14 PM, Guido van Rossum wrote: In a discussion about mypy I discovered that the Python 3 version of the re module's Match object behaves subtly different from the Python 2 version when the target string (i.e. the haystack, not the needle) is a buffer object. In Python 2, the type

Re: [Python-Dev] Tweaking PEP 8 guidelines for use of leading underscores

2013-07-16 Thread Terry Reedy
On 7/15/2013 11:11 PM, Nick Coghlan wrote: I'll look into adding some stronger wording at the top making it clear that while PEP 8 is a useful starting point and a good default if a project doesn't have a defined style guide of it's own, it is *not* the be-all-and-end-all for Python style guides

Re: [Python-Dev] Is it safe to call PyEval_EvalFrameEx() with an exception set?

2013-07-16 Thread Antoine Pitrou
Le Tue, 16 Jul 2013 02:34:49 +0200, Victor Stinner a écrit : > Hi, > > I'm working on the issue #18408 (fix issues found by my pyfailmalloc > tool). To analyze some bugs, I have to add debug traces in various > functions to find which function returned NULL without setting an > error, or the oppo

Re: [Python-Dev] Misc re.match() complaint

2013-07-16 Thread Antoine Pitrou
Le Mon, 15 Jul 2013 21:53:42 -0700, Guido van Rossum a écrit : > Hm. I'd still like to change this, but I understand it's debatable... > Is the group() method written in C or Python? Is there a strong enough use case to change it? I can't say the current behaviour seems very useful either, but so