Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Ethan Furman
Nick Coghlan wrote: On Thu, Mar 8, 2012 at 11:42 AM, Benjamin Peterson benja...@python.org wrote: 2012/3/7 Victor Stinner victor.stin...@gmail.com: Can't we simply raise an error if the dict contains non-string keys? Sounds okay to me. For 3.3, the most we can do is trigger a deprecation

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Lennart Regebro
On Thu, Mar 8, 2012 at 08:46, Ethan Furman et...@stoneleaf.us wrote: I think it would be sad to lose that functionality. If we are going to, though, we may as well check the string to make sure it's a valid identifier: That would break even more code. I have encountered many cases of

Re: [Python-Dev] problem with recursive yield from delegation

2012-03-08 Thread Mark Shannon
Stefan Behnel wrote: Hi, I found a problem in the current yield from implementation that I think is worth discussing: http://bugs.python.org/issue14220 [snip] I've been experimenting with the implementation of PEP 380, and I found a couple of interesting things. First of all, the

Re: [Python-Dev] problem with recursive yield from delegation

2012-03-08 Thread Nick Coghlan
On Thu, Mar 8, 2012 at 9:52 PM, Mark Shannon m...@hotpy.org wrote: I would recommend changing one of two things in the PEP: Either, close and throw should not close/throw in subiterators (this would simplify the semantics and implementation immensely) Or, only allow subgenerators, not

Re: [Python-Dev] Adding a builtins parameter to eval(), exec() and __import__().

2012-03-08 Thread Mark Shannon
Jim J. Jewett wrote: http://mail.python.org/pipermail/python-dev/2012-March/117395.html Brett Cannon posted: [in reply to Mark Shannon's suggestion of adding a builtins parameter to match locals and globals] It's a mess right now to try to grab the __import__() implementation and this would

Re: [Python-Dev] problem with recursive yield from delegation

2012-03-08 Thread Nick Coghlan
On Thu, Mar 8, 2012 at 9:52 PM, Mark Shannon m...@hotpy.org wrote: First of all, the semantics described in the PEP do not match the tests. If you substitute the supposedly semantically equivalent code based on normal yields for each yield from in the test code (Lib/test/test_pep380.py) and

Re: [Python-Dev] Adding a builtins parameter to eval(), exec() and __import__().

2012-03-08 Thread Nick Coghlan
On Thu, Mar 8, 2012 at 10:06 PM, Mark Shannon m...@hotpy.org wrote: I don't think it cleans up import, but I'll defer to Brett on that. I've included __import__() along with exec and eval as it is a place where new namespaces can be introduced into an execution. There may be others I haven't

[Python-Dev] steps to solve bugs

2012-03-08 Thread Ejaj Hassan
Hi, I am a novice python programmer and am learning to be able to solve some issues. Well following the steps given in the PSF website, I have * installed vc++ 2008 and even finished till building the cpython code and I have got the console for python 3.0x Having done this, I am not able to

Re: [Python-Dev] steps to solve bugs

2012-03-08 Thread Nick Coghlan
On Thu, Mar 8, 2012 at 11:09 PM, Ejaj Hassan ejjy...@gmail.com wrote: Hi,   I am a novice python programmer and am learning to be able to solve some issues. Well following the steps given in the PSF website, I have * installed vc++ 2008 and even finished till building the cpython code and I

Re: [Python-Dev] steps to solve bugs

2012-03-08 Thread Oleg Broytman
On Thu, Mar 08, 2012 at 06:39:42PM +0530, Ejaj Hassan wrote: I am a novice python programmer and am learning to be able to solve some issues. Well following the steps given in the PSF website, I have installed vc++ 2008 and even finished till building the cpython code and I have got the

Re: [Python-Dev] Adding a builtins parameter to eval(), exec() and __import__().

2012-03-08 Thread Mark Shannon
Nick Coghlan wrote: On Thu, Mar 8, 2012 at 10:06 PM, Mark Shannon m...@hotpy.org wrote: I don't think it cleans up import, but I'll defer to Brett on that. I've included __import__() along with exec and eval as it is a place where new namespaces can be introduced into an execution. There may be

Re: [Python-Dev] problem with recursive yield from delegation

2012-03-08 Thread Mark Shannon
Nick Coghlan wrote: On Thu, Mar 8, 2012 at 9:52 PM, Mark Shannon m...@hotpy.org wrote: First of all, the semantics described in the PEP do not match the tests. If you substitute the supposedly semantically equivalent code based on normal yields for each yield from in the test code

Re: [Python-Dev] PEP 412 has been accepted

2012-03-08 Thread Antoine Pitrou
On Wed, 7 Mar 2012 18:52:43 -0500 Brett Cannon br...@yvrsfo.ca wrote: Since PEP 412 has code that doesn't break tests anymore (thanks to hash randomization), it was just accepted. Mark, can you make sure there is an up-to-date patch in the tracker so people can potentially look at the code at

Re: [Python-Dev] Adding a builtins parameter to eval(), exec() and __import__().

2012-03-08 Thread Nick Coghlan
On Thu, Mar 8, 2012 at 11:40 PM, Mark Shannon m...@hotpy.org wrote: Other code will use whatever builtins they were given at __import__. Then they're not builtins - they're module-specific chained globals. The thing that makes the builtins special is *who else* can see them (i.e. all the other

[Python-Dev] Request for clarification of PEP 380

2012-03-08 Thread Mark Shannon
Hi, The scenario is this: A generator, G, has a non-generator sub-iterator, S, (ie G includes a yield from S experssion and S is not a generator) and either G.close() or G.throw(GeneratorExit) is called. In the current implementation, S.close() is called and, if that call raises an exception,

Re: [Python-Dev] problem with recursive yield from delegation

2012-03-08 Thread Nick Coghlan
On Thu, Mar 8, 2012 at 11:45 PM, Mark Shannon m...@hotpy.org wrote: It really ought say that yield from is equivalent to inlining in the PEP. That's what the motivation section is about. There's also an entire subsection called The Refactoring Principle that describes this intent. However, we

Re: [Python-Dev] Request for clarification of PEP 380

2012-03-08 Thread Nick Coghlan
On Fri, Mar 9, 2012 at 12:06 AM, Mark Shannon m...@hotpy.org wrote: The text of the PEP seems to implicitly assume that all sub-iterators will be generators, so it is not clear on the above points. On the contrary, this question is explicitly addressed in the PEP:

Re: [Python-Dev] Why does Mac OS X python share site-packages with apple python?

2012-03-08 Thread Barry Scott
Just to follow up. With Robin's help over in wxPython land I have given Robin a patch to wxPython to fix the site-packages issue. Barry ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe:

Re: [Python-Dev] Request for clarification of PEP 380

2012-03-08 Thread Mark Shannon
Nick Coghlan wrote: On Fri, Mar 9, 2012 at 12:06 AM, Mark Shannon m...@hotpy.org wrote: The text of the PEP seems to implicitly assume that all sub-iterators will be generators, so it is not clear on the above points. On the contrary, this question is explicitly addressed in the PEP:

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Guido van Rossum
On Thu, Mar 8, 2012 at 1:10 AM, Lennart Regebro rege...@gmail.com wrote: On Thu, Mar 8, 2012 at 08:46, Ethan Furman et...@stoneleaf.us wrote: I think it would be sad to lose that functionality. If we are going to, though, we may as well check the string to make sure it's a valid identifier:

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Ethan Furman
Guido van Rossum wrote: On Wed, Mar 7, 2012 at 11:43 PM, Ethan Furman wrote: Are you able to modify classes after class creation in Python 3? Without using a metaclass? Yes, by assignment to attributes. The __dict__ is a read-only proxy, but attribute assignment is allowed. (This is because

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Guido van Rossum
On Thu, Mar 8, 2012 at 8:22 AM, Ethan Furman et...@stoneleaf.us wrote: Guido van Rossum wrote: On Wed, Mar 7, 2012 at 11:43 PM, Ethan Furman wrote: Are you able to modify classes after class creation in Python 3? Without using a metaclass? Yes, by assignment to attributes. The __dict__ is

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread PJ Eby
On Thu, Mar 8, 2012 at 2:43 AM, Ethan Furman et...@stoneleaf.us wrote: PJ Eby wrote: Short version: AddOns are things you can use to dynamically extend instances -- a bit like the decorator in decorator pattern (not to be confused with Python decorators). Rather than synthesize a unique

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread fwierzbi...@gmail.com
On Wed, Mar 7, 2012 at 5:39 PM, Victor Stinner victor.stin...@gmail.com wrote: Hi, During the Language Summit 2011 (*), it was discussed that PyPy and Jython don't support non-string key in type dict. An issue was open to emit a warning on such dict, but the patch has not been commited yet.

Re: [Python-Dev] Adding a builtins parameter to eval(), exec() and __import__().

2012-03-08 Thread Guido van Rossum
On Thu, Mar 8, 2012 at 5:57 AM, Nick Coghlan ncogh...@gmail.com wrote: On Thu, Mar 8, 2012 at 11:40 PM, Mark Shannon m...@hotpy.org wrote: Other code will use whatever builtins they were given at __import__. Then they're not builtins - they're module-specific chained globals. The thing that

Re: [Python-Dev] PEP 412 has been accepted

2012-03-08 Thread Guido van Rossum
On Thu, Mar 8, 2012 at 5:41 AM, Antoine Pitrou solip...@pitrou.net wrote: For the record (I had to look it up), PEP 412 is Mark Shannon's Key-Sharing Dictionary, an optimization that decreases memory consumption of instances. http://www.python.org/dev/peps/pep-0412/ Thanks for reminding us.

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Ethan Furman
Guido van Rossum wrote: On Thu, Mar 8, 2012 at 8:22 AM, Ethan Furman et...@stoneleaf.us wrote: Guido van Rossum wrote: On Wed, Mar 7, 2012 at 11:43 PM, Ethan Furman wrote: Are you able to modify classes after class creation in Python 3? Without using a metaclass? Yes, by assignment to

Re: [Python-Dev] Non-string keys in type dict

2012-03-08 Thread Amaury Forgeot d'Arc
Hi, 2012/3/8 Ethan Furman et...@stoneleaf.us: A little more experimentation shows that not all is well, however: -- dir(Test) Traceback (most recent call last):  File stdin, line 1, in module TypeError: unorderable types: int() str() So what conclusion do you draw? That other changes

Re: [Python-Dev] Sandboxing Python

2012-03-08 Thread Armin Rigo
Hi Stefan, On Wed, Mar 7, 2012 at 23:16, Stefan Behnel stefan...@behnel.de wrote: Well, there's a bug tracker that lists some of them, which is not *that* hard to find. Does your claim about a significantly harder endeavour refer to finding a crash or to finding a fix for it? Are you talking

Re: [Python-Dev] problem with recursive yield from delegation

2012-03-08 Thread Stefan Behnel
Stefan Behnel, 07.03.2012 21:40: I found a problem in the current yield from implementation ... and here's another one, also in genobject.c: int PyGen_FetchStopIterationValue(PyObject **pvalue) { PyObject *et, *ev, *tb; PyObject *value = NULL; if

Re: [Python-Dev] Adding a builtins parameter to eval(), exec() and __import__().

2012-03-08 Thread Paul Moore
On 8 March 2012 12:52, Nick Coghlan ncogh...@gmail.com wrote: 2. it's already trivial to achieve such chained lookups in 3.3 by passing a collections.ChainMap instance as the globals parameter: http://docs.python.org/dev/library/collections#collections.ChainMap Somewhat OT, but

Re: [Python-Dev] problem with recursive yield from delegation

2012-03-08 Thread Benjamin Peterson
2012/3/8 Stefan Behnel stefan...@behnel.de: Would that be acceptable for CPython as well or would you prefer full fledged normalisation? I think we have to normalize for correctness. Consider that it may be some StopIteration subclass which set value on construction. -- Regards, Benjamin

Re: [Python-Dev] problem with recursive yield from delegation

2012-03-08 Thread Antoine Pitrou
On Thu, 8 Mar 2012 14:36:06 -0600 Benjamin Peterson benja...@python.org wrote: 2012/3/8 Stefan Behnel stefan...@behnel.de: Would that be acceptable for CPython as well or would you prefer full fledged normalisation? I think we have to normalize for correctness. Consider that it may be

Re: [Python-Dev] problem with recursive yield from delegation

2012-03-08 Thread Benjamin Peterson
2012/3/8 Antoine Pitrou solip...@pitrou.net: On Thu, 8 Mar 2012 14:36:06 -0600 Benjamin Peterson benja...@python.org wrote: 2012/3/8 Stefan Behnel stefan...@behnel.de: Would that be acceptable for CPython as well or would you prefer full fledged normalisation? I think we have to normalize

[Python-Dev] PEP

2012-03-08 Thread Mark Janssen
On Thu, Feb 9, 2012 at 5:18 PM, Guido van Rossum gu...@python.org wrote: A dictionary would (then) be a SET of these. (Voila! things have already gotten simplified.) Really? So {a:1, a:2} would be a dict of length 2? Eventually, I also think this will seque and integrate nicely into

Re: [Python-Dev] [Python-ideas] PEP

2012-03-08 Thread Masklinn
On 2012-03-08, at 22:08 , Mark Janssen wrote: I just noticed something in Guido's example. Something gives me a strange feeling that using a variable as a key doesn't smell right. Presumably Python just hashes the variable's id, or uses the id itself as the key Python calls ``hash`` on the

Re: [Python-Dev] Adding a builtins parameter to eval(), exec() and __import__().

2012-03-08 Thread Victor Stinner
On 07/03/2012 16:33, Mark Shannon wrote: It should also help with sandboxing, as it would make it easier to analyse and thus control access to builtins, since the execution context of all code would be easier to determine. pysandbox patchs __builtins__ in: - the caller frame - the

Re: [Python-Dev] PEP 414 - some numbers from the Django port

2012-03-08 Thread Maciej Fijalkowski
On Wed, Mar 7, 2012 at 2:36 PM, Vinay Sajip vinay_sa...@yahoo.co.uk wrote: Armin Ronacher armin.ronacher at active-4.com writes: What are you trying to argue?  That the overall Django testsuite does not do a lot of string processing, less processing with native strings? I'm surprised you see

Re: [Python-Dev] Sandboxing Python

2012-03-08 Thread Victor Stinner
On 05/03/2012 23:11, Victor Stinner wrote: 3 tests are crashing pysandbox: - modify a dict during a dict lookup: I proposed two different fixes in issue #14205 - type MRO changed during a type lookup (modify __bases__ during the lookup): I proposed a fix in issue #14199 (keep a reference to

Re: [Python-Dev] Adding a builtins parameter to eval(), exec() and __import__().

2012-03-08 Thread Nick Coghlan
On Fri, Mar 9, 2012 at 3:31 AM, Guido van Rossum gu...@python.org wrote: But the __builtins__ that are actually used by any particular piece of code is *not* taken by importing builtins. It is taken from what the globals store under the key __builtins__. This is a feature that was added

Re: [Python-Dev] Adding a builtins parameter to eval(), exec() and __import__().

2012-03-08 Thread Guido van Rossum
On Thu, Mar 8, 2012 at 4:33 PM, Nick Coghlan ncogh...@gmail.com wrote: On Fri, Mar 9, 2012 at 3:31 AM, Guido van Rossum gu...@python.org wrote: But the __builtins__ that are actually used by any particular piece of code is *not* taken by importing builtins. It is taken from what the globals

Re: [Python-Dev] Sandboxing Python

2012-03-08 Thread Victor Stinner
On 01/03/2012 22:59, Victor Stinner wrote: I challenge anymore to break pysandbox! I would be happy if anyone breaks it because it would make it more stronger. Results, one week later. Nobody found a vulnerability giving access to the filesystem or to the sandbox. Armin Rigo complained that