[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-05 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

Thanks Tim. I see that is back in 3.2 rather than in the shift and mask
sections. At least I know what to refer to now.

--

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



[issue7441] Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001.

2009-12-05 Thread Lie Ryan

New submission from Lie Ryan lie.1...@gmail.com:

maybe related to #6501

Vista 32-bit SP1, Python 3.1:

Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
D:\chcp 65001
Active code page: 65001

D:\python -c 'print()'
Fatal Python error: Py_Initialize: can't initialize sys standard streams
LookupError: unknown encoding: cp65001

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
D:\python
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit
(Intel)] on win32
Type help, copyright, credits or license for more information.



Expected, either:
1. print nothing (), or
2. python exception about unknown encoding, or
3. python exception about cannot encode to the encoding

cp65001 is supposed to be an alias for utf-8. Because of the error,
there is AFAICT no way to set the command prompt to accept utf-8 output
even for pipe redirection.

A workaround is to use sys.stdout.buffer.write() to write raw byte
strings, encoding manually. But this takes us back to python 2.

--
components: IO, Interpreter Core, Unicode, Windows
messages: 95987
nosy: lieryan
severity: normal
status: open
title: Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001.
type: crash
versions: Python 3.1

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



[issue7442] decimal.py: format failure with locale specifier

2009-12-05 Thread Stefan Krah

New submission from Stefan Krah stefan-use...@bytereef.org:

Hi, the following works in 2.7 but not in 3.x:

 import locale
 from decimal import *
 locale.setlocale(locale.LC_NUMERIC, 'fi_FI')
'fi_FI'
 format(Decimal('1000'), 'n')
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python3.2/decimal.py, line 3632, in __format__
spec = _parse_format_specifier(specifier, _localeconv=_localeconv)
  File /usr/lib/python3.2/decimal.py, line 5628, in
_parse_format_specifier
_localeconv = _locale.localeconv()
  File /usr/lib/python3.2/locale.py, line 111, in localeconv
d = _localeconv()
ValueError: Cannot convert byte to string

--
messages: 95988
nosy: mark.dickinson, skrah
severity: normal
status: open
title: decimal.py: format failure with locale specifier
versions: Python 3.1, Python 3.2

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



[issue7441] Py3.1: Fatal Python Error: Py_Initialize...unknown encoding: chcp 65001.

2009-12-05 Thread flox

flox la...@yahoo.fr added the comment:

there's a patch proposed to add cp65001 alias: issue6058

--
nosy: +flox

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



[issue6058] Add cp65001 to encodings/aliases.py

2009-12-05 Thread flox

Changes by flox la...@yahoo.fr:


--
versions: +Python 2.6, Python 3.1, Python 3.2

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



[issue6472] Inconsistent use of iterator in ElementTree doc diff between Py and C modules

2009-12-05 Thread Milko Krachounov

Milko Krachounov pyt...@milko.3mhz.net added the comment:

This isn't just a documentation issue. A function named getiterator(),
for which the docs say that it returns an iterator, should return an
iterator, not just an iterable. They have different semantics and can't
be used interchangeably, so the behaviour of getiterator() in
ElementTree is wrong. I was using this in my program:

iterator = element.getiterator()
next(iterator)
subelement = next(iterator)

Which broke when I tried switching to ElementTree from cElementTree,
even though the docs tell me that I'll get an iterator there.

Also, for findall() and friends, is there any reason why we can't stick
to either an iterator or list, and not both? The API will be more clear
if findall() always returned a list, or always an iterator, regardless
of the implementation. It is currently not clear what will happen if I do:

for x in tree.findall(path):
 mutate_tree(tree, x)

--
components: +Library (Lib)
nosy: +milko.krachounov
type:  - behavior
versions: +Python 2.6, Python 2.7

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



[issue7443] test.support.unlink issue on Windows platform

2009-12-05 Thread Andrew Svetlov

New submission from Andrew Svetlov andrew.svet...@gmail.com:

On Windows there are tiny delay between call to os.unlink and real file 
removing. Periodically it leads to unittest crashes in cases like this:

test.support.unlink(filename)
f = open(filename, 'wb')

Proposed solution: wait in support.unlink for end of deletion asking 
os.stat for removed file (only if os.name == 'nt', of course).

Also test.test_linecache:LineCacheTests.test_checkcache should be fixed 
- this one miss to close last opened file and Windows cannot remove it.

Both patches for trunk and py3k is attached.

--
components: Tests, Windows
files: python3.patch
keywords: patch
messages: 95991
nosy: asvetlov
severity: normal
status: open
title: test.support.unlink issue on Windows platform
type: behavior
versions: Python 2.7, Python 3.2
Added file: http://bugs.python.org/file15454/python3.patch

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



[issue7443] test.support.unlink issue on Windows platform

2009-12-05 Thread Andrew Svetlov

Andrew Svetlov andrew.svet...@gmail.com added the comment:

patch for python 2 is attached

--
Added file: http://bugs.python.org/file15455/python2.patch

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



[issue7443] test.support.unlink issue on Windows platform

2009-12-05 Thread Andrew Svetlov

Andrew Svetlov andrew.svet...@gmail.com added the comment:

Problem can be reproduced with several run of test_bufio in both python 
versions. trunk contains more tests (+1 test case) so it's easer to catch 
'access denied' exception on it.

--

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



[issue7444] Allow for a default method in the JSON decoder

2009-12-05 Thread Daniel Goldman

New submission from Daniel Goldman goldman.in...@gmail.com:

I encountered JavaScript-style Date objects in a JSON document that I 
wanted to parse, and these objects were causing the Python JSON decoder 
to raise an error with a message that said Expecting object, followed 
by the line and column numbers. Here is an example of how such an object 
appeared in the document:

someDate: new Date(120756820),

I went looking in the documentation for a way to plug in a fall-back 
method, to be used when the module's standard conversion methods fail, 
but none of the supplied hooks seemed appropriate.

It would be enormously helpful to provide a hook for such a method in 
the JSON decoder in a future release of Python. I believe this would 
parallel the JSON encoder's default keyword argument. In this way, 
developers could provide their own method of handling non-standard 
values in JSON documents.

Ultimately, to parse the Date objects, I created a function similar to 
those in the json.decoder module, added the function to the 
json.decoder.ANYTHING list, and assigned a new Scanner object with this 
updated list to json.decoder.JSONScanner.

I couldn't find a similar issue in the issues list, but my apologies if 
this has already been suggested.

--
components: Library (Lib)
messages: 95994
nosy: dhgoldman
severity: normal
status: open
title: Allow for a default method in the JSON decoder
type: feature request
versions: Python 2.7, Python 3.2

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



[issue7445] urllib2 (and urllib) should raise error for incomplete response

2009-12-05 Thread Chris Lasher

New submission from Chris Lasher chris.las...@gmail.com:

This question is motivated by a question on Stack Overflow:
http://stackoverflow.com/questions/1824069/urllib2-not-retrieving-entire-http-response

In the event the user receives an incomplete response when using urllib2
(and urllib), the library should raise an error to indicate the response
is incomplete. This is a matter of checking if the Content-Length
defined in the header matches the size of the retrieved response. While
this can be done by the user, an exception will help alert the more
unwitting, such as myself, by failing early.

--
components: Library (Lib)
messages: 95995
nosy: gotgenes
severity: normal
status: open
title: urllib2 (and urllib) should raise error for incomplete response
type: behavior

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



[issue6472] Inconsistent use of iterator in ElementTree doc diff between Py and C modules

2009-12-05 Thread flox

Changes by flox la...@yahoo.fr:


--
nosy: +flox

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



[issue7435] Int/Long: some tests are duplicate and error messages refer to long

2009-12-05 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Looks fine to me.  I'd probably keep MyInt rather than MyLong in 
Lib/test/pickletester.py, and Int 
rather than Long in Lib/test/test_getargs2.py, but that's just a matter of 
renaming.

I note the major deletions in test_long;  maybe the remaining tests in 
test_long should be moved 
from there to test_int?

With this patch, all tests pass for me on OS X 10.6.

Eric, this patch affects a bunch of formatting tests, particularly in 
Lib/test/test_types.py;  I 
don't know whether you're trying to keep trunk and py3k formatting tests 
synchronized for ease of 
maintenance.  Are you?

--

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



[issue7444] Allow for a default method in the JSON decoder

2009-12-05 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
assignee:  - bob.ippolito
nosy: +bob.ippolito

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



[issue7439] Bug or expected behavior? I cannot tell.

2009-12-05 Thread Matthew Barnett

Matthew Barnett pyt...@mrabarnett.plus.com added the comment:

The problem with the shorthand form is that the generators use the
values that are bound to 'a' and 'p' when they are iterated, not when
they are created. You can test this by inserting:

a = X

just before the assert: you'll get a TypeError later on.

You need something like this:

m = []
for (a,p,) in ((2,p2),(3,p3),(5,p5)):
def gen(a=a, p=p):
return (a*x for x in p)
m.append(gen(a, p))

--
nosy: +mrabarnett

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



[issue6472] Inconsistent use of iterator in ElementTree doc diff between Py and C modules

2009-12-05 Thread flox

flox la...@yahoo.fr added the comment:

There's many differences between both implementations.
I don't know if we can live with them or not.

~ $ ./python 
Python 3.1.1+ (release31-maint:76650, Dec  3 2009, 17:14:50) 
[GCC 4.3.2] on linux2
Type help, copyright, credits or license for more information.
 from xml.etree import ElementTree as ET, cElementTree as cET
 from io import StringIO
 SAMPLE = 'root/'
 IO_SAMPLE = StringIO(SAMPLE)


With ElementTree

 elt = ET.XML(SAMPLE)
 elt.getiterator()
[Element root at 15cb920]
 elt.findall('')  # or '.'
[Element root at 15cb920]
 elt.findall('./')
[Element root at 15cb920]
 elt.items()
dict_items([])
 elt.keys()
dict_keys([])
 elt[:]
[]
 IO_SAMPLE.seek(0)
 next(ET.iterparse(IO_SAMPLE))
('end', Element root at 15d60d0)
 IO_SAMPLE.seek(0)
 list(ET.iterparse(IO_SAMPLE))
[('end', Element root at 15583e0)]


With cElementTree

 elt_c = cET.XML(SAMPLE)
 elt_c.getiterator()
generator object getiterator at 0x15baae0
 elt_c.findall('')
[]
 elt_c.findall('./')
[Element 'root' at 0x15cf3a0]
 elt_c.items()
[]
 elt_c.keys()
[]
 elt_c[:]
Traceback (most recent call last):
TypeError: sequence index must be integer, not 'slice'
 IO_SAMPLE.seek(0)
 next(cET.iterparse(IO_SAMPLE))
Traceback (most recent call last):
TypeError: iterparse object is not an iterator
 IO_SAMPLE.seek(0)
 list(cET.iterparse(IO_SAMPLE))
[(b'end', Element 'root' at 0x15cf940)]

--

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



[issue7406] int arithmetic relies on C signed overflow behaviour

2009-12-05 Thread Gregory P. Smith

Changes by Gregory P. Smith g...@krypto.org:


--
nosy: +gregory.p.smith

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



[issue7439] Bug or expected behavior? I cannot tell.

2009-12-05 Thread David W. Lambert

David W. Lambert b49p23t...@stny.rr.com added the comment:

Thank you!

A prime sieve variant is a better way to generate the generalized
Hamming numbers I'm after, at least if the maximum is known ahead of
time.

Dave Lambert

--

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



[issue7444] Allow for a default method in the JSON decoder

2009-12-05 Thread Bob Ippolito

Bob Ippolito b...@redivi.com added the comment:

If it had JavaScript style Date objects in it, it wasn't a JSON document.

While it may be easy enough to do this in the version that happens to be 
included with Python, the optimizations in later versions of simplejson 
make this no longer possible. You'd have to change a bunch of C and Python 
code to parse that. There are fewer function calls and regular expressions 
for efficiency reasons. It's not simplejson's goal to be able to parse 
non-JSON documents.

--
resolution:  - wont fix

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



[issue7444] Allow for a default method in the JSON decoder

2009-12-05 Thread Bob Ippolito

Changes by Bob Ippolito b...@redivi.com:


--
status: open - closed

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



[issue7435] Int/Long: some tests are duplicate and error messages refer to long

2009-12-05 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

 Eric, this patch affects a bunch of formatting tests, particularly
 in Lib/test/test_types.py;  I don't know whether you're trying to
 keep trunk and py3k formatting tests synchronized for ease of
 maintenance.  Are you?

No, I've basically given up on keeping the tests in sync. The
implementations are the same but not the tests.

--

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



[issue7438] Allow to use a part of subprocess module during building Python

2009-12-05 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
keywords: +needs review
priority:  - low
stage:  - patch review
type:  - behavior

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



[issue7439] Bug or expected behavior? I cannot tell.

2009-12-05 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
resolution:  - invalid
status: open - closed

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



[issue7443] test.support.unlink issue on Windows platform

2009-12-05 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
keywords: +needs review
priority:  - low
stage:  - patch review

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



[issue7443] test.support.unlink issue on Windows platform

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

Martin v. Löwis mar...@v.loewis.de added the comment:

I'm fairly skeptical that your analysis is right. Can you prove that a
file still exists after unlink returns?

--
nosy: +loewis

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



[issue5672] Implement a way to change the python process name

2009-12-05 Thread Daniele Varrazzo

Daniele Varrazzo p...@develer.com added the comment:

I wrote a wrapper around the PostgreSQL implementation of setproctitle 
(probably the most portable around). I've only tested it on Linux: 
probably will require tweaking constants to compile on other platforms 
(something postgres does at configure time) but the core functionality 
is surely well tested.

I've put the module on http://code.google.com/p/py-setproctitle/ : 
testing (yes, there is an unit test) and tweaking setup on other 
platforms is welcome.

--
nosy: +piro

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



[issue7435] Int/Long: some tests are duplicate and error messages refer to long

2009-12-05 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Patch applied in r76681 (I took the liberty of doing the MyLong - MyInt 
and Long - Int renames).  Many thanks, flox!

--
resolution:  - accepted
stage:  - committed/rejected
status: open - closed

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



[issue7446] http.cookies.BaseCookie (and SimpleCookie) can't be load from dict

2009-12-05 Thread Thomas Courbon

New submission from Thomas Courbon hart...@yahoo.fr:

Hi there !

According the documentation [1], the following code should work :
 from http.cookies import SimpleCookie
 c = SimpleCookie({'field1': 'value1', 'field2': 'value2'})
 print(c)
'Set-Cookie: field1=value1\r\nSet-Cookie: field2=value2'

But an exception is raised : 
Traceback (most recent call last):
  File stdin, line 1, in module
  File c:\python31\lib\http\cookies.py, line 507, in output
result.append( V.output(attrs, header) )
AttributeError: 'str' object has no attribute 'output'

in BaseCookie.load(...) the call to BaseCookie.update(rawdata) seem to
use dict.__setitem__ instead of BaseCookie.__setitem__.

Despite it's weird (I believe that the __setitem__ of the child class
should be used) I don't know why.

I don't have a solution to this underlying issue so I propose to define
an update method for BaseCookie:
def update(self, other=None, **kwargs):
if other is None:
other = kwargs
elif not hasattr(other, 'items'):
other = dict(other)
for k, v in other.items():
self[k] = v

This method behave like the dict one.

Hope it help and it's not a duplicate.

Regards,
Thomas


[1] :
http://docs.python.org/3.1/library/http.cookies.html#http.cookies.BaseCookie.load

--
components: Library (Lib)
messages: 96007
nosy: tcourbon
severity: normal
status: open
title: http.cookies.BaseCookie (and SimpleCookie) can't be load from dict
versions: Python 3.1

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



[issue7442] decimal.py: format failure with locale specifier

2009-12-05 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

This fails in _localemodule.c: str2uni(). mbstowcs(NULL, s, 0) is
LC_CTYPE sensitive, but LC_CTYPE is UTF-8 in my terminal.

If I set LC_CTYPE and LC_NUMERIC together, things work.

This raises the question: If LC_CTYPE and LC_NUMERIC differ (and
since they are separate entities I assume they may differ), what
is the correct way to convert the separator and the decimal point?


a) call setlocale(LC_CTYPE, setlocale(LC_NUMERIC, NULL)) before
   mbstowcs. This is not really an option.


b) use some kind of _mbstowcs_l
(http://msdn.microsoft.com/en-us/library/k1f9b8cy(VS.80).aspx), which
takes a locale parameter. But I don't
find such a thing on Linux.

--

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



[issue7446] http.cookies.BaseCookie (and SimpleCookie) can't be load from dict

2009-12-05 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

This was already corrected with issue5275. Thanks however for the report.

--
nosy: +amaury.forgeotdarc
resolution:  - out of date
status: open - closed
superseder:  - BaseCookie.load doesn't create Morsel objects for mappings

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

.endswith() is a good alternative to [-2:] ==

--
nosy: +benjamin.peterson

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



[issue7434] pprint doesn't know how to print a namedtuple

2009-12-05 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

You could make all namedtuples inherit from a common base class, e.g.
`BaseNamedTuple`.

--
nosy: +pitrou

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



[issue7443] test.support.unlink issue on Windows platform

2009-12-05 Thread Andrew Svetlov

Andrew Svetlov andrew.svet...@gmail.com added the comment:

You right, problem is not in os.unlink (Windows call DeleteFile) itself.

I have TortoiseSVN (very popular Explorer extension to work with 
Subversion) installed. 
This tool run TSVNCache.exe process to update own data in background.
TSVNCache.exe receive NotifyChangeDirectory events for svn checkout 
folders. 
support.TESTFN is tempfile name in current working directory. If I try 
to run unittests from some folder from python checkout TSVNCache.exe get 
change notify and analyze it.

So, sometimes I can see race condition:
- python: os.unlink(file)
- TSVNCache.exe: get change event
- TSVNCache.exe: query changes
- python: open(file) - oops, TSVNCache.exe still processing notification 
and lock deleted file by holding opened handles to it.
According to MSDN for DeleteFile function:
The DeleteFile function marks a file for deletion on close. Therefore, 
the file deletion does not occur until the last handle to the file is 
closed. Subsequent calls to CreateFile to open the file fail with 
ERROR_ACCESS_DENIED.
We get exactly same.
- TSVNCache.exe finish of change update and release handle. File is 
actually deleted.

I see this situation in sysinternals Process Monitor tool.
Probability of race condition is tiny but non-zero. Intensive 
create/drop/create again sequences can catch this one.

--

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



[issue7447] Sum() doc and behavior mismatch

2009-12-05 Thread Terry J. Reedy

New submission from Terry J. Reedy tjre...@udel.edu:

sum(iterable[, start]) 
Sums start and the items of an iterable from left to right and returns
the total. start defaults to 0. The iterable‘s items are normally
numbers, and are not allowed to be strings.

The last sentence is not currently true (3.1, assume also others).
It is the start value that cannot be a string.

 sum([1,2],'')
TypeError: sum() can't sum strings [use ''.join(seq) instead]

sum(['xyz', 'pdq'], Zero()) # R Hettinger's universal zero class
'xyzpdq'
works because start is not a string

 sum(['a','b'])
TypeError: unsupported operand type(s) for +: 'int' and 'str'
passes type(start) != str and only fails because + fails.

I am filing this as a doc issue as the easiest fix for the discrepancy
between doc and behavior. But the fix could be a behavior change, though
certain to be controversial. Given that, my  suggested revision is:
The iterable‘s items are normally numbers. The start value is not
allowed to be a string.

I think this fits the followup sentence: The fast, correct way to
concatenate a sequence of strings...

--
assignee: georg.brandl
components: Documentation
messages: 96013
nosy: georg.brandl, tjreedy
severity: normal
status: open
title: Sum() doc and behavior mismatch
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2

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



[issue7434] pprint doesn't know how to print a namedtuple

2009-12-05 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

We need a more generic solution that allows multi-line reprs for a
variety of types.  Here is an example that doesn't involve named tuples:

 pprint(s, width=15)
[OrderedDict([('x', 300), ('y', 40), ('z', 50)]),
 OrderedDict([('x', 60), ('y', 7000), ('z', 80)])]

What we want is to have it print like regular dictionaries do:

 pprint([dict(p) for p in s], width=15)
[{'x': 300,
  'y': 40,
  'z': 50},
 {'x': 60,
  'y': 7000,
  'z': 80}]

It would also be nice if pprint could accept arguments telling it how to
format various types:

 pprint(s, width=15, format={int: '15,'})
[{'x': ' 30,000,000,000',
  'y': '  4,000,000,000',
  'z': '  5,000,000,000'},
 {'x': '  6,000,000,000',
  'y': ' 70,000,000',
  'z': '  8,000,000,000'}]

--

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



[issue1578269] Add os.link() and os.symlink() and os.path.islink() support for Windows

2009-12-05 Thread Andrew Svetlov

Andrew Svetlov andrew.svet...@gmail.com added the comment:

Jason, as I see you implemented os.samefile (actually ntpath.samefile) 
but  os.sameopenfile is still not implemented.

Looks like it's easy to do: while GetFinalPathNameByHandle already 
accept file handle you can use CRT function _get_osfhandle(fd) to 
convert file descriptors (arguments for sameopenfile) to file handles 
and pass it to GetFinalPathNameByHandle.

For me samefile and sameopenfile has very close semantic and I like to 
see both if it's possible.

Thanks.

--
nosy: +asvetlov

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



[issue5985] Implement os.path.samefile and os.path.sameopenfile on Windows

2009-12-05 Thread Andrew Svetlov

Andrew Svetlov andrew.svet...@gmail.com added the comment:

Please note: patch for http://bugs.python.org/issue1578269 is already has 
implementation for samefile. It's easer to add sameopenfile is same way 
than maintain two different approaches.

Unfortunately solution will work only starting from Windows Vista and 
Windows Server 2008.

--
nosy: +asvetlov

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



[issue6727] ImportError when package is symlinked on Windows

2009-12-05 Thread Andrew Svetlov

Changes by Andrew Svetlov andrew.svet...@gmail.com:


--
nosy: +asvetlov

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Scott Dial

Scott Dial sc...@scottdial.com added the comment:

Alright, I am attaching a new patch to correct the brain-fart
inefficiency of slicing versus endswith().

I don't understand why this is so difficult to review. I don't think
Janssen is the right person to have been assigned to this. While it is
related to SSL, I don't think the IMAP module is even on his radar.
Whereas, I use this module everyday, every 10 minutes every day to fetch
my email (via getmail), and can assure you that the 110 character change
is correct.

--
Added file: http://bugs.python.org/file15456/imaplib-r76683.patch

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Scott Dial

Changes by Scott Dial sc...@scottdial.com:


Removed file: http://bugs.python.org/file15013/imaplib-r75166.patch

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Rest assured it has little to do with the difficultly of reviewing it.
Rather we are all volunteers. Do you think a test would be easy to write
for this?

--
assignee: janssen - 

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Scott Dial

Scott Dial sc...@scottdial.com added the comment:

Ben, I understand that we are all volunteers here. My frustration in the
lack of a de facto owner of the imaplib module and not with you
personally or any other committer for that matter.

As it is, there is no unittests for the imaplib module, and I am not in
a position to provide a complete implementation of an IMAP server.
However, I have attached a simple script demonstrating the issue. An
unpatched trunk will infinite loop, consuming memory, and a patched
version will throw a Traceback immediately.

--
Added file: http://bugs.python.org/file15457/imaplib-eof-test.py

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



[issue7316] Add a timeout functionality to common locking operations

2009-12-05 Thread Andrew Svetlov

Changes by Andrew Svetlov andrew.svet...@gmail.com:


--
nosy: +asvetlov

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



[issue5596] memory leaks in py3k

2009-12-05 Thread Andrew Svetlov

Changes by Andrew Svetlov andrew.svet...@gmail.com:


--
nosy: +asvetlov

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Scott Dial

Scott Dial sc...@scottdial.com added the comment:

I found myself in the mood to code, so in the spirit of every step
counts, I have attached a patch that updates test_imaplib accordingly.
The construction of the test framework is based loosely on test_ssl and
test_socketserver. If someone felt so moved to add more test cases, then
one would could simply extend SimpleIMAPHandler to handle more IMAP
commands.

FYI, as previously noted, on an unpatch trunk test_issue5949() is an
infinite loop.

--
Added file: http://bugs.python.org/file15458/test_imaplib-r76683.patch

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Scott Dial

Changes by Scott Dial sc...@scottdial.com:


Added file: http://bugs.python.org/file15459/test_imaplib-r76683.patch

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Scott Dial

Changes by Scott Dial sc...@scottdial.com:


Removed file: http://bugs.python.org/file15458/test_imaplib-r76683.patch

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Scott Dial

Changes by Scott Dial sc...@scottdial.com:


Added file: http://bugs.python.org/file15460/test_imaplib-r76683.patch

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



[issue5949] IMAP4_SSL spin because of SSLSocket.suppress_ragged_eofs

2009-12-05 Thread Scott Dial

Changes by Scott Dial sc...@scottdial.com:


Removed file: http://bugs.python.org/file15459/test_imaplib-r76683.patch

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