Re: [Python-Dev] Suggested addition to PEP 8 for context managers

2012-04-15 Thread Chris Angelico
On Mon, Apr 16, 2012 at 3:13 AM, Raymond Hettinger wrote: > Instead, the context manager implements a different behavior.  It would > have been better if that behavior had been given a name: > >    db = sqlite3.connect(filename) >    with auto_commit_or_rollback(db): >          # do a transaction

Re: [Python-Dev] making the import machinery explicit

2012-04-15 Thread Brett Cannon
On Sun, Apr 15, 2012 at 22:03, Nick Coghlan wrote: > On Mon, Apr 16, 2012 at 2:31 AM, Brett Cannon wrote: > > What about sys.path_importer_cache: all of it or just NullImporter/None > > entries (or should that be a boolean to this function)? And shouldn't it > be > > called reset_import() with t

Re: [Python-Dev] Providing a mechanism for PEP 3115 compliant dynamic class creation

2012-04-15 Thread Nick Coghlan
On Mon, Apr 16, 2012 at 5:34 AM, Daniel Urban wrote: > On Sun, Apr 15, 2012 at 13:48, Nick Coghlan wrote: >> /me pages thoughts from 12 months ago back into brain... > > Sorry about that, I planned to do this earlier... No worries - good to have someone following up on it, since it had completel

Re: [Python-Dev] making the import machinery explicit

2012-04-15 Thread Nick Coghlan
On Mon, Apr 16, 2012 at 2:31 AM, Brett Cannon wrote: > What about sys.path_importer_cache: all of it or just NullImporter/None > entries (or should that be a boolean to this function)? And shouldn't it be > called reset_import() with the level of changes you are proposing the > function make? Hmm

Re: [Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions

2012-04-15 Thread Victor Stinner
> time.perf_counter() > ^^^ > > Performance counter with the highest available precision to measure a > duration.  It does include time elapsed during sleep and is > system-wide.  The reference point of the returned value is undefined, > so that only the difference between the resul

Re: [Python-Dev] Require loaders set __package__ and __loader__

2012-04-15 Thread Glyph
On Apr 15, 2012, at 6:38 PM, Barry Warsaw wrote: > On Apr 15, 2012, at 02:12 PM, Glyph wrote: > >> Twisted has such a thing, mostly written by me, called >> twisted.python.modules. >> >> Sorry if I'm repeating myself here, I know I've brought it up on this list >> before, but it seems germane t

Re: [Python-Dev] Edit the rejected PEP 416 (frozendict) to mention the newly added types.MappingProxyType

2012-04-15 Thread Guido van Rossum
Go ahead and update the PEP! On Sunday, April 15, 2012, Victor Stinner wrote: > Hi, > > The frozendict (PEP 416) was rejected, but I just added the > types.MappingProxyType. This type is not new, it existed since Python > 2.2 as the internal dict_proxy type. See also the issue #14386. > > I would

Re: [Python-Dev] Require loaders set __package__ and __loader__

2012-04-15 Thread Barry Warsaw
On Apr 15, 2012, at 02:12 PM, Glyph wrote: >Twisted has such a thing, mostly written by me, called >twisted.python.modules. > >Sorry if I'm repeating myself here, I know I've brought it up on this list >before, but it seems germane to this thread. I'd be interested in getting >feedback from the i

Re: [Python-Dev] Require loaders set __package__ and __loader__

2012-04-15 Thread Barry Warsaw
On Apr 14, 2012, at 03:32 PM, Guido van Rossum wrote: >Funny, I was just thinking about having a simple standard API that >will let you open files (and list directories) relative to a given >module or package regardless of how the thing is loaded. I tend to use the "basic resource access" API of

[Python-Dev] Edit the rejected PEP 416 (frozendict) to mention the newly added types.MappingProxyType

2012-04-15 Thread Victor Stinner
Hi, The frozendict (PEP 416) was rejected, but I just added the types.MappingProxyType. This type is not new, it existed since Python 2.2 as the internal dict_proxy type. See also the issue #14386. I would like to know if I can edit the rejected PEP, or if Guido prefers to do it, to mention the n

Re: [Python-Dev] cpython: Update importlib.h

2012-04-15 Thread Antoine Pitrou
On Sun, 15 Apr 2012 23:56:18 +0200 brett.cannon wrote: > http://hg.python.org/cpython/rev/096653de404d > changeset: 76332:096653de404d > user:Brett Cannon > date:Sun Apr 15 17:47:19 2012 -0400 > summary: > Update importlib.h I wonder if we could somehow set importlib.h as bin

Re: [Python-Dev] Require loaders set __package__ and __loader__

2012-04-15 Thread Glyph
On Apr 14, 2012, at 3:32 PM, Guido van Rossum wrote: > Funny, I was just thinking about having a simple standard API that > will let you open files (and list directories) relative to a given > module or package regardless of how the thing is loaded. Twisted has such a thing, mostly written by m

Re: [Python-Dev] Require loaders set __package__ and __loader__

2012-04-15 Thread Glyph
On Apr 14, 2012, at 7:59 PM, Guido van Rossum wrote: > On Sat, Apr 14, 2012 at 5:06 PM, Christian Heimes wrote: >> Am 15.04.2012 00:56, schrieb Guido van Rossum: >>> Well, if it's a real file, and you need a stream, that's efficient, >>> and if you need the data, you can read it. But if it comes

Re: [Python-Dev] Providing a mechanism for PEP 3115 compliant dynamic class creation

2012-04-15 Thread Daniel Urban
On Sun, Apr 15, 2012 at 13:48, Nick Coghlan wrote: > /me pages thoughts from 12 months ago back into brain... Sorry about that, I planned to do this earlier... > On Sun, Apr 15, 2012 at 7:36 PM, Daniel Urban wrote: >> On Tue, Apr 19, 2011 at 16:10, Nick Coghlan wrote: >>> Initially I was going

Re: [Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions

2012-04-15 Thread Victor Stinner
2012/4/15 M.-A. Lemburg : > I'd suggest to also include a tool or API to determine the > real resolution of a time function (as opposed to the advertised > one). See pybench's clockres.py helper as example. The PEP includes such tool, but I forgot to mention it in the PEP: http://hg.python.org/pep

Re: [Python-Dev] cpython: Rebuild importlib.h to incorporate added comments.

2012-04-15 Thread Brett Cannon
On Sun, Apr 15, 2012 at 10:42, Georg Brandl wrote: > On 15.04.2012 14:53, Antoine Pitrou wrote: > >> On Sun, 15 Apr 2012 03:50:06 +0200 >> brett.cannon> >> wrote: >> >>> >>> http://hg.python.org/cpython/**rev/6a77697d2a63 >>> changeset: 76311:6

[Python-Dev] Suggested addition to PEP 8 for context managers

2012-04-15 Thread Raymond Hettinger
We should publish some advice on creating content managers. Context managers are a general purpose tool but have a primary use case of creating and releasing resources. This creates an expectation that that is what the context managers are doing unless they explicitly say otherwise. For example

Re: [Python-Dev] making the import machinery explicit

2012-04-15 Thread Brett Cannon
On Sun, Apr 15, 2012 at 07:26, Nick Coghlan wrote: > Hooray for finally having this to the point where it has been pushed to > trunk :) > > On Sun, Apr 15, 2012 at 8:16 AM, Brett Cannon wrote: > > Once again, it's just code that needs updating to run on Python 3.3 so I > > don't view it as a con

Re: [Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions

2012-04-15 Thread M.-A. Lemburg
Victor Stinner wrote: > Hi, > > Here is a simplified version of the first draft of the PEP 418. The > full version can be read online. > http://www.python.org/dev/peps/pep-0418/ > > The implementation of the PEP can be found in this issue: > http://bugs.python.org/issue14428 > > I post a simplif

Re: [Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions

2012-04-15 Thread Victor Stinner
> Here is a simplified version of the first draft of the PEP 418. The > full version can be read online. > http://www.python.org/dev/peps/pep-0418/ FYI there is no time.thread_time() function. It would only be available on Windows and Linux. It does not use seconds but CPU cycles. No module or pro

Re: [Python-Dev] cpython: Rebuild importlib.h to incorporate added comments.

2012-04-15 Thread Georg Brandl
On 15.04.2012 14:53, Antoine Pitrou wrote: On Sun, 15 Apr 2012 03:50:06 +0200 brett.cannon wrote: http://hg.python.org/cpython/rev/6a77697d2a63 changeset: 76311:6a77697d2a63 user:Brett Cannon date:Sat Apr 14 21:18:48 2012 -0400 summary: Rebuild importlib.h to incorpora

Re: [Python-Dev] cpython: Rebuild importlib.h to incorporate added comments.

2012-04-15 Thread Antoine Pitrou
On Sun, 15 Apr 2012 03:50:06 +0200 brett.cannon wrote: > http://hg.python.org/cpython/rev/6a77697d2a63 > changeset: 76311:6a77697d2a63 > user:Brett Cannon > date:Sat Apr 14 21:18:48 2012 -0400 > summary: > Rebuild importlib.h to incorporate added comments. Isn't there a Makef

Re: [Python-Dev] Require loaders set __package__ and __loader__

2012-04-15 Thread Nick Coghlan
On Sun, Apr 15, 2012 at 8:32 AM, Guido van Rossum wrote: > Funny, I was just thinking about having a simple standard API that > will let you open files (and list directories) relative to a given > module or package regardless of how the thing is loaded. If we > guarantee that there's always a __lo

Re: [Python-Dev] Providing a mechanism for PEP 3115 compliant dynamic class creation

2012-04-15 Thread Nick Coghlan
/me pages thoughts from 12 months ago back into brain... On Sun, Apr 15, 2012 at 7:36 PM, Daniel Urban wrote: > On Tue, Apr 19, 2011 at 16:10, Nick Coghlan wrote: >> Initially I was going to suggest making __build_class__ part of the >> language definition rather than a CPython implementation de

Re: [Python-Dev] making the import machinery explicit

2012-04-15 Thread Nick Coghlan
Hooray for finally having this to the point where it has been pushed to trunk :) On Sun, Apr 15, 2012 at 8:16 AM, Brett Cannon wrote: > Once again, it's just code that needs updating to run on Python 3.3 so I > don't view it as a concern. Going from list.append() to list.insert() (even > if its `

Re: [Python-Dev] Require loaders set __package__ and __loader__

2012-04-15 Thread Nick Coghlan
On Sun, Apr 15, 2012 at 12:59 PM, Guido van Rossum wrote: > Hm... Can you give an example of a library that needs a real file? > That sounds like a poorly designed API. If you're invoking a separate utility (e.g. via it's command line interface), you may need a real filesystem path that you can p

Re: [Python-Dev] Providing a mechanism for PEP 3115 compliant dynamic class creation

2012-04-15 Thread Daniel Urban
On Tue, Apr 19, 2011 at 16:10, Nick Coghlan wrote: > In reviewing a fix for the metaclass calculation in __build_class__ > [1], I realised that PEP 3115 poses a potential problem for the common > practice of using "type(name, bases, ns)" for dynamic class creation. > > Specifically, if one of the

Re: [Python-Dev] Security issue with the tracker

2012-04-15 Thread anatoly techtonik
On Fri, Apr 13, 2012 at 9:53 PM, Éric Araujo wrote: > bugs.python.org already sanitizes the ok_message and Ezio already posted a > patch to the upstream bug tracker, so I don’t see what else we could do. I am +1 with Glyph that XSS protection in Roundup is an unreliable hack. Ezio's patch just pr