[issue7004] Py_RETURN_BOOL() convenience macro

2009-09-27 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

-1. What's wrong with writing

   return PyBool_FromLong(x);

--
nosy: +loewis

___
Python tracker 

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



[issue7004] Py_RETURN_BOOL() convenience macro

2009-09-27 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

I agree with Martin; PyBool_FromLong is sufficient.

--
nosy: +benjamin.peterson
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



[issue7006] The replacement suggested for callable(x) in py3k is not equivalent

2009-09-27 Thread Milko Krachounov

New submission from Milko Krachounov :

hasattr(x, '__call__') has been suggested as a replacement for
callable(x) in the documentation and in the warning when running
python2.6 with -3. It is also what 2to3 replaces it with. However, the
two are not equivalent.

1. I can add a __call__ attribute to my object with "obj.__call__ =
lambda x:x". That will not make the object callable, callable() on
Python 2.6 returns False, but hasattr(obj, '__call__') returns True.
2. I can implement a __getattr__ that returns something for every
possible attribute name. Again, this doesn't make the object callable,
nor does callable(obj) in Python 2.6 return True.

I think a closer replacement for "callable(x)" would be "'__call__' in
vars(type(x))".

--
assignee: georg.brandl
components: 2to3 (2.x to 3.0 conversion tool), Documentation, Interpreter Core
messages: 93171
nosy: georg.brandl, milko.krachounov
severity: normal
status: open
title: The replacement suggested for callable(x) in py3k is not equivalent
type: behavior
versions: Python 2.6, 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



[issue6071] no longer possible to hash arrays

2009-09-27 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> The first thing the function does is checking if the object implements 
> the old buffer api, but also fails if pb->bf_releasebuffer != NULL. So I 
> guess it's also making sure the new buffer api is not implemented.
> 
> What's the thought behind this?

The idea is that if a type implements the bf_releasebuffer function, it
shouldn't be used in a situation where the caller won't try to release
the buffer.

It looks a bit unwarranted though, because a type implementing the old
buffer API should be able to function without the releasing anyway.
Otherwise it wouldn't implement that API at all.

Martin, ISTR you did that addition, would you be opposed to removing the
NULL check on bf_releasebuffer when trying to get a buffer through the
old buffer API?

--

___
Python tracker 

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



[issue1745] Backport of PEP 3102 "keyword-only arguments" to 2.6

2009-09-27 Thread Éric Araujo

Changes by Éric Araujo :


--
nosy: +Merwok

___
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-09-27 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis  added the comment:

I can still reproduce this test failure after applying patch from
r74638. I use Gentoo ~amd64.

--
nosy: +Arfrever
title: test test_telnetlib failed -> test_debuglevel from test_telnetlib.py 
fails

___
Python tracker 

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



[issue6393] OS X: python3 from python-3.1.dmg crashes at startup

2009-09-27 Thread Svetoslav Agafonkin

Svetoslav Agafonkin  added the comment:

There is an error in r74687 (3.x) and r74688 (3.1) fixes - in the 'else' 
clause there should be 'return result' at the end.

--
nosy: +slavi
status: pending -> open

___
Python tracker 

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



[issue7006] The replacement suggested for callable(x) in py3k is not equivalent

2009-09-27 Thread Ezio Melotti

Ezio Melotti  added the comment:

In the PEP3100 [1] there's written, in the "to be removed" list:
  "callable(): just use hasattr(x, '__call__') (?) [2] [done]"
and the note refers to a pdf [2] that instead says:
  "callable(): just call it, already"

If callable() was removed to encourage the EAFP [3] style, replacing "if
callable(x):" with "if hasattr(x, '__call__'):" is just a less-accurate
and less-readable way of doing the same (wrong) thing [4] (also note the
(?) next to the hasattr() expression).

This might be OK for automated tools like 2to3, but not for the doc and
the warning. Humans should probably replace the expression with a
try/except instead of using hasattr().
Even for 2to3 there are better and more accurate solutions though, like
the one proposed by the OP (not really readable) and isinstance(x,
collections.Callable).

(Note: what the OP said is correct for new-style classes, for old-style
classes callable() and hasattr() have the same result).

[1]: http://www.python.org/dev/peps/pep-3100/
[2]: Python Regrets:
http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.pdf
[3]: http://docs.python.org/glossary.html#term-eafp
[4]: http://docs.python.org/glossary.html#term-lbyl

--
nosy: +ezio.melotti
priority:  -> normal

___
Python tracker 

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



[issue6713] Integer & Long types: Performance improvement of 1.6x to 2x for base 10 conversions

2009-09-27 Thread Mark Dickinson

Mark Dickinson  added the comment:

Committed int_decimal_conversion_trunk.patch in r75084.  Thanks, Gawain.

--
resolution:  -> accepted
stage: patch review -> committed/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



[issue5931] Python runtime name hardcoded in wsgiref.simple_server

2009-09-27 Thread Thijs Triemstra

Thijs Triemstra  added the comment:

Here's a patch that uses platform.python_implementation instead, 
producing:

>>> from wsgiref import simple_server
>>> simple_server.software_version
'WSGIServer/0.1 CPython/2.7a0'
>>> 

This will become relevant when Jython and IronPython start using these 
modules.

--
keywords: +patch
Added file: http://bugs.python.org/file14986/wsgiref.patch

___
Python tracker 

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



[issue7006] The replacement suggested for callable(x) in py3k is not equivalent

2009-09-27 Thread Milko Krachounov

Milko Krachounov  added the comment:

My suggestion is not only unreadable, but wrong. It's even less accurate
than hasattr(x, '__call__'), as it doesn't look in all the classes in
the MRO. Using isinstance(x, collections.Callable) should probably be
the correct replacement for 2to3 and situation where checking this is
really needed, as it does look for __call__ in the whole MRO.

--

___
Python tracker 

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



[issue4887] environment inspection and manipulation API is buggy, inconsistent with "Python philosophy" for wrapping native APIs

2009-09-27 Thread Éric Araujo

Changes by Éric Araujo :


--
nosy: +Merwok

___
Python tracker 

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



[issue7007] Tiny inconsistency in the orthography of "url encoded" in the doc of urllib.parse

2009-09-27 Thread Mitchell Model

New submission from Mitchell Model :

The documentation of urllib.parse contains:
URL encoded
a “url-encoded” string
I am not sure what the official usage is, either in Python or more 
generally. Actually, in formal W3C documents the term used is percent-
encoding (with the hyphen, even when used as a noun). I don't expect 
anyone to use "percent-encoding" but maybe, especially as an adjective, 
the phrase in Python documentation should consistently be "url-encoded"?

--
messages: 93179
nosy: MLModel
severity: normal
status: open
title: Tiny inconsistency in the orthography of "url encoded" in the doc of 
urllib.parse
versions: Python 3.0, Python 3.1, Python 3.2

___
Python tracker 

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



[issue7008] str.title() misbehaves with apostrophes

2009-09-27 Thread Nick Devenish

New submission from Nick Devenish :

str.title() capitalizes the first letter after an apostrophe:

>>> "This isn't right".title()
"This Isn'T Right"

The library function string.capwords, which appears to have exactly the
same responsibility, doesn't exhibit this behavior:

>>> string.capwords("This isn't right")
"This Isn't Right"

Tested on 2.6.2 on Mac OS X

--
messages: 93180
nosy: nickd
severity: normal
status: open
title: str.title() misbehaves with apostrophes
type: behavior
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



[issue6956] Test creation in unittest.TestProgram should be done in one place

2009-09-27 Thread Michael Foord

Michael Foord  added the comment:

Committed in revision 75095.

--
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



[issue6515] http://docs.python.org/dev/library/unittest.html#load-tests-protocol doesn't make it clear when load_tests support was introduced

2009-09-27 Thread Michael Foord

Michael Foord  added the comment:

Committed revision 75098. Re-open if you think this isn't sufficient.

--
resolution:  -> accepted
status: open -> closed

___
Python tracker 

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



[issue7005] ConfigParser does not handle options without values

2009-09-27 Thread Fred L. Drake, Jr.

Changes by Fred L. Drake, Jr. :


--
nosy: +fdrake

___
Python tracker 

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



[issue7005] ConfigParser does not handle options without values

2009-09-27 Thread Fred L. Drake, Jr.

Fred L. Drake, Jr.  added the comment:

The test "value is not None" in line 620 (of the new version) could be
just "value" and get a little more value from less code.

I don't think I've ever run across a sample .ini-style file that used
unspecified values, though it's frequently done in "flat" configuration
files.

Have you come across an existing configuration format that uses the
[section] markers and unspecified values, or is this really a new use-case?

--

___
Python tracker 

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



[issue6606] csv.Sniffer.sniff on data with doublequotes doesn't set up the dialect properly

2009-09-27 Thread Thomas W. Barr

Thomas W. Barr  added the comment:

I'm not actually sure where we go from here. This is my first attempted 
patch to this project, and I was hoping that someone else would be more 
knowledgeable about the process;-)

--

___
Python tracker 

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



[issue6971] Add the SIO_KEEPALIVE_VALS option to socket.ioctl

2009-09-27 Thread Kristján Valur Jónsson

Kristján Valur Jónsson  added the comment:

Ported to py3k in revision 75100

--

___
Python tracker 

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



[issue7004] Py_RETURN_BOOL() convenience macro

2009-09-27 Thread Jon Parise

Jon Parise  added the comment:

I agree, as well.

I didn't consider PyBool_FromLong() because I was expecting to solve the
problem using a macro, but that is clearly not the best approach here
(insignificant function call overhead aside).

--

___
Python tracker 

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



[issue6606] csv.Sniffer.sniff on data with doublequotes doesn't set up the dialect properly

2009-09-27 Thread R. David Murray

R. David Murray  added the comment:

Thomas, is the patch you uploaded to rietveld the same as the patches
attached to the ticket?  If so, Skip can just ignore the rietveld and
work from the patch files. Rietveld is really more useful for reviews of
longer patches than this one; for patches this size we generally just
use the tracker.

--
nosy: +r.david.murray
priority:  -> normal

___
Python tracker 

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



[issue6606] csv.Sniffer.sniff on data with doublequotes doesn't set up the dialect properly

2009-09-27 Thread Thomas W. Barr

Thomas W. Barr  added the comment:

Got it. Yes, they're the same patch.

--

___
Python tracker 

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



[issue6606] csv.Sniffer.sniff on data with doublequotes doesn't set up the dialect properly

2009-09-27 Thread Skip Montanaro

Skip Montanaro  added the comment:

Applied to trunk as rev 75102.

--
resolution:  -> accepted
status: open -> closed

___
Python tracker 

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



[issue7009] random.randint docs

2009-09-27 Thread James G. sack (jim)

New submission from James G. sack (jim) :

Docs for 2.6.2 (http://docs.python.org/library/random.html?
highlight=random#module-random)
presently say
"""
random.randint(a, b)
Return a random integer N such that a <= N <= b.
"""

It should say
...a <= N < b

I wonder if there are other mistakes there in upper limit docs?

~jim

--
assignee: georg.brandl
components: Documentation
messages: 93190
nosy: georg.brandl, jgsack
severity: normal
status: open
title: random.randint docs
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



[issue6963] Add worker process lifetime to multiprocessing.Pool - patch included

2009-09-27 Thread Charles Cazabon

Changes by Charles Cazabon :


Removed file: http://bugs.python.org/file14947/worker-lifetime-python2.6.2.patch

___
Python tracker 

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



[issue6963] Add worker process lifetime to multiprocessing.Pool - patch included

2009-09-27 Thread Charles Cazabon

Charles Cazabon  added the comment:

Updated patch attached; handles some of the Pool methods that weren't
handled before.  Now includes documentation and unit test additions as well.

--
Added file: http://bugs.python.org/file14987/worker-lifetime-python2.6.2.patch

___
Python tracker 

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



[issue7009] random.randint docs

2009-09-27 Thread Senthil Kumaran

Senthil Kumaran  added the comment:

Not actually a bug. The documentation is correct.
Do, random.randint(0,1) a couple of times and you see 1 appearing.
If still not convinced, look into the random.py see that randint(a, b)
actually does a return self.randrange(a, b+1)

--
nosy: +senthil.kumaran
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