[issue1182143] making builtin exceptions more informative

2009-11-05 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> 

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7224] One obvious way to do interning

2009-11-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

The basic problem here is that the "one obvious way" to some people
(including me and Martin v. Löwis) is to use a dictionary.  Further,
there is the problem of conflating types in a user's mind -- right now,
dictionaries are all about looking up and returning values, while sets
are not.  

The current notion of sets corresponds neatly with what folks learn in
their basic math classes.  In contrast, the notion of "canonical
representatives of an equivalence class" is a more advanced mathematical
concept, one that many people are never taught.  This is even more
problematic in Python because the operation of finding canonical values
is hidden behind well designed __hash__ and __eq__ functions (for
example, it is not at all obvious how Decimal(3.0), float(3.0), and
int(3.0) all have the same hash value).  

An additional problem is the modification of set.add() so that it
violates Python's norm of having mutating methods return None.  We
should keep the language consistent in this regard.

Also, I should comment on the "appreciable memory savings".  This saves
only a single pointer (4 bytes on a 32-bit build) out of three per
string.  But the string object itself takes up memory, so the percent
savings per string is smaller than you would might expect (typically
less than 15%).

Finally, the spirit of the language moratorium is to make it so that
other Python implementations don't have to change for a few years.

FWIW, I am already going to expand the set/frozenset documention to show
some techniques for accessing and using sets.  I can add a link to a
get_equivalent() recipe that makes it possible to retrieve canonical
values from any container including sets.  That recipe uses all the
containers as-is, no patching or API changes needed.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1294959] Problems with /usr/lib64 builds.

2009-11-05 Thread Éric Araujo

Éric Araujo  added the comment:

If I understand correctly, using lib32 or lib64 is a kludge. Debian
and Ubuntu want to come up with a better way to do this:
http://wiki.debian.org/ReleaseGoals/MultiArch
https://wiki.ubuntu.com/MultiarchSpec

Kind regards.

--
nosy: +Merwok

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7265] IDLE not working

2009-11-05 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

Closing as resolved, then.

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7212] Retrieve an arbitrary element from a set without removing it

2009-11-05 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

I don't want to pollute python-dev with more hopeless ideas, but I wonder 
if itertools could grow an efficient C-implemented

def first(collection):
   return next(iter(collection))

On the other hand, it probably belongs to recipes more than stdlib.  This 
is not really an iterator tool after all.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7212] Retrieve an arbitrary element from a set without removing it

2009-11-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

After a long discussion on python-dev, this proposal is rejected in
favor of adding documentation notes on the ways to non-destructively
retrieve an arbitrary item from a set or frozenset.

Here is an except from the end of the thread:

[Steven D'Aprano]
>> Anyway, given the level of opposition to the suggestion, I'm no longer
>> willing to carry the flag for it. If anyone else -- perhaps the OP --
>> feels they want to take it any further, be my guest.

[geremy condra]
> I've said before that I'd like there to be one, standard way of
> doing this. A function call- set.pick() seems reasonably named
> to me- is probably the cleanest way to do that. Absent that,
> an example in the docs that illustrates the preferred idiom
> would be great. 

[Raymond]
Summarizing my opposition to a new set method:
1) there already are at least two succinct ways to get the same effect
2) those ways work with any container, not just sets
3) set implementations in other languages show that this isn't needed.
4) there is value to keeping the API compact
5) isn't needed for optimization (selecting the same value in a loop
makes no sense)
6) absence of real-world code examples that would be meaningfully improved

[Terry Reedy]
Agreed

[Raymond]
I would be happy to add an example to the docs so that this thread
can finally end.

[Eric Smith]
Please do!

[Terry Reedy]
Yes!
'''


Leaving this open until I've done the documentation patch.

--
priority:  -> low
resolution:  -> rejected

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7224] One obvious way to do interning

2009-11-05 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

On Thu, Nov 5, 2009 at 2:16 PM, Raymond Hettinger
 wrote:
>
> Raymond Hettinger  added the comment:
>
> The basic problem here is that the "one obvious way" to some people
> (including me and Martin v. Löwis) is to use a dictionary.  Further,
> there is the problem of conflating types in a user's mind -- right now,
> dictionaries are all about looking up and returning values, while sets
> are not.

One feature that is missing from both dict approach and get_equivalent
recipe is the ability to do interning of new values with a single
lookup.  Note that even at the C level one has to first try to
retrieve the key from the dictionary and then if that fails, do an
insert which repeats the same lookup.  Even dict.setdefault which is
designed to remove the double lookup while eliminates it when key is
present, still does the second lookup when the key is missing.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7224] One obvious way to do interning

2009-11-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

That is a false optimization.  Regular python code is full of look-ups
(even set.add has a getattr(s, 'add') lookup just to find the
add-method; every call to a built-in typically goes through multiple
lookups).   Also, the cost of a second lookup is trivial because of
processor caching:  see Object/dictnotes.txt.

Martin has already rejected a similar proposal for similar reasons. 
Please drop this one.  IMO, it is harmful to the set API because it
changes set's core concept to include lookup operations instead of just
simple set operations.

Either use sys.intern() or roll your own using get_equivalent() or a
dictionary.  A single use-case doesn't warrant building-out the
language, providing more ways to do it, or messing the core concept of
the set/frozenset datatype.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7224] One obvious way to do interning

2009-11-05 Thread Eric Smith

Eric Smith  added the comment:

I agree with Raymond here. This use case isn't special enough, or the
performance of the current "one way to do it" bad enough to warrant
changing set. I recommend closing this issue.

--
nosy: +eric.smith

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7224] One obvious way to do interning

2009-11-05 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

On Thu, Nov 5, 2009 at 3:23 PM, Raymond Hettinger
 wrote:
..
> Martin has already rejected a similar proposal for similar reasons.
> Please drop this one.

Sure.  In fact I've never proposed to apply this patch.  As I said in
my original submission, the only purpose of reviving  issue1507011 is
this way was to give an easy way for users who claimed that in their
apps saving 4-8 bytes per interned string would make a difference to
test their claim.

Just as with issue1507011 three years ago I personally did not see
noticeable improvements in my applications from the patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7224] One obvious way to do interning

2009-11-05 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Thank you.

--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7266] test_lib2to3 failure under Windows

2009-11-05 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

I think we need someone with access to windows to propose a patch.

--
assignee: benjamin.peterson -> 
components: +Windows

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

New submission from flashk :

I recently ran 2to3 on some of my scripts and noticed a change in behavior.

I had a script that used the built-in execfile function. After the conversion, 
it was 
changed to manually open the file and read the contents into the exec function. 
Now I am 
getting a SyntaxError with the modified code.

The SyntaxError is caused when the new exec code is called on a script that 
ends with an 
empty indented line. I'm not sure if this is an error with the 2to3 script or 
the built-
in exec function.

I've attached a very minimal test case. The test.py file is a simple hello 
world script 
that ends with an empty indented line. The execfile_example.py file simply 
calls 
execfile on the test.py script. The execfile_example_converted.py file is the 
2to3 
converted version of execfile_example.py.

I'm running Python 2.6.2 on Windows XP.

--
components: 2to3 (2.x to 3.0 conversion tool), Interpreter Core
files: execfile_problem.zip
messages: 94949
nosy: flashk
severity: normal
status: open
title: 2to3 execfile conversion changes behavior
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file15267/execfile_problem.zip

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Could you attach the files separately or paste them into the bug? zip
files are hard to work with.

--
nosy: +benjamin.peterson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

Changes by flashk :


Added file: http://bugs.python.org/file15268/test.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

Changes by flashk :


Added file: http://bugs.python.org/file15269/execfile_example.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

Changes by flashk :


Added file: http://bugs.python.org/file15270/execfile_example_converted.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

flashk  added the comment:

I just attached the files individually.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

test.py is invalid Python 3 syntax.

--
resolution:  -> invalid
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

flashk  added the comment:

I'm running this code under 2.6, so the print statement should not be the 
issue. I've attached a new version of test.py that simply performs a 
variable assignment and I still get the syntax error on both 2.6 and 3.1 
with the exec function. Also, the syntax error is reported on line 3, 
which is the empty indented line. Sorry for the confusion.

--
Added file: http://bugs.python.org/file15271/test.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3001] RLock's are SLOW

2009-11-05 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
assignee:  -> pitrou
components:  -Interpreter Core
stage: patch review -> needs patch
versions: +Python 3.2 -Python 2.7, Python 3.1

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

This is because you have DOS newlines which the Python compiler cannot
handle. In 2.x, open("test.py", "r") does not translate newlines. In
3.x, it does.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

flashk  added the comment:

Ok, I converted test.py to use Unix style newlines and still get the 
syntax error on both 2.6 and 3.1. I'm confused as to why execfile works on 
the file but reading the contents and passing it to exec behaves 
differently under 2.6. Sorry if I'm just being dense.

--
Added file: http://bugs.python.org/file15272/test.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

2009/11/5 flashk :
>
> flashk  added the comment:
>
> Ok, I converted test.py to use Unix style newlines and still get the
> syntax error on both 2.6 and 3.1. I'm confused as to why execfile works on
> the file but reading the contents and passing it to exec behaves
> differently under 2.6. Sorry if I'm just being dense.

open in 2.x does not translate newlines by default. It does so in 3.x.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

flashk  added the comment:

Ok, but why am I still getting a syntax error in both 2.6 and 3.1 on the 
file, even after converting the newlines?

If I remove the trailing indentation then everything works properly on 2.6 
and 3.1, even with DOS newlines.

It just seems that exec does not properly handle code that ends with an 
empty indented line, but execfile handles it correctly.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

2009/11/5 flashk :
>
> flashk  added the comment:
>
> Ok, but why am I still getting a syntax error in both 2.6 and 3.1 on the
> file, even after converting the newlines?
>
> If I remove the trailing indentation then everything works properly on 2.6
> and 3.1, even with DOS newlines.
>
> It just seems that exec does not properly handle code that ends with an
> empty indented line, but execfile handles it correctly.

Well, it works for me with the empty newline. Can you isolate the exact problem?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6462] bsddb3 intermittent test failures

2009-11-05 Thread R. David Murray

R. David Murray  added the comment:

The deadlock error is still there, so I'm leaving this open, but it is
no longer causing buildbot instability.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6462] bsddb3 intermittent test failures

2009-11-05 Thread R. David Murray

Changes by R. David Murray :


--
keywords:  -buildbot

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7266] test_lib2to3 failure under Windows

2009-11-05 Thread R. David Murray

R. David Murray  added the comment:

Benjamin disabled this test on windows so it is no longer causing the
buildbot to fail.

--
components: +Tests
keywords: +easy -buildbot
nosy: +r.david.murray
priority: normal -> low
stage:  -> needs patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3892] bsddb: test01_basic_replication fails on Windows sometimes

2009-11-05 Thread R. David Murray

Changes by R. David Murray :


--
keywords:  -buildbot

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6748] test_debuglevel from test_telnetlib.py fails

2009-11-05 Thread R. David Murray

Changes by R. David Murray :


--
keywords: +buildbot

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

flashk  added the comment:

On Thu, Nov 5, 2009 at 5:48 PM, Benjamin Peterson wrote:
>
>
> Well, it works for me with the empty newline. Can you isolate the exact
> problem?

For me, the exact problem seems to be that exec raises a SyntaxError if the
code contains a trailing indentation. Here's a summary of everything I've
tried:

 * test.py runs successfully on 2.6 and 3.1, regardless of line ending style
(LF, CR+LF)

 * "execfile('test.py')" runs successfully on 2.6, regardless of line ending
style

 * "exec(compile(open('test.py').read(), 'test.py', 'exec'))" raises a
SyntaxError on line 3 of test.py under 2.6 and 3.1, regardless of line
ending style.

 * Removing the trailing indentation from test.py causes the above code to
succeed under 2.6 and 3.1, regardless of line ending style.

You mentioned that it worked for you with an empty newline. To be clear, the
last line of test.py contains a single tab, with no newline character.

--
Added file: http://bugs.python.org/file15273/unnamed

___
Python tracker 

___On Thu, Nov 5, 2009 at 5:48 PM, Benjamin Peterson 
rep...@bugs.python.org> 
wrote:



Well, it works for me with the empty newline. Can you isolate the exact 
problem?For me, the exact problem seems to be 
that exec raises a SyntaxError if the code contains a trailing indentation. 
Here's a summary of everything I've tried:

 * test.py runs successfully on 2.6 and 3.1, regardless of 
line ending style (LF, CR+LF) * 
"execfile('test.py')" runs successfully on 2.6, regardless of 
line ending style

 * "exec(compile(open('test.py').read(), 
'test.py', 'exec'))" raises a SyntaxError on line 3 of 
test.py under 2.6 and 3.1, regardless of line ending style.

 * Removing the trailing indentation from test.py causes the above 
code to succeed under 2.6 and 3.1, regardless of line ending 
style.You mentioned that it worked for you with an 
empty newline. To be clear, the last line of test.py contains a single tab, 
with no newline character.


___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7269] Windows buildbot occasional DBFileExistsError failures in test_bsddb3

2009-11-05 Thread R. David Murray

New submission from R. David Murray :

The windows buildbot occasionally fails with tracebacks like this:

==
ERROR: test01_badpointer (bsddb.test.test_misc.MiscTestCase)
--
Traceback (most recent call last):
  File
"E:\cygwin\home\db3l\buildarea\2.6.bolen-windows\build\lib\bsddb\test\test_misc.py",
line 21, in test01_badpointer
dbs = dbshelve.open(self.filename)
  File
"E:\cygwin\home\db3l\buildarea\2.6.bolen-windows\build\lib\bsddb\dbshelve.py",
line 106, in open
d.open(filename, dbname, filetype, flags, mode)
  File
"E:\cygwin\home\db3l\buildarea\2.6.bolen-windows\build\lib\bsddb\dbshelve.py",
line 171, in open
self.db.open(*args, **kwargs)
DBFileExistsError: (17, 'File exists -- __fop_file_setup:  Retry limit
(100) exceeded')

This also happens for several of the other test methods.

--
assignee: jcea
components: Library (Lib), Tests
keywords: buildbot
messages: 94962
nosy: jcea, r.david.murray
priority: normal
severity: normal
stage: needs patch
status: open
title: Windows buildbot occasional DBFileExistsError failures in test_bsddb3
type: behavior
versions: Python 2.6, Python 2.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7175] unify pydistutils.cfg and distutils.cfg and use .local

2009-11-05 Thread Éric Araujo

Éric Araujo  added the comment:

When ~/.local/lib was chosen for the user directory, the BaseDir Spec
was given as prior example. Why not go the full way and follow the spec?
The config file could be $XDG_CONFIG_HOME/python/distutils, with
$XDG_CONFIG_HOME defaulting to ~/.config.

References:
http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
http://www.freedesktop.org/wiki/Software/pyxdg (deals with
freedesktop.org-approved file formats too; the part of the code that
deals with paths would make a useful addition to the stdlib, as more and
more applications follow the spec)

--
nosy: +Merwok

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7268] 2to3 execfile conversion changes behavior

2009-11-05 Thread flashk

flashk  added the comment:

I noticed that calling "exec('\t')" raises a SyntaxError, so maybe this is 
the root of the problem. I manually added a newline character to the end 
of the file contents and it fixes the issue for me:

exec(compile(open('test.py').read()+'\n', 'test.py', 'exec'))

So maybe the 2to3 script should automatically do this in order to be 
compatible with previous execfile behavior? Or is this a problem with 
exec?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com