classification
Title: regrtest single: iterator not subscriptable
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: jgsack, michael.foord, ncoghlan, pitrou, r.david.murray
Priority: normal Keywords: patch

Created on 2009-11-26 04:50 by jgsack, last changed 2009-12-16 15:26 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
regrtest_single_issue7396.patch r.david.murray, 2009-12-12 15:36
Messages (5)
msg95731 - (view) Author: James G. sack (jim) (jgsack) Date: 2009-11-26 04:50
file Lib/tests/regrtest.py
 
Evidently rev 76260 (trunk) / 76261 (py3k)
broke code at
  rev 76324 line 655 (py3k)
  rev 76321 line 620 (trunk) 
which is
   if tests[0] == alltests[i]  
because tests was rebound from a list to an iterable, and hence indexing 
cannot be performed on tests subsequent to the rebinding.

There are a few other places where tests is indexed, but I suspect those 
places are before the rebinding to an iterable.

At first glance, a viable patch might be to use a different name, eg 
itests, and leave the original tests list available for use by the line 
causing the TypeError. However, I think someone more knowledgeable needs 
to have a look.

Ummm, forgive me if this is offbase, but would it be fair to identify as 
a bad practice, the rebinding of a variable to a different type. 

~jim
msg96294 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-12-12 15:36
Yes, rebinding a variable to a different type is something that is
considered an acceptable pattern in Python programs, at least in certain
circumstances.  Python programs generally use 'duck typing', and a list
and an iterable have equivalent semantics for the purposes of (most of)
the regrtest code.

On the other hand, regrtest is in general *not* an example of good
Python code, and really ought to be cleaned up at some point.  In
particular, the code blocks in regrtest are simply huge, and this makes
changing it very error prone, with "what type is this variable" being
just one example of the coupling problems.

Attached is a patch against trunk.  Please confirm that this fixes the
problems you found.
msg96473 - (view) Author: James G. sack (jim) (jgsack) Date: 2009-12-16 03:03
Thanks, it seems to work now. 

My test method uses the command format
  ./python -Ebb Lib/test/regrtest.py -s test_calendar

Sorry for the delayed response, I discovered problems with 
  test_bz2
  test_codecs
which I wanted to confirm was real rather than my test procedure.

~jim
msg96477 - (view) Author: James G. sack (jim) (jgsack) Date: 2009-12-16 07:00
Update: I was doing something wrong and getting false failures. 

I forgot to do ./configure and make after major revision-switches so the 
failures I was seeing in bz2 and codecs (and others, :-[ ) was bogus.

Repeating the main message, though:
 The regrtest patch seems ok

~jim
msg96490 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-12-16 15:26
Thanks for testing.  Note that you don't need to use -s to run a single
test.  You can specify a list of tests to run on the regrtest command
line, which can be just one test.  -s for running all the tests one at a
time so that you restart the interpreter between each one (ie: when
using -s you issue the regrtest -s command multiple times...)

Committed to trunk in r76856 and py3k in r76857.
History
Date User Action Args
2009-12-16 15:26:15r.david.murraysetstatus: open -> closed
resolution: fixed
messages: + msg96490

stage: patch review -> resolved
2009-12-16 07:00:46jgsacksetmessages: + msg96477
2009-12-16 03:03:02jgsacksetmessages: + msg96473
2009-12-12 15:36:25r.david.murraysetfiles: + regrtest_single_issue7396.patch

assignee: r.david.murray
components: + Tests
versions: - Python 2.6, Python 3.1
keywords: + patch
nosy: jgsack, ncoghlan, pitrou, r.david.murray, michael.foord
messages: + msg96294
stage: patch review
2009-12-12 08:29:11ezio.melottisetpriority: normal
nosy: + ncoghlan, pitrou, r.david.murray, michael.foord

versions: - Python 3.0
2009-11-26 04:50:13jgsackcreate