[issue5728] Support telling TestResult objects a test run has finished

2009-04-11 Thread Robert Collins

Robert Collins  added the comment:

I've written up a patch for this; it works with old result classes too.

Hopefully the bugtracker will attach it in reply to this mail; if not
I'll put in via the webui this evening.

-Rob

--
keywords: +patch
Added file: http://bugs.python.org/file13669/start-stop-TestRun.patch

___
Python tracker 

___=== modified file 'Lib/test/test_unittest.py'
--- Lib/test/test_unittest.py   2009-04-05 19:19:28 +
+++ Lib/test/test_unittest.py   2009-04-10 08:54:32 +
@@ -6,6 +6,7 @@
 TestCase.{assert,fail}* methods (some are tested implicitly)
 """
 
+from StringIO import StringIO
 import re
 from test import test_support
 import unittest
@@ -25,10 +26,18 @@
 self._events.append('startTest')
 super(LoggingResult, self).startTest(test)
 
+def startTestRun(self):
+self._events.append('startTestRun')
+# super(LoggingResult, self).startTestRun(test)
+
 def stopTest(self, test):
 self._events.append('stopTest')
 super(LoggingResult, self).stopTest(test)
 
+def stopTestRun(self):
+self._events.append('stopTestRun')
+# super(LoggingResult, self).stopTestRun(test)
+
 def addFailure(self, *args):
 self._events.append('addFailure')
 super(LoggingResult, self).addFailure(*args)
@@ -1816,6 +1825,12 @@
 self.assertEqual(result.testsRun, 1)
 self.assertEqual(result.shouldStop, False)
 
+# "Called before and after tests are run. The default implementation does 
nothing."
+def test_startTestRun_stopTestRun(self):
+result = unittest.TestResult()
+result.startTestRun()
+result.stopTestRun()
+
 # "addSuccess(test)"
 # ...
 # "Called when the test case test succeeds"
@@ -1963,6 +1978,53 @@
 class Bar(Foo):
 def test2(self): pass
 
+class LoggingTestCase(unittest.TestCase):
+"""A test case which logs its calls."""
+
+def __init__(self, events):
+super(LoggingTestCase, self).__init__('test')
+self.events = events
+
+def setUp(self):
+self.events.append('setUp')
+
+def test(self):
+self.events.append('test')
+
+def tearDown(self):
+self.events.append('tearDown')
+
+class ResultWithNoStartTestRunStopTestRun(object):
+"""An object honouring TestResult before startTestRun/stopTestRun."""
+
+def __init__(self):
+self.failures = []
+self.errors = []
+self.testsRun = 0
+self.skipped = []
+self.expectedFailures = []
+self.unexpectedSuccesses = []
+self.shouldStop = False
+
+def startTest(self, test):
+pass
+
+def stopTest(self, test):
+pass
+
+def addError(self, test):
+pass
+
+def addFailure(self, test):
+pass
+
+def addSuccess(self, test):
+pass
+
+def wasSuccessful(self):
+return True
+
+
 
 ### /Support code for Test_TestCase
 
@@ -2057,21 +2119,32 @@
 events = []
 result = LoggingResult(events)
 
-class Foo(unittest.TestCase):
+class Foo(LoggingTestCase):
 def setUp(self):
-events.append('setUp')
+super(Foo, self).setUp()
 raise RuntimeError('raised by Foo.setUp')
 
-def test(self):
-events.append('test')
-
-def tearDown(self):
-events.append('tearDown')
-
-Foo('test').run(result)
+Foo(events).run(result)
 expected = ['startTest', 'setUp', 'addError', 'stopTest']
 self.assertEqual(events, expected)
 
+# "With a temporary result stopTestRun is called when setUp errors.
+def test_run_call_order__error_in_setUp_default_result(self):
+events = []
+
+class Foo(LoggingTestCase):
+def defaultTestResult(self):
+return LoggingResult(self.events)
+
+def setUp(self):
+super(Foo, self).setUp()
+raise RuntimeError('raised by Foo.setUp')
+
+Foo(events).run()
+expected = ['startTestRun', 'startTest', 'setUp', 'addError',
+'stopTest', 'stopTestRun']
+self.assertEqual(events, expected)
+
 # "When a setUp() method is defined, the test runner will run that method
 # prior to each test. Likewise, if a tearDown() method is defined, the
 # test runner will invoke that method after each test. In the example,
@@ -2083,20 +2156,32 @@
 events = []
 result = LoggingResult(events)
 
-class Foo(unittest.TestCase):
-def setUp(self):
-events.append('setUp')
-
+class Foo(LoggingTestCase):
 def test(self):
-events.append('test')
+super(Foo, self).test()
 raise 

[issue4977] test_maxint64 fails on 32-bit systems due to assumption that 64-bit fits into "long"

2009-04-11 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Closing since I haven't seen any sign of such failures on a 64-bit build.

--
resolution:  -> works for me
status: open -> closed

___
Python tracker 

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



[issue5729] Allows tabs for indenting JSON output

2009-04-11 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
assignee:  -> bob.ippolito
nosy: +bob.ippolito
priority:  -> normal
stage:  -> patch review
versions: +Python 2.7

___
Python tracker 

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



[issue4753] Faster opcode dispatch on gcc

2009-04-11 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy:  -marketdickinson

___
Python tracker 

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



[issue5723] Incomplete json tests

2009-04-11 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Hi,

> I don't think the decorator approach would work for the doctests, it looks 
> like it could be an interesting approach though. I have a feeling that 
> it's going to have to be done in some kind of ugly subclass though, I'll 
> dig into unittest deeper this weekend to see how that might be done.

Doctests will be annoying indeed. I never use doctests so I can't
suggest you anything.
As for standard unit tests, the common idiom is something like:

class JSONEncodingTests:
def test_encode1(self):
self.assertEquals(self.encode("foo"), "bar")
# etc.

class CJSONEncodingTests(JSONEncodingTests, unittest.TestCase):
encode = json.c_encode

class PyJSONEncodingTests(JSONEncodingTests, unittest.TestCase):
encode = json.py_encode

(I'm CC'ing you since bugs.python.org looks down)

Regards

Antoine.

--

___
Python tracker 

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



[issue5722] settimer / gettimer functionality on FreeBSD 6.3 (not 7.x)

2009-04-11 Thread Andrew I MacIntyre

Andrew I MacIntyre  added the comment:

I've just built (using ./configure; make) 3.1a on FreeBSD 6.4 amd64.
libpthread is used by the resulting binary, not libc_r, according to ldd.

I would expect then that explicit action is required to use libc_r, and
given that FreeBSD people have indicated that it is deprecated and no
fixes are likely to be made, I would suggest documenting this as a
"don't do that" (ie use -lc_r) and close this as "won't fix".

The README file in the root of the source tree would seem an appropriate
place for such documentation, though I note that there appears to be a
lot of out of date information in there already...

--
nosy: +aimacintyre

___
Python tracker 

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



[issue5724] 2.6.2c1 fails to pass test_cmath on Solaris10

2009-04-11 Thread Mark Dickinson

Mark Dickinson  added the comment:

Sorry for the late reply: I've been away for a few days.

This looks like the same problem as issue 4575, so
should already be fixed in the trunk and py3k.  It
looks as though I never got around to backporting the
fix to 2.6 (or 3.0).  I'll do that today.

--
assignee: barry -> marketdickinson

___
Python tracker 

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



[issue5725] process SysV-Semaphore support

2009-04-11 Thread jvdias

jvdias  added the comment:

Thanks for responding !

I also think that the the Solaris Python should provide support for prctl .
Well, actually in modern Solaris what can be achieved with "prctl"
can be achieved my mmap()-ping and manipulating the procfs(4) mounted under 
/proc - 
but yes, what I meant was not that process-scope semaphore support
was required to solve the problem solved in the example code for this bug 
report -
actually, there are many other ways of doing that on either Linux or Solaris,
such as with rlimit(1) - but was only that, had process-scope semaphore support 
been available in Python , then the algorithm used by the example would have 
been 
a simple and robust one and suitable for use in Python code ;  but as the 
application 
the example code was originally part of required process-scope semaphores 
anyway , 
and for many other reasons, such as when a process is killed with -9, its 
semaphore
count is automatically adjusted by specifying the SEM_UNDO option, meaning 
another 
"slot" is available, this was the best among several methods investigated .  

Actually, the example code I submitted for this bug report also raises another, 
completely separate issue, which is that any parent using Python fork() MUST 
somehow do a 
fflush() of its standard output and error C stdio file descriptors before doing 
so ; otherwise
the child's first Python "print " statement is prefixed by what was in the 
parent's stdio buffer,
so that more than one initial "log" line can occasionally appear if Python 
"print" is used to
produce the log - but if the parent does 'print "\n"' immediately before 
calling "fork()" 
then both processes proceed with clean buffers and there are no doubled log 
lines . 
Can't Python provide a better print() implementation or a fflush() 
implementation
that will enable print()'s buffers to be flushed ? Perhaps something like 
PERL's IO::Handle::autoflush() ?

Maybe I should raise another "fflush() support required" bug ?

Thanks & Regards,
Jason 

On Thursday 09 April 2009 19:31:31 you wrote:
> 
> R. David Murray  added the comment:
> 
> In issue5672 Martin said:
> 
>   If somebody would provide a patch that adds prctl to the posix module,
>   that would be fine with me - we have a long tradition of exposing all
>   available system calls if somebody wants them.
> 
> However, you are talking about a System V call, not a posix call, so
> it's not clear to me if the same rules apply.
> 
> I suggest bringing this up on python-ideas.
> 
> (BTW, sys is for python system stuff, not OS system stuff (which goes in
> the 'os' module).
> 
> --
> components: +Library (Lib) -Interpreter Core
> nosy: +r.david.murray
> priority:  -> low
> versions:  -Python 2.6, Python 3.0
> 
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue5724] 2.6.2c1 fails to pass test_cmath on Solaris10

2009-04-11 Thread Mark Dickinson

Mark Dickinson  added the comment:

Here's a patch that backports the corresponding changes from trunk.

Skip, can you confirm that this fixes the issue?

--
keywords: +patch
Added file: http://bugs.python.org/file13670/issue5724.patch

___
Python tracker 

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



[issue5724] 2.6.2c1 fails to pass test_cmath on Solaris10

2009-04-11 Thread Mark Dickinson

Mark Dickinson  added the comment:

Just to say, I'm a bit uncomfortable with a patch this large going into a 
release candidate.  It's all code that's been backported from 2.7, so it 
*should* be okay, but I really don't want to be responsible for breaking 
2.6.2.

The test failure that Skip reports *is* due to a bug, but the bug is 
platform-specific (only affects x86 platforms where the math library 
doesn't have isinf or isnan---in practice, that's only Solaris/x86), and 
it's a bug in a somewhat obscure corner case (overflow in cmath.acosh) 
that's not likely to affect many people.

I don't think the (small, I hope) risk of breaking a release candidate is 
worth the (even smaller, IMO) benefit from fixing this bug.  If Skip 
confirms that the patch works, I'd suggest that it can wait for 2.6.3.

Assigning back to Barry for pronouncement.

--
assignee: marketdickinson -> barry

___
Python tracker 

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



[issue5734] BufferedRWPair broken

2009-04-11 Thread Brian Quinlan

New submission from Brian Quinlan :

The C implementation:
- doesn't correctly initialize its reader and writer instances
- incorrectly maps its "readinto" method to another class
- incorrectly delegates its "closed" property to its base class

i.e. this class can't be used at all

The Python implementation:
- Calls internal methods of its constructor arguments that aren't
  part of the IOBase interface to determine if its streams are 
  readable/writable

There aren't any useful tests for either.

--
files: rwpair.diff
keywords: patch
messages: 85849
nosy: bquinlan
severity: normal
status: open
title: BufferedRWPair broken
versions: Python 3.1
Added file: http://bugs.python.org/file13671/rwpair.diff

___
Python tracker 

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



[issue5734] BufferedRWPair broken

2009-04-11 Thread Brian Quinlan

Changes by Brian Quinlan :


--
components: +Library (Lib)
type:  -> behavior

___
Python tracker 

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



[issue5734] BufferedRWPair broken

2009-04-11 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Hey, thanks a lot for caring. I'll take a look at the patch and come
back later.
If you want to add some more tests, you are welcome too :-)

--
assignee:  -> pitrou
nosy: +pitrou
priority:  -> release blocker
stage:  -> patch review

___
Python tracker 

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



[issue5698] pydoc -w doesn't produce proper HTML

2009-04-11 Thread Georg Brandl

Georg Brandl  added the comment:

I fixed the DOCTYPE in trunk/3k r71443/71444, and the encoding issue in
3k only, because there the encoding is well-defined, in r71445.

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



[issue5733] py3_test_grammar.py syntax error

2009-04-11 Thread Georg Brandl

Georg Brandl  added the comment:

I think this file is only meant as a test that 2to3 can parse both 2.x
and 3.x syntax, not Python itself.

--
nosy: +georg.brandl
resolution:  -> wont fix
status: open -> pending

___
Python tracker 

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



[issue5735] Segfault when loading not recompiled module

2009-04-11 Thread Leonid Vasilev

New submission from Leonid Vasilev :

I compiled two versions of python(both from main trunk)

Here's what I do:
$cd /usr/local/src/Python-3.0.1/
$./configure
$make && make install
...
$cd ~/pyext/
$python3.0 setup.py install
...
"run python3.0 and import ext1 -- it worked ok"
...
$cd /usr/local/src/Python-3.0.1
$mkdir debug
$cd debug
$./../configure --with-pydebug
$make
$./python
...
Try to import a ext1, and got a Segfault

Backtrace from gdb:
(gdb) backtrace
#0  0xb7e9b1cb in strlen () from /lib/i686/cmov/libc.so.6
#1  0x0807c06d in PyUnicodeUCS2_FromString (u=0x ) at ./../Objects/unicodeobject.c:553
#2  0x0816251a in PyModule_New (name=0x ) at ./../Objects/moduleobject.c:39
#3  0x0816282d in PyModule_Create2 (module=0xb7fd26a0,
module_api_version=1013) at ./../Objects/moduleobject.c:106
#4  0xb7fd14b8 in PyInit_ext1 () at ext1.c:40
#5  0x080cfda0 in _PyImport_LoadDynamicModule (name=0xbf9f8a17 "ext1",
pathname=0xbf9f798f "/usr/local/lib/python3.0/site-packages/ext1.so",
fp=0x9a18ef8)
at ./../Python/importdl.c:57
#6  0x080cc226 in load_module (name=0xbf9f8a17 "ext1", fp=0x9a18ef8,
buf=0xbf9f798f "/usr/local/lib/python3.0/site-packages/ext1.so", type=3,
loader=0x0)
at ./../Python/import.c:1807
#7  0x080ce236 in import_submodule (mod=0x81b8d4c, subname=0xbf9f8a17
"ext1", fullname=0xbf9f8a17 "ext1") at ./../Python/import.c:2601
#8  0x080cd7b6 in load_next (mod=0x81b8d4c, altmod=0x81b8d4c,
p_name=0xbf9f9a30, buf=0xbf9f8a17 "ext1", p_buflen=0xbf9f8a10) at
./../Python/import.c:2406
#9  0x080ccbdf in import_module_level (name=0x0, globals=0xb7e10714,
locals=0xb7e10714, fromlist=0x81b8d4c, level=0) at ./../Python/import.c:2123
#10 0x080ccfc7 in PyImport_ImportModuleLevel (name=0x9a057f0 "ext1",
globals=0xb7e10714, locals=0xb7e10714, fromlist=0x81b8d4c, level=0)
at ./../Python/import.c:2174
#11 0x0809f65f in builtin___import__ (self=0xb7df6ce4, args=0xb7df7a9c,
kwds=0x0) at ./../Python/bltinmodule.c:173
#12 0x08161e56 in PyCFunction_Call (func=0xb7df6dfc, arg=0xb7df7a9c,
kw=0x0) at ./../Objects/methodobject.c:84
#13 0x081179c1 in PyObject_Call (func=0xb7df6dfc, arg=0xb7df7a9c,
kw=0x0) at ./../Objects/abstract.c:2161
#14 0x080b1806 in PyEval_CallObjectWithKeywords (func=0xb7df6dfc,
arg=0xb7df7a9c, kw=0x0) at ./../Python/ceval.c:3313
#15 0x080ac71c in PyEval_EvalFrameEx (f=0x9a3105c, throwflag=0) at
./../Python/ceval.c:1995
#16 0x080b03fa in PyEval_EvalCodeEx (co=0x9983ec8, globals=0xb7e10714,
locals=0xb7e10714, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
defcount=0, 
kwdefs=0x0, closure=0x0) at ./../Python/ceval.c:2869
#17 0x080a562b in PyEval_EvalCode (co=0x9983ec8, globals=0xb7e10714,
locals=0xb7e10714) at ./../Python/ceval.c:526
#18 0x080dcb68 in run_mod (mod=0x9a78d68, filename=0x819ff60 "",
globals=0xb7e10714, locals=0xb7e10714, flags=0xbf9faf70, arena=0x99126d8)
at ./../Python/pythonrun.c:1686
#19 0x080dadf1 in PyRun_InteractiveOneFlags (fp=0xb7f81420,
filename=0x819ff60 "", flags=0xbf9faf70) at
./../Python/pythonrun.c:1081
#20 0x080da953 in PyRun_InteractiveLoopFlags (fp=0xb7f81420,
filename=0x819ff60 "", flags=0xbf9faf70) at
./../Python/pythonrun.c:993
#21 0x080da7ab in PyRun_AnyFileExFlags (fp=0xb7f81420,
filename=0x819ff60 "", closeit=0, flags=0xbf9faf70) at
./../Python/pythonrun.c:962
#22 0x080ec7a7 in Py_Main (argc=1, argv=0xb7de3028) at
./../Modules/main.c:625
#23 0x0805a75b in main (argc=1, argv=0xbf9fb0b4) at ./../Modules/python.c:70

--
assignee: tarek
components: Build, Distutils, Installation
files: ext1.c
messages: 85853
nosy: chin, tarek
severity: normal
status: open
title: Segfault when loading not recompiled module
type: crash
versions: Python 3.0
Added file: http://bugs.python.org/file13672/ext1.c

___
Python tracker 

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



[issue5730] setdefault speedup

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

Martin v. Löwis  added the comment:

> By the way, defaultdict is NOT like setdefault--it is like get().
> Missing entries do no get set.

Why do you say that?

__missing__(...)
__missing__(key) # Called by __getitem__ for missing key; pseudo-code:
if self.default_factory is None: raise KeyError((key,))
self[key] = value = self.default_factory()
return value

In all cases of setdefault that I know of, replacing this with
a defaultdict would be appropriate. The only case where it wouldn't
work is if the default value depends on the key.

> What do you think?

If no speedup can be demonstrated, we should not change it.

--

___
Python tracker 

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



[issue5724] 2.6.2c1 fails to pass test_cmath on Solaris10

2009-04-11 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue5733] py3_test_grammar.py syntax error

2009-04-11 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Quite correct.

--
nosy: +benjamin.peterson
resolution: wont fix -> invalid
status: pending -> closed

___
Python tracker 

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



[issue5736] Add the iterator protocol to dbm modules

2009-04-11 Thread Akira Kitada

New submission from Akira Kitada :

In Python 2.6, dbm modules othar than bsddb don't support the iterator
protocol.

>>> import dbm
>>> d = dbm.open('spam.dbm', 'c')
>>> for k in range(5): d["key%d" % k] = "value%d" % k
... 
>>> for k in d: print k, d[k]
... 
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'dbm.dbm' object is not iterable

Adding iterator support would make dbm modules more convenient and
easier to use.

--
components: Extension Modules
messages: 85856
nosy: akitada
severity: normal
status: open
title: Add the iterator protocol to dbm modules
type: feature request
versions: Python 2.7

___
Python tracker 

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



[issue5733] py3_test_grammar.py syntax error

2009-04-11 Thread Kurt B. Kaiser

Kurt B. Kaiser  added the comment:

So the error during libinstall should be ignored

http://docs.python.org/dev/results/make-install.out

--

___
Python tracker 

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



[issue5724] 2.6.2c1 fails to pass test_cmath on Solaris10

2009-04-11 Thread Skip Montanaro

Skip Montanaro  added the comment:

Mark> Here's a patch that backports the corresponding changes from
Mark> trunk.

Mark> Skip, can you confirm that this fixes the issue?

Indeed, your patch appears to fix the problem:

% LD_LIBRARY_PATH=. ./python Lib/test/regrtest.py -v test_cmath
test_cmath
test_abs (test.test_cmath.CMathTests) ... ok
test_cmath_matches_math (test.test_cmath.CMathTests) ... ok
test_constants (test.test_cmath.CMathTests) ... ok
test_input_type (test.test_cmath.CMathTests) ... ok
test_isinf (test.test_cmath.CMathTests) ... ok
test_isnan (test.test_cmath.CMathTests) ... ok
test_phase (test.test_cmath.CMathTests) ... ok
test_polar (test.test_cmath.CMathTests) ... ok
test_rect (test.test_cmath.CMathTests) ... ok
test_specific_values (test.test_cmath.CMathTests) ... ok
test_user_object (test.test_cmath.CMathTests) ... ok

--
Ran 11 tests in 0.063s

OK
1 test OK.

I'll leave it to you and Barry to consider if the patch is too hefty for
backport.

Skip

--

___
Python tracker 

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



[issue5736] Add the iterator protocol to dbm modules

2009-04-11 Thread Akira Kitada

Akira Kitada  added the comment:

Attached is a patch that adds the iterator protocol.
Now it can be interated through like:

>>> for k in d: print k, d[k]
... 
key1 vale1
key3 vale3
key0 vale0
key2 vale2
key4 vale4

The problem is there is no way to get the internal pointer back to the
start. So Once it reached to the end, you are done.

>>> for k in d: print k, d[k]
...

The solution to this would be:
- Add a method to get the pointer back to the start
  (with {first,next}key API)
- Add a method that returns a generator

--
keywords: +patch
Added file: http://bugs.python.org/file13673/issue5736.diff

___
Python tracker 

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



[issue5724] 2.6.2c1 fails to pass test_cmath on Solaris10

2009-04-11 Thread Skip Montanaro

Skip Montanaro  added the comment:

FWIW, with the patch applied all tests still pass on Mac OS X 10.5.6
(Intel).

S

--

___
Python tracker 

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



[issue5354] Add test.support.import_python_only

2009-04-11 Thread Nick Coghlan

Nick Coghlan  added the comment:

Ended up going for a slightly more general name "import_fresh_module".
Reason being, test_warnings *also* wanted a fresh version of the
accelerated module along with a pure Python version - it seemed silly to
only factor out half of the problem into a support function, when the
support function could handle both tasks fairly easily.

So I implemented a version of the fresh import function that blocks no
extension modules by default, but still accepts a list of names to be
disabled during the import.

--

___
Python tracker 

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



[issue5354] Add test.support.import_python_only

2009-04-11 Thread Nick Coghlan

Nick Coghlan  added the comment:

Implemented for 2.7 in r71465
Implemented for 3.1 in r7146

Leaving issue open for the moment - the 3.1 test_warnings fails if I
don't get a fresh copy of _warnings before running the unit tests. I
want to figure out why that is necessary before closing the issue.

--

___
Python tracker 

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



[issue5354] Add test.support.import_python_only

2009-04-11 Thread Nick Coghlan

Changes by Nick Coghlan :


--

___
Python tracker 

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



[issue5354] Add test.support.import_python_only

2009-04-11 Thread Nick Coghlan

Nick Coghlan  added the comment:

Implemented for 2.7 in r71465
Implemented for 3.1 in r71469

Leaving issue open for the moment - the 3.1 test_warnings fails if I
don't get a fresh copy of _warnings before running the unit tests. I
want to figure out why that is necessary before closing the issue.

--

___
Python tracker 

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



[issue5732] add a new command called "check" into Distutils

2009-04-11 Thread Tarek Ziadé

Tarek Ziadé  added the comment:

'check' added in r71473 and r71473

Now working on sdist and register so they use it.

--

___
Python tracker 

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



[issue5502] io-c: TextIOWrapper is faster than BufferedReader but not protected by a lock

2009-04-11 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Committed in r71483.

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



[issue5733] ignore py3_test_grammar.py syntax error

2009-04-11 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Oh, indeed. I wonder what the best way to do that is?

--
assignee: collinwinter -> 
resolution: invalid -> 
status: closed -> open
title: py3_test_grammar.py syntax error -> ignore py3_test_grammar.py syntax 
error

___
Python tracker 

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



[issue5736] Add the iterator protocol to dbm modules

2009-04-11 Thread Akira Kitada

Akira Kitada  added the comment:

Revised patch adds firstkey and nextkey to dbm.
Now the internal pointer can be reset with firstkey.

--
Added file: http://bugs.python.org/file13674/issue5736.diff

___
Python tracker 

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



[issue5737] add Solaris errnos

2009-04-11 Thread Matthew Ahrens

New submission from Matthew Ahrens :

The "errno" module does not contain some error names/numbers that are
used on Solaris.  Please add them.

from /usr/include/sys/errno.h:

#define ECANCELED 47/* Operation canceled   */
#define ENOTSUP 48  /* Operation not supported  */

/* Interprocess Robust Locks */
#define EOWNERDEAD  58  /* process died with the lock */
#define ENOTRECOVERABLE 59  /* lock is not recoverable */
#define ELOCKUNMAPPED   72  /* locked lock was unmapped */
#define ENOTACTIVE 73   /* Facility is not active   */

--
components: Library (Lib)
messages: 85868
nosy: mahrens
severity: normal
status: open
title: add Solaris errnos
type: feature request
versions: Python 2.4, Python 3.0

___
Python tracker 

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



[issue1751245] Popen pipe file descriptor leak on OSError in init

2009-04-11 Thread Kuang-che Wu

Kuang-che Wu  added the comment:

this is duplicated to issue 5179 and is fixed in trunk

--
nosy: +kcwu

___
Python tracker 

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



[issue5734] BufferedRWPair broken

2009-04-11 Thread Brian Quinlan

Brian Quinlan  added the comment:

Hey Antoine,

Will do - but first I'll finish up my reason for needing a working
version of this class in the first place ;-)

Cheers,
Brian

--

___
Python tracker 

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



[issue4753] Faster opcode dispatch on gcc

2009-04-11 Thread Alexandre Vassalotti

Changes by Alexandre Vassalotti :


--
nosy:  -alexandre.vassalotti

___
Python tracker 

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



[issue1751245] Popen pipe file descriptor leak on OSError in init

2009-04-11 Thread Benjamin Peterson

Changes by Benjamin Peterson :


--
resolution:  -> duplicate
status: open -> closed

___
Python tracker 

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



[issue5733] ignore py3_test_grammar.py syntax error

2009-04-11 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Should be fixed in r71494.

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



[issue5354] Add test.support.import_python_only

2009-04-11 Thread Brett Cannon

Brett Cannon  added the comment:

On Sat, Apr 11, 2009 at 07:28, Nick Coghlan  wrote:

>
> Nick Coghlan  added the comment:
>
> Implemented for 2.7 in r71465
> Implemented for 3.1 in r7146
>

Style nit: why the extra check for block_names being None to later set it to
an empty tuple? Why not make the default argument the empty tuple?

>
> Leaving issue open for the moment - the 3.1 test_warnings fails if I
> don't get a fresh copy of _warnings before running the unit tests. I
> want to figure out why that is necessary before closing the issue.

Might have to do with _warnings trying to import warnings for certain things
in certain cases.

And just something I thought about, Nick, is possibly coming up with a class
decorator that sets self.module on the class. This could have the perk of
taking an optional argument that checks if the optimized module is even in
existence so as to skip running the tests twice if it is not needed. Then
again this might over-optimizing and best to just let the tests run twice
even if it is not needed.

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

___
Python tracker 

___On Sat, Apr 11, 2009 at 07:28, Nick Coghlan 
rep...@bugs.python.org> 
wrote:


Nick Coghlan ncogh...@gmail.com> 
added the comment:

Implemented for 2.7 in r71465
Implemented for 3.1 in r7146
Style nit: why the extra check for block_names being None 
to later set it to an empty tuple? Why not make the default argument the empty 
tuple? 


Leaving issue open for the moment - the 3.1 test_warnings fails if I
don't get a fresh copy of _warnings before running the unit tests. I
want to figure out why that is necessary before closing the 
issue.Might have to do with _warnings trying to import 
warnings for certain things in certain cases.And just something I 
thought about, Nick, is possibly coming up with a class decorator that sets 
self.module on the class. This could have the perk of taking an optional 
argument that checks if the optimized module is even in existence so as to skip 
running the tests twice if it is not needed. Then again this might 
over-optimizing and best to just let the tests run twice even if it is not 
needed.


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



[issue5623] test_fdopen fails with vs2005, release build on Windows 2000

2009-04-11 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Could someone port this to 3.1, please? I'm not Windows savy enough to
do it.

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue5738] multiprocessing example wrong

2009-04-11 Thread Garrett Cooper

New submission from Garrett Cooper :

The last example on the multiprocessing documentation page is clearly
wrong. It references a lot of renamed / deprecated API's from processing
that are no longer in multiprocessing.

I'll try and come up with a comparable working example on all platforms
(I use FreeBSD).

--
assignee: georg.brandl
components: Documentation
messages: 85874
nosy: georg.brandl, yaneurabeya
severity: normal
status: open
title: multiprocessing example wrong
type: feature request
versions: Python 2.6, Python 3.0

___
Python tracker 

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



[issue5738] multiprocessing example wrong

2009-04-11 Thread Benjamin Peterson

Changes by Benjamin Peterson :


--
assignee: georg.brandl -> jnoller
nosy: +jnoller

___
Python tracker 

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



[issue5665] Add more pickling tests

2009-04-11 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Collin, can you port these new tests to Py3k?

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue5738] multiprocessing example wrong

2009-04-11 Thread Jesse Noller

Jesse Noller  added the comment:

Ugh, I thought that was cleaned up. Don't bother with FreeBSD, or any 
other BSDes. If you're willing to do it, just make it work on linux. MP 
support on BSD is severely broken right now.

--

___
Python tracker 

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



[issue754016] urlparse goes wrong with IP:port without scheme

2009-04-11 Thread Senthil

Senthil  added the comment:

Facundo, I re-looked at this issue (after a long time; sorry for that)
and I think that the patch is good to be applied as it is for this issue.

The Web-SIG discussion, which you pointed to in the comment
(http://mail.python.org/pipermail/web-sig/2008-June/003458.html)
suggests a more "general case" of thinking and parsing of the urls.

The suggestion is specifically for "//path" kind of urls, which is will
be parsed into authority (as per RFC2396) or into netloc as in the patch.

My suggestion is to fix this issue with patch and if the corner case
like "//path" comes up, then I shall look the modifications required as
there is No RFC Specifications and Tests defining those cases.

Your comments?

--
resolution:  -> accepted

___
Python tracker 

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



[issue5735] Segfault when loading not recompiled module

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

Changes by Martin v. Löwis :


--
nosy: +loewis

___
Python tracker 

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



[issue5736] Add the iterator protocol to dbm modules

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

Martin v. Löwis  added the comment:

Would you like to fix gdbm as well?

--
nosy: +loewis

___
Python tracker 

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



[issue5738] multiprocessing example wrong

2009-04-11 Thread Garrett Cooper

Garrett Cooper  added the comment:

How about this? I'll do both :).

I'm avoiding sync + semaphore stuff because it's still non-portable
(Issue 3770 fun), even though I have a functioning copy of FreeBSD...
but I do have a Mac, VMware fusion, etc, and I'll toss in a working
example with Fedora 10.

--

___
Python tracker 

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



[issue5354] Add test.support.import_python_only

2009-04-11 Thread Nick Coghlan

Nick Coghlan  added the comment:

The None->tuple check is a legacy of the original API where "None"
actually meant to block "_name". I'll change it as you suggest.

Your explanation as to why the test was failing in py3k makes sense. I
think I will tidy that use case up a bit by adding a "fresh=()" argument
to the function to go along with the "blocked=()" argument. Then the two
warnings imports would be:
  py_warnings = support.import_fresh_module('warnings',
blocked=['_warnings']
  c_warnings = support.import_fresh_module('warnings', fresh=['_warnings']

On the last topic, implementations that don't have an accelerated
version of a module can use the new features for marking implementation
specific tests to skip over those ones.

--

___
Python tracker 

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



[issue1542677] IDLE shell gives different len() of unicode strings compared to Python shell

2009-04-11 Thread Naoki INADA

Naoki INADA  added the comment:

This issue is caused by compile() behavior.

Following sample is in codepage 932.

>>> 'あ'
'\x82\xa0'  # OK - 'あ' is '\x82\xa0' in cp932
>>> u'あ'
u'\u3042'   # OK - u'あ' is '\u3042' in UCS-2

compile as byte string.
>>> c = compile("'あ'", 'test', 'single')
>>> exec c
'\x82\xa0'  # OK
>>> c = compile("u'あ'", 'test', 'single')
>>> exec c
u'\x82\xa0' # NG!!!

compile as unicode string.
>>> c = compile(u"'あ'", 'test', 'single')
>>> exec c
'\xe3\x81\x82' # NG!!!
>>> c = compile(u"u'あ'", 'test', 'single')
>>> exec c
u'\u3042'  # OK

compile as byte string with pep 0263
>>> c = compile("# coding: mbcs\n'あ'", 'test', 'single')
>>> exec c
'\x82\xa0' # OK
>>> c = compile("# coding: mbcs\nu'あ'", 'test', 'single')
>>> exec c
u'\u3042'  # OK

--
nosy: +naoki

___
Python tracker 

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



[issue1542677] IDLE shell gives different len() of unicode strings compared to Python shell

2009-04-11 Thread Naoki INADA

Naoki INADA  added the comment:

This patch is for iplib/PyShell.py#ModifiedInterpreter.runsource.

 if isinstance(source, types.UnicodeType):
 import IOBinding
 try:
 source = source.encode(IOBinding.encoding)
+source = "# coding: %s\n%s" % (IOBinding.encoding, source)
 except UnicodeError:

--

___
Python tracker 

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



[issue5739] Language reference is ambiguous regarding next() method lookup

2009-04-11 Thread Nick Coghlan

New submission from Nick Coghlan :

The language reference is currently silent as to whether or not an
iterator's next() method is looked up on every pass around a for loop,
or whether it is OK for an implementation to look the method up once at
the start of the loop, cache the result and call it again each time
around the loop without doing the lookup again.

The language reference should require implementations to follow
CPython's behaviour in this respect: the method should be looked up
again on each pass around the loop.

As per this email on python-ideas:
http://mail.python.org/pipermail/python-ideas/2009-April/004083.html

--
assignee: georg.brandl
components: Documentation
messages: 85883
nosy: georg.brandl, ncoghlan
priority: normal
severity: normal
status: open
title: Language reference is ambiguous regarding next() method lookup
type: behavior

___
Python tracker 

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



[issue5730] setdefault speedup

2009-04-11 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I would support fixing the double call to PyObject_Hash().  For user
defined classes with their own __hash__ methods, this is by far the
slowest part of the operation.

> from my perspective creating an internal SetItem adds another
> function handling the data structure just as setdefault would

Incorrect comparison.  Your in-lining manipulated the ep structure
directly (not a good thing).  In contrast, adding an alternative
_PyDict_SetItemWithHash uses the insertdict() function, fully isolating
itself of from the table implementation.  The whole purpose of having
insertdict() and lookdict() is to isolate the data structure internals
from all externally visible functions.

>>> setup = '''
class A(object):
def __hash__(self):
return 10
class B(object):
   pass
a = A()
b = B()
'''
>>> min(Timer('{}.setdefault(a, 0)', setup).repeat(7, 10))
0.12840011789208106
>>> min(Timer('{}.setdefault(b, 0)', setup).repeat(7, 10))
0.053155359130840907

The double call to a very simple user defined __hash__ adds .07 to call
that takes on .05 with the double call to builtin object hash.  So, we
could save half of the the .07 just by elimating the double call to
__hash__.  With more complex hash functions the overall speedup is huge
(essentially cutting the total work almost in half).

--

___
Python tracker 

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



[issue5665] Add more pickling tests

2009-04-11 Thread Collin Winter

Collin Winter  added the comment:

Yes, I'm porting them. I got started, but got distracted by other things
since there were a lot of conflicts in the merge

--

___
Python tracker 

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