[issue4681] mmap offset should be off_t instead of ssize_t

2008-12-17 Thread saa

New submission from saa :

In trying to use the mmap offset to allow me to work with a 12GB file, I 
encountered the fact that the new offset parameter was a ssize_t, which 
is only 32 bits on my platform (OS X).  The mmap offset in C is defined 
to be an off_t 
(http://opengroup.org/onlinepubs/007908775/xsh/mmap.html), which is 64 
bits on my platform.  The attached patch attempts to fix the non-Windows 
code to have an off_t offset parameter and allows my code to access all 
12 GB of my file.  As a warning, this is the first time I've even looked 
at the Python source, and wouldn't even consider myself a Python coder; 
I just use Python every few months.  Review the patch carefully.

--
components: Extension Modules
files: mmap_off_t.patch
keywords: patch
messages: 77957
nosy: saa
severity: normal
status: open
title: mmap offset should be off_t instead of ssize_t
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file12375/mmap_off_t.patch

___
Python tracker 

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



[issue4681] mmap offset should be off_t instead of ssize_t

2008-12-17 Thread Martin v. Löwis

Martin v. Löwis  added the comment:

I don't think fpos_t is a suitable type here. It isn't guaranteed to be
an integral type, and, on many systems, it isn't integral. So you can't
convert int to it, and you can't do arithmetic on it.

--
nosy: +loewis

___
Python tracker 

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



[issue4681] mmap offset should be off_t instead of ssize_t

2008-12-17 Thread saa

saa  added the comment:

Sorry, I should have explained that the bulk of my patch was derived from 
existing code.  The code that references fpos_t is basically a cut and 
paste of code from Modules/bz2module.c.  I don't know if this is a valid 
usage of fpos_t, but if it isn't, you should probably file a bug on the 
existing usage in bz2module and suggest a fix.  Thanks for reviewing!

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

This new patch adds another improvement where tuples can be "optimized".
Optimized means that tuples which don't contain any GC-tracked object
become themselves untracked. Since tuples are immutable this
optimization is valid, and since it is common to store lots of tuples as
very simple containers of atomic objects this can be an interesting
optimization.

Added file: http://bugs.python.org/file12378/gctrigger2.patch

___
Python tracker 

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



[issue3439] create a numbits() method for int and long types

2008-12-17 Thread Skip Montanaro

Changes by Skip Montanaro :


--
nosy:  -skip.montanaro

___
Python tracker 

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



[issue1524639] Fix Tkinter Tcl-commands memory-leaks

2008-12-17 Thread Guilherme Polo

Guilherme Polo  added the comment:

Fix: My previous comment was about changes in Misc.deletecommand not
Misc.destroy (this is what you get for guessing the methods changed in
the diff, without applying it).

To Quentin: I wouldn't bother mentioning it since this new TkinterError
exception should go away along the changes in Misc.deletecommand as
mentioned in my previous comment.

--
versions: +Python 2.5

___
Python tracker 

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



[issue1170] shlex have problems with parsing unicode

2008-12-17 Thread Nicolau Leal Werneck

Nicolau Leal Werneck  added the comment:

Hello. I tried to patch my own shlex, and this doens't seem to be
working properly. When I try the patched module isntead of th eoriginal,
in my otherwise working program, I get the result ahead.

Is there any conversion steps missing?...


mymachine$ python interp.py < exemplo.prg
Traceback (most recent call last):
  File "interp.py", line 11, in 
tok = ss.get_token()
  File "shlexutf.py", line 103, in get_token
raw = self.read_token()
  File "shlexutf.py", line 139, in read_token
nextcategory = unicodedata.category(nextchar)
TypeError: category() argument 1 must be unicode, not str

--
nosy: +nwerneck

___
Python tracker 

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



[issue1170] shlex have problems with parsing unicode

2008-12-17 Thread Nicolau Leal Werneck

Nicolau Leal Werneck  added the comment:

OK, it worked after I found out I didn't know how to open unicode
files... Sorry for the noise, and thanks for this patch! :]

___
Python tracker 

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



[issue4680] Queue class should include high-water mark

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

It is probably easy enough to do so in a custom Queue subclass, and it's
too specialized to put in the standard library IMHO.
I'm closing the bug, another developer can reopen it if he thinks it is
truely useful.

--
nosy: +pitrou
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



[issue1524639] Fix Tkinter Tcl-commands memory-leaks

2008-12-17 Thread Guilherme Polo

Guilherme Polo  added the comment:

Rethinking about the changes done in Misc._configure I found out that
you don't need any of those there. 
Isn't it the case of only improving the changes regarding callable
overwriting in Misc._options ? So if the value is a callable and the
option doesn't exist you also don't _register the callable. Maybe I'm
forgetting about something here, so you could bring an example that
fails on this reasoning.

I've applied these changes and others commented before in a thing I'm
testing:
http://code.google.com/p/plumage/source/detail?r=85
http://code.google.com/p/plumage/source/detail?r=86
http://code.google.com/p/plumage/source/detail?r=87
http://code.google.com/p/plumage/source/detail?r=89
http://code.google.com/p/plumage/source/detail?r=91

I didn't fix the ones related to Variable yet, but if any of these
changes looks fine for someone the diffs would probably apply on "the
standard" Tkinter.py without much problem.

___
Python tracker 

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



[issue4684] sys.exit() exits program when non-daemonic threads are still running

2008-12-17 Thread Mark Florisson

New submission from Mark Florisson :

sys.exit() exits the program when non-daemonic threads are still
running, in versions >= 2.5. 

Test included. A demonstration here: http://paste.pocoo.org/show/95766/
(On debian GNU/Linux)

--
components: None
files: foo.py
messages: 77978
nosy: eggy
severity: normal
status: open
title: sys.exit() exits program when non-daemonic threads are still running
type: behavior
versions: Python 2.5, Python 2.6, Python 3.0
Added file: http://bugs.python.org/file12381/foo.py

___
Python tracker 

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



[issue4680] Queue class should include high-water mark

2008-12-17 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I concur with Antoine.

--
nosy: +rhettinger

___
Python tracker 

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



[issue3439] create a numbits() method for int and long types

2008-12-17 Thread STINNER Victor

STINNER Victor  added the comment:

> Committed

Really? YEAH! Great job everybody ;-) I read the code and it looks 
valid. Micro optimisation (for smaller memory footprint): would it be 
possible to share the 32 int table (BitLengthTable) between int and 
long (in Python 2.x)?

___
Python tracker 

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



[issue1524639] Fix Tkinter Tcl-commands memory-leaks

2008-12-17 Thread Guilherme Polo

Guilherme Polo  added the comment:

The changes in Misc.destroy do not look right, why are you deleting
commands created by bind_all (for example) from the root window when a
simple widget is destroyed ? 

It would make more sense to not apply these changes in Misc.destroy,
instead, Misc.unbind_all would remove commands from the root using
Misc._root.deletecommand and inside Misc._bind it would check if
needcleanup is true or false and decide from where to remove. Also,
given how this needcleanup parameter is used, I suggest renaming it to
widgetcmd, so if it is set 0 it indicates that the command should live
in self._root()._tclCommands.

___
Python tracker 

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



[issue4681] mmap offset should be off_t instead of ssize_t

2008-12-17 Thread saa

saa  added the comment:

Thanks again, revised patch attached.

Added file: http://bugs.python.org/file12376/mmap_off_t_2.patch

___
Python tracker 

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



[issue3110] Multiprocessing package build problem on Solaris 10

2008-12-17 Thread osvenskan

Changes by osvenskan :


--
nosy: +osvenskan

___
Python tracker 

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



[issue4680] Queue class should include high-water mark

2008-12-17 Thread Roy Smith

Roy Smith  added the comment:

I'm suppose you could implement this in a subclass, but it would be
inefficient.  You'd have to over-ride put() and get(), call qsize(),
then delegate to Base.put() and Base.get().

A cleaner solution would be in the C implementation of deque, in
Modules/collectionsmodule.c.  There's just a couple of places where
queue->len gets incremented.  All that needs to happen is add:

if (queue->len > queue->high_water_mark) {
queue->high_water_mark = queue->len;
}

after each one and then add the appropriate accessor functions in deque
and Queue to expose it to users.  The run-time cost is a couple of
machine instructions for each item added to the deque.

If I were to write the code and submit it, would you be willing to
accept it?

___
Python tracker 

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



[issue4683] urllib2.HTTPDigestAuthHandler fails on third hostname?

2008-12-17 Thread Chris Boyle

New submission from Chris Boyle :

The attached script, when edited to fill in valid LiveJournal
credentials (or InsaneJournal, if you change the URL and user list)
fails for me in a very odd way. It fetches the first two URLs quite
happily, and returns a 401 on the third after querying my password
manager about 6 times (always the third, no matter what the user list
is). Rebuilding the opener each time around the loop doesn't fix it.
Recreating the HTTPDigestAuthHandler (and then rebuilding the opener)
*does* fix it. Seems like any given instance of HTTPDigestAuthHandler
fails on the third hostname.

Python package version 2.5.1-5ubuntu5.2. Haven't tried it on newer versions.

--
components: Extension Modules
files: urllib2-test.txt
messages: 77965
nosy: cmb
severity: normal
status: open
title: urllib2.HTTPDigestAuthHandler fails on third hostname?
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file12377/urllib2-test.txt

___
Python tracker 

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



[issue4685] IDLE will not open (2.6.1 on WinXP pro)

2008-12-17 Thread Ilan

New submission from Ilan :

Hello,

I am new to programming... I installed Python a couple days ago with no
problems. I used it quite a bit since I'm going through loads of tutorials. 
All of a sudden, it shut off, closed and will no longer open. This
problem seems to be common, but none of the suggestions work.

I uninstalled it and re-installed it to no avail. The command line works
however.
Suggestions?

--
components: IDLE
messages: 77982
nosy: Yo
severity: normal
status: open
title: IDLE will not open (2.6.1 on WinXP pro)
versions: Python 2.6

___
Python tracker 

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



[issue4681] mmap offset should be off_t instead of ssize_t

2008-12-17 Thread Martin v. Löwis

Martin v. Löwis  added the comment:

This is different from bz2, though. In bzlib, there is no API to seek to
a certain position. In mmap, the offset type in mmap specified as off_t,
so fpos_t plays no role here.

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

FWIW, with the tuple optimization, the number of objects in
gc.get_objects() after the regression tests has fallen from 15 to
14.

___
Python tracker 

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



[issue1524639] Fix Tkinter Tcl-commands memory-leaks

2008-12-17 Thread Quentin Gallet-Gilles

Quentin Gallet-Gilles  added the comment:

A little remark : please replace "if not
globals().has_key('TkinterError'):" by "if 'TkinterError' not in
globals():". has_key is now deprecated in 2.6 and should be avoided.

--
nosy: +quentin.gallet-gilles
versions:  -Python 2.5

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

This new patch also adds a function named gc.is_tracked() which returns
True if the object is tracked by the GC:

>>> import gc
>>> gc.is_tracked(1)
False
>>> gc.is_tracked([])
True
>>> gc.is_tracked(())
True
>>> gc.is_tracked((0,1))
False
>>> gc.is_tracked((0,"a"))
False
>>> gc.is_tracked((0,[]))
True
>>> gc.is_tracked((0,(1,2)))
False
>>> gc.is_tracked((0,(1,0.55)))
False
>>> gc.is_tracked((0,(1,{})))
True
>>> gc.is_tracked((None, True, False, "a", (1,2,u"z",("another",
"nested", u"tuple")), int))
False
>>> gc.is_tracked(gc)
True


(as you see the empty tuple is considered tracked, this is not important
since it is a singleton anyway)

Added file: http://bugs.python.org/file12379/gctrigger3.patch

___
Python tracker 

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



[issue4686] Exceptions in ConfigParser don't set .args

2008-12-17 Thread David M. Beazley

New submission from David M. Beazley :

The ConfigParser module defines a variety of custom exceptions, many of 
which take more than one argument (e.g., InterpolationError, 
NoOptionError, etc.).   However, none of these exceptions properly set 
the .args attribute.   For example, shouldn't NoOptionError be defined 
as follows:

class NoOptionError(Error):
def __init__(self,option,section):
Error.__init__(self,"No option %r in section: %r" %
   (option,section))
self.option = option
self.section = section
self.args = (option,section)  #!! Added this line

This is kind of a minor point, but the missing args means that these 
exceptions don't work properly with programs that need to do fancy kinds 
of exception processing (i.e., catching errors and reraising them in a 
different context or process).

I can't speak for Python 3.0, but it's my understanding that .args 
should always be set to the exception arguments.

Don't ask how I came across this---it was the source of a really bizarre 
bug in something I was playing around with.

--
components: Library (Lib)
messages: 77983
nosy: beazley
severity: normal
status: open
title: Exceptions in ConfigParser don't set .args
type: behavior
versions: Python 2.1.1, Python 2.1.2, Python 2.2, Python 2.2.1, Python 2.2.2, 
Python 2.2.3, Python 2.3, Python 2.4, Python 2.5, Python 2.5.3, Python 2.6, 
Python 2.7, Python 3.0, Python 3.1

___
Python tracker 

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



[issue3439] create a numbits() method for int and long types

2008-12-17 Thread Mark Dickinson

Mark Dickinson  added the comment:

Committed to trunk in r67822, py3k in r67824.

--
status: open -> closed

___
Python tracker 

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



[issue4681] mmap offset should be off_t instead of ssize_t

2008-12-17 Thread Martin v. Löwis

Martin v. Löwis  added the comment:

> Ah, I think I'm beginning to understand.  Thanks for the explanation.  So, 
> if I understand correctly, I should refactor the patch and just remove all 
> of the Py_off_t and just use off_t because the standard says that *is* the 
> type.  Correct?

Correct.

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Here is a new patch adding tests for gc.is_tracked().

Added file: http://bugs.python.org/file12380/gctrigger4.patch

___
Python tracker 

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



[issue4682] 'b' formatter is actually unsigned char

2008-12-17 Thread vt

New submission from vt :

The 'b' format unit to PyArg_ParseTuple, PyArg_ParseTupleAndKeywords, and 
PyArg_Parse is described in the documentation (in Parsing arguments and 
building values) as representing a signed char, but actually represents an 
unsigned char.

Personally, I would say that this is a problem with the interpreter core, 
but 'b' has been an unsigned char since 2000 and fixing it now would 
probably break backwards compatibility of extensions.

--
assignee: georg.brandl
components: Documentation
messages: 77964
nosy: georg.brandl, vt
severity: normal
status: open
title: 'b' formatter is actually unsigned char

___
Python tracker 

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



[issue3439] create a numbits() method for int and long types

2008-12-17 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

32 bytes isn't worth sharing between modules.

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Changes by Antoine Pitrou :


Removed file: http://bugs.python.org/file11743/tuple_gc_hell.py

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

New version of Greg's script, with different choices (list of tuples,
list of lists, list of dicts, dict of tuples).

Added file: http://bugs.python.org/file12382/tuple_gc_hell.py

___
Python tracker 

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



[issue4681] mmap offset should be off_t instead of ssize_t

2008-12-17 Thread saa

saa  added the comment:

Ah, I think I'm beginning to understand.  Thanks for the explanation.  So, 
if I understand correctly, I should refactor the patch and just remove all 
of the Py_off_t and just use off_t because the standard says that *is* the 
type.  Correct?

___
Python tracker 

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



[issue4680] deque class should include high-water mark

2008-12-17 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Will think about it for a bit.  My initial inclination is against
because there have been no other such requests to instrument all the
fundamental data types, because it's not hard to add instrumentation
using your own pure python additions around size-mutating calls, because
it clutters the API, and because it's unclear whether a maximum-size
statistic has much utility.

For deques, should the clear() method zero-out the high-water mark?  How
about the equivalent code where the contents are all popped-off (down to
zero size) before the structure is re-used?

--
assignee:  -> rhettinger
title: Queue class should include high-water mark -> deque class should include 
high-water mark

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Now an additional patch which applies over the basic gctrigger4.patch.
It adds dict optimizations so that dicts with only atomic or immutable
elements are also untracked (they get tracked later when other trackable
elements are added).

Since dicts are often used as mappings of simple objects (int, str,
tuple) over other simple objects, this can be very useful.

Added file: http://bugs.python.org/file12383/dictopts.patch

___
Python tracker 

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



[issue4397] test_socket fails occassionaly in teardown: AssertionError: [Errno 57] Socket is not connected

2008-12-17 Thread Mark Dickinson

Mark Dickinson  added the comment:

Thanks for the report.  I can reproduce this both on the py3k branch and the 
trunk.  It looks as though there's a race condition 
in the testShutDown/_testShutDown pair of methods in SocketConnectedTest.  If 
you add the line

time.sleep(0.01)

to the middle of the _testShutDown method in test_socket.py (between the 
self.serv_conn.send() and the self.serv_conn.shutdown), 
you'll probably find that this random occasional failure becomes a 99.9% 
reliable failure.

As far as I can tell, this is just a bug in test_socket itself, rather than a 
problem with the socket module.  I also can't see 
any reason why it should be Mac specific, but I don't have anything else handy 
to test on right now.

Suggested fix:  don't let testShutDown exit until after _testShutdown has 
executed the shutdown method.  Use a threading Event to 
make this work.  The attached patch (against the trunk) appears to fix the 
problem for me.  Martina, if you're in a position to 
test the patch, feedback would be welcome.

It would be good if someone could review this for sanity;  I'm a complete 
novice when it comes to threading (and sockets, for that 
matter).

--
components:  -Library (Lib), Macintosh
keywords: +patch
nosy: +marketdickinson
priority:  -> normal
stage:  -> patch review
versions: +Python 2.6, Python 2.7, Python 3.1
Added file: http://bugs.python.org/file12384/issue4397.patch

___
Python tracker 

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



[issue4680] deque class should include high-water mark

2008-12-17 Thread Roy Smith

Roy Smith  added the comment:

I'm not actually sure what the use case is for clear().  It's easy
enough to just create a new deque.  If you can do that, why do you need
clear()?  Since I don't ever see a reason anybody would want to call
clear(), I'm not 100% if it should reset the high-water mark or not.  I
don't *think* it should, but I'm willing to believe that a use case
could exist which would make me change my mind about that.

Popping all the elements off the deque certainly should *not* reset the
high water mark.  The whole point of tracking the high water mark is to
know if the consumer thread ever fell behind the producer thread (yes, I
realize queues could be used for non-threading purposes).  It's
perfectly normal for the queue to drain completely at times, and there's
absolutely no reason this should affect the high-water mark.

You do raise a good question about whether all of the standard
containers should be instrumented.  I don't know the answer to that. 
Queues and, say, dicts are different beasts.  It's common to use queues
where the putting-in and taking-out are asynchronous, and thus the
high-water mark is an indicator of overall application health.  I don't
see that for dicts, or lists (well, maybe if used as a stack) or most
other kinds of containers.

___
Python tracker 

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



[issue4273] cycle created by profile.run

2008-12-17 Thread darrenr

darrenr  added the comment:

I think we still need to prevent collectable cycles in our Python code.
Here's the situation:

We've got a process that creates many Python objects, and it needs to be
responsive, it's not good for it to block on one operation for more than
100-200 ms. The automatic garbage collection is currently taking on the
order of 2 seconds for this process.

If we can guarantee that no collectable or non-collectable cycles are
being created, we can gradually increase the collection threshold, or
turn off the garbage collector entirely, reducing or eliminating the
blocking overhead of garbage collection.

___
Python tracker 

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



[issue2467] gc.DEBUG_STATS reports invalid "elapsed" times

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Fixed in r67832, thanks!

--
nosy: +pitrou
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed
versions: +Python 2.7 -Python 2.5, Python 2.6

___
Python tracker 

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



[issue1524639] Fix Tkinter Tcl-commands memory-leaks

2008-12-17 Thread Guilherme Polo

Guilherme Polo  added the comment:

I've fixed the leaks in Variable doing this:
http://code.google.com/p/plumage/source/detail?r=93

I don't use an extra _tclCommands for Variable, instead in __del__ I use
the information returned by Variable.trace_vinfo to remove associated
callbacks.

___
Python tracker 

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



[issue4687] GC stats not accurate because of debug overhead

2008-12-17 Thread Antoine Pitrou

New submission from Antoine Pitrou :

With gc.DEBUG_STATS, each GC collection displays the elapsed time.
Unfortunately, this elapsed time includes the debug overhead itself,
most notable the calls to gc_list_size() which can be quite expensive
with lots of objects in the older generation. Consequently, collections
of generation 0 will incorrectly appear as very expensive, while in
non-debug mode they are very cheap.

Here is a patch to get a more useful output, by not including the time
taken in gc_list_size().

--
components: Extension Modules
files: gc_stats_fix.patch
keywords: patch
messages: 77993
nosy: pitrou
priority: normal
severity: normal
stage: patch review
status: open
title: GC stats not accurate because of debug overhead
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file12385/gc_stats_fix.patch

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Changes by Antoine Pitrou :


Removed file: http://bugs.python.org/file12383/dictopts.patch

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Changes by Antoine Pitrou :


Removed file: http://bugs.python.org/file12353/gctrigger.patch

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Changes by Antoine Pitrou :


Removed file: http://bugs.python.org/file12378/gctrigger2.patch

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Changes by Antoine Pitrou :


Removed file: http://bugs.python.org/file12379/gctrigger3.patch

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Changes by Antoine Pitrou :


Removed file: http://bugs.python.org/file12380/gctrigger4.patch

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Cleanup: this patch only has the algorithmic change. Tuple and dict opts
will go to a separate tracker issue.

Added file: http://bugs.python.org/file12386/gctrigger5.patch

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Antoine Pitrou

New submission from Antoine Pitrou :

Split out from #4074, here is a standalone patch which disables GC
tracking for simple tuples (tuples made of atomic objects or immutable
containers, possibly nested). The performance improvement can be
evaluated using tuple_gc_hell.py from #4074.

The patch also adds a function named is_tracked() to the gc module.

--
components: Interpreter Core
files: tupleopts.patch
keywords: patch
messages: 77995
nosy: pitrou
priority: normal
severity: normal
stage: patch review
status: open
title: GC optimization: don't track simple tuples and dicts
type: performance
versions: Python 2.7, Python 3.1
Added file: http://bugs.python.org/file12387/tupleopts.patch

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

This additional patch also optimizes simple dicts, it must be applied
over the tuples patch.

Together these two patches make it so that e.g. a dict of tuples or
strings won't be tracked at all, saving CPU cycles when collecting.

--
nosy: +loewis
Added file: http://bugs.python.org/file12388/dictopts.patch

___
Python tracker 

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



[issue4074] Building a list of tuples has non-linear performance

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

The optimization issue for tuples and dicts is #4688.

___
Python tracker 

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



[issue4680] deque class should include high-water mark

2008-12-17 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

FWIW, here's a trivial Queue subclass with instrumentation:

class HighWaterQueue(Queue):

def _init(self, maxsize):
Queue.__init__(self, maxsize)
self.highwater = 0

def _put(self, item):
Queue._put(self, item)
self.highwater = max(self.highwater, self._qsize())

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

I've looked very quickly over your patches to try to figure what rule
qualifies a tuple or dict as simple enough to be untracked, out of
curiosity.

For tuples, I think the rule is:
If an object is immutable, and it points only to untracked objects,
the object can be untracked.

Is that right?  If so, you could perform the same optimization on the
frozenset() type.

Why do empty tuples have to be tracked?

The dict patch adds a boolean flag to the dict data structure to
indicate whether the dict is being tracked or not.  I think.  Couldn't
you use _PyObject_GC_IS_TRACKED() instead?

What's the rule for when a dict can be tracked or untracked?  Do you
need to recheck the rule every time the dict is modified?

--
nosy: +stutzbach

___
Python tracker 

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



[issue4689] Typo in PyObjC URL on "GUI Programming on the Mac"

2008-12-17 Thread Mark Evans

New submission from Mark Evans :

The "GUI Programming on the Mac" page:
  http://www.python.org/doc/2.5.3/mac/node10.html

states that the PyObjC project is at:
  http://pybojc.sourceforge.net

This is incorrect and should be:
  http://pyobjc.sourceforge.net

This appears fixed in the 2.6 and 3.0 documentation.

--
assignee: georg.brandl
components: Documentation
messages: 78000
nosy: georg.brandl, mevans
severity: normal
status: open
title: Typo in PyObjC URL on "GUI Programming on the Mac"
versions: Python 2.5, Python 2.5.3

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Le mercredi 17 décembre 2008 à 23:56 +, Daniel Stutzbach a écrit :
> For tuples, I think the rule is:
> If an object is immutable, and it points only to untracked objects,
> the object can be untracked.

Roughly, yes. Exactly, it is "if it points only to untrackable objects".
That is, a tuple containing an untracked dict will still be tracked,
because the dict may mutate and become tracked later. But a tuple
containing an untracked tuple will itself be untracked, because the
enclosed tuple can't mutate.

> Is that right?  If so, you could perform the same optimization on the
> frozenset() type.

Yes, but I prefer to concentrate on those two core types now, which are
the most frequent. Once the principle is accepted we can extend the
implementation to other types.

> Why do empty tuples have to be tracked?

Actually, they are never tracked, which means calling
_PyObject_GC_UNTRACK on them would segfault.

> The dict patch adds a boolean flag to the dict data structure to
> indicate whether the dict is being tracked or not.  I think.  Couldn't
> you use _PyObject_GC_IS_TRACKED() instead?

Yes, probably. I thought a dedicated flag may be faster but I will try
without.

> Do you
> need to recheck the rule every time the dict is modified?

Only if it is not tracked. Once a dict is tracked, it cannot become
untracked again (there would be too much overhead, and the assumption is
that you usually create homogeneous containers, you don't create a dict
of mutable containers things and then replace the mutable containers
with simple atomic objects).

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
nosy: +rhettinger

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

So, I've tried without the dedicated flag in the dict object and it's as
fast as previously! Here is a new patch.

Added file: http://bugs.python.org/file12389/dictopts2.patch

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Antoine Pitrou

Changes by Antoine Pitrou :


Removed file: http://bugs.python.org/file12388/dictopts.patch

___
Python tracker 

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



[issue4690] asyncore calls handle_write() on closed sockets when use_poll=True

2008-12-17 Thread Forest Wilkinson

New submission from Forest Wilkinson :

With use_poll=True on linux, asyncore calls handle_write() after the
socket has been closed.

More specifically, it looks like asyncore dispatches handle_read() and
handle_close() events between the writable() test and the corresponding
handle_write() call.  If handle_close() calls close(), as asyncore's
default implementation does, the subsequent handle_write() will fail and
generate an EBADF (bad file descriptor) exception.  If handle_error()
also calls close(), as asyncore's default implementation does, this will
mean close() gets called twice on the same socket.

I am attaching example code which demonstrates the problem on Linux
2.6.24 using python 2.5.2, 2.5.3rc1, and 2.6.  In one window, run
pollwritefail.py.  In another window, establish a TCP connection to port
12345 and immediately close it without reading or writing.  This can be
done from within the python interactive interpreter like this:

  import socket
  s=socket.socket( socket.AF_INET, socket.SOCK_STREAM); s.connect(
('localhost', 12345)); s.close()

The output from pollwritefail.py will look like this:

  writable() - asyncore asked if we have data to write
  handle_read() - asyncore asked us to read
  handle_close() - asyncore said the remote host closed connection
  close() - we are closing our end of the connection
  handle_write() - asyncore asked us to write
  handle_error() - asyncore exception: (9, 'Bad file descriptor')
  close() - we are closing our end of the connection

IMHO, two things need fixing here:

1. When writable() returns True, the next handler asyncore calls should
be handle_write().  Calling other handlers in between risks invalidating
the writable() return value.

2. After close(), asyncore should not call handle_write(), even if
writable() would return true.

--
components: Library (Lib)
files: pollwritefail.py
messages: 78003
nosy: forest
severity: normal
status: open
title: asyncore calls handle_write() on closed sockets when use_poll=True
type: behavior
versions: Python 2.5, Python 2.5.3, Python 2.6
Added file: http://bugs.python.org/file12390/pollwritefail.py

___
Python tracker 

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



[issue4621] zipfile returns string but expects binary

2008-12-17 Thread Eddie

Eddie  added the comment:

The error you got is caused by giving the wrong parameters. You gave a
ZipInfo object instead of a filename.

If you execute data = testzip.read(t1.filename) yo will have no problems.

--
nosy: +Eddie

___
Python tracker 

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



[issue4643] cgitb.html fails if getattr call raises exception

2008-12-17 Thread Allan Crooks

Allan Crooks  added the comment:

In terms of patching scanvars, I came up with the following solution:

ORIGINAL:
if parent is not __UNDEF__:
value = getattr(parent, token, __UNDEF__)
vars.append((prefix + token, prefix, value))

SOLUTION:
if parent is not __UNDEF__:
try:
value = getattr(parent, token, __UNDEF__)
except Exception:
value = __UNDEF__
vars.append((prefix + token, prefix, value))

I think this makes the most sense - it requires a small change, and it
won't have any strange side effect. One slightly undesirable aspect is
that for an attribute value which could not be determined (due to this
problem), it will say that it was "undefined", which isn't entirely
accurate.

My initial patch changed value to be a string to be "could not determine
value", but if the line of code looked like this:
print 'B:', weird.b.upper()

Then for something which shouldn't work, it would determine that the
value of weird.b.upper is the string method - which isn't what we're after.

So I would recommend my original patch (as described above) as the best
solution.

___
Python tracker 

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



[issue3110] Multiprocessing package build problem on Solaris 10

2008-12-17 Thread osvenskan

osvenskan  added the comment:

I'm facing the same problem (getting a good definition of SEM_VALUE_MAX)
for my posix_ipc extension. The patch presented here will get the
compiler to shut up on OpenSolaris, but not for the reason you think. At
least, that's the way I see it.

On OpenSolaris (2008.05 is what I'm testing with), _SEM_VALUE_MAX is
indeed #defined in sys/param.h, but it's inside this #ifdef on line 322:

#if (defined(_KERNEL) || defined(_KMEMUSER))

Since multiprocessing.c doesn't #define either of these, both
SEM_VALUE_MAX and _SEM_VALUE_MAX will remain undefined and so the patch
will always fall back to INT_MAX.

IMHO, given the choice between #defining _KERNEL or _KMEMUSER and
calling sysconf(_SC_SEM_VALUE_MAX), I feel safer doing the latter. 

I did a survey of all the operating systems to which I have access
(OpenSolaris 2008.05, OS X 10.5.5, RHEL?, Ubuntu 8.04, and FreeBSD 7).
OpenSolaris is the only one that doesn't #define SEM_VALUE_MAX, and on
all systems except for the possibly Red Hattish one,
sysconf(_SC_SEM_VALUE_MAX) returned the same value as the definition of
SEM_VALUE_MAX. I attached my code & results.

Added file: http://bugs.python.org/file12391/explore_sem_value_max.c

___
Python tracker 

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



[issue1524639] Fix Tkinter Tcl-commands memory-leaks

2008-12-17 Thread Guilherme Polo

Guilherme Polo  added the comment:

On Wed, Dec 17, 2008 at 3:51 PM, Guilherme Polo  wrote:
>
> Guilherme Polo  added the comment:
>
> Rethinking about the changes done in Misc._configure I found out that
> you don't need any of those there.
> Isn't it the case of only improving the changes regarding callable
> overwriting in Misc._options ? So if the value is a callable and the
> option doesn't exist you also don't _register the callable. Maybe I'm
> forgetting about something here, so you could bring an example that
> fails on this reasoning.

Uhm, this will fail in other places in Tkinter that are using _options
for handling options not related to widget options but specific
command options.

___
Python tracker 

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



[issue4680] deque class should include high-water mark

2008-12-17 Thread Roy Smith

Roy Smith  added the comment:

And, FWIW, I did figure out a use case for clear().  I create a queue and 
pass it to two threads.  One side or the other decides to abandon processing 
of the events currently in the queue.  I can't just create a new queue, 
because you have no way to tell the other thread about it.  You need to have 
clear() to do this.  And, no, it should not clear the high water mark.

As I see it, it comes down to this:

If you bury this in the C code inside deque(), it's very efficient compared 
to the Python wrapper class.  The downside is it makes the API larger than 
it would otherwise be, to satisfy a use case with limited demand.

If you feel the efficiency gain doesn't justify the added complexity in the 
API, I'm OK with that.  I just didn't want this shot down on the basis of, 
"He's asking us to invest the effort to write the code for something we 
don't see a need for", hence the offer to write it myself.  But, it's your 
call if you want it or not.

___
Python tracker 

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



[issue2944] asyncore doesn't handle connection refused correctly

2008-12-17 Thread Forest Wilkinson

Changes by Forest Wilkinson :


--
nosy: +forest

___
Python tracker 

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



[issue4680] deque class should include high-water mark

2008-12-17 Thread Tim Peters

Tim Peters  added the comment:

There's no need to keep asking -- this report was already rejected ;-)

Seriously, the efficiency argument carries no weight with me -- in 15
years of using Queue in a variety of applications, the time it takes to
.put and .get "here's a piece of work to do" descriptors is trivial
compared to the cost of /doing/ the "piece of work".  A Python-coded
subclass would have been plenty fast enough in any of those apps
(assuming I ever wanted to track a highwater mark, which to date I never
have).

--
nosy: +tim_one

___
Python tracker 

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



[issue4691] IDLE Code Caching Windows

2008-12-17 Thread Brandon Dixon

New submission from Brandon Dixon :

I made changes to my code and hit F5 to run it through IDLE. The code
appeared to run without any errors, but when I closed everything out and
ran it again it turned out to be full of errors.

I am able to replicate this problem with my code and have seen others
have the same problem, but its unclear when and what causes the caching
to take place. I created a test file that only contained "print hello".
I ran this, made changes and then ran it again. The changes were
reflected, but after testing my code, it still cached. 

Attached is a simple python file I used to test everything out. Run the
test, then comment out the Struct class and run it again. No errors
should appear, but if you close the code, reopen it and then run it
again it will error.

--
components: IDLE
files: bug-test.py
messages: 78010
nosy: brandon.dixon
severity: normal
status: open
title: IDLE Code Caching Windows
type: behavior
versions: Python 2.5, Python 2.6
Added file: http://bugs.python.org/file12392/bug-test.py

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Martin v. Löwis

Martin v. Löwis  added the comment:

IIUC, you try to find various places where tuples are created, and check
whether they create tuples that don't need tracking.

I think this approach is difficult to maintain, and also may miss some
objects.

I'd rather see that integrated into collection: e.g. when iterating over
survivors of a collection, check whether they can be untracked.

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

Unfortunately, the check is O(n), so it can get a little expensive.  I
suppose that's no worse than traversing the tuple to look for a cycle,
though.  Perhaps it could be done at the same time?

Can _PyObject_GC_UNTRACK() be safely called from tp_traverse?

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Martin v. Löwis

Martin v. Löwis  added the comment:

> Unfortunately, the check is O(n), so it can get a little expensive.

Not in the typical case, I guess. *If* you have to go through all
objects, then likely you end up untracking the object. If you can't
untrack, you typically find a tracked object in the content quickly.

> I suppose that's no worse than traversing the tuple to look for a cycle,
> though.  

Correct. Collection is O(n) per object, anyway.

> Perhaps it could be done at the same time?
> Can _PyObject_GC_UNTRACK() be safely called from tp_traverse?

No. However, I doubt that iterating over the object twice is
significantly slower than iterating over it once and performing
both checks. Plus, the check for tracked elements can return
as soon as one such object is found.

___
Python tracker 

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



[issue4688] GC optimization: don't track simple tuples and dicts

2008-12-17 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
nosy: +gregory.p.smith

___
Python tracker 

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



[issue4621] zipfile returns string but expects binary

2008-12-17 Thread Francesco Ricciardi

Francesco Ricciardi  added the comment:

If that is what is requested, then the manual entry for ZipFile.read
must be corrected, because it states:

"ZipFile.read(name[, pwd])  name is the name of the file in the
archive, or a ZipInfo object."


However, Eddie, you haven't tried what you suggested, because this is
what you would get:

>>> import zipfile
>>> testzip = zipfile.ZipFile('test.zip')
>>> t1 = testzip.infolist()[0]
>>> t1.filename
'tést.xml'
>>> data = testzip.read(t1.filename)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python30\lib\zipfile.py", line 843, in read
return self.open(name, "r", pwd).read()
  File "C:\Python30\lib\zipfile.py", line 883, in open
% (zinfo.orig_filename, fname))
zipfile.BadZipfile: File name in directory 'tést.xml' and header
b't\x82st.xml' differ.

___
Python tracker 

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