Issue 14858: 'pysetup create' off-by-one when choosing classification maturity status interactively. (original) (raw)

Created on 2012-05-19 15:17 by todddeluca, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue14858.patch todddeluca,2012-05-27 10:03 Patch for issue14848.
Messages (8)
msg161129 - (view) Author: Todd DeLuca (todddeluca) Date: 2012-05-19 15:17
Today I installed distutils2 via pip and ran 'pysetup create'. During the selection of Trove classifiers for Development status I chose '2 - Alpha' but setup.cfg ended up incorrectly indicating that my project is Pre-Alpha. Here is a "screenshot" of the interactive setup with me choosing '2 - Alpha': ``` Do you want to set Trove classifiers? (y/n): y Please select the project status: 0 - Planning 1 - Pre-Alpha 2 - Alpha 3 - Beta 4 - Production/Stable 5 - Mature 6 - Inactive Status: 2 ``` Here is the relevant line in setup.cfg: classifier = Development Status :: 2 - Pre-Alpha Here are the relevant Trove classifications from http://pypi.python.org/pypi?%3Aaction=list_classifiers: ``` Development Status :: 1 - Planning Development Status :: 2 - Pre-Alpha Development Status :: 3 - Alpha Development Status :: 4 - Beta Development Status :: 5 - Production/Stable Development Status :: 6 - Mature Development Status :: 7 - Inactive ``` Notice above that the numbers assigned to the Trove classifiers are greater (by one) than the numbers displayed in the pysetup script. The problem is in file distutil2/create.py (http://hg.python.org/distutils2/file/d015f9edccb8/distutils2/create.py) in class MainProgram, method set_maturity_status(). Changing the following line: 676 Status''' % '\n'.join('%s - %s' % (i, maturity_name(n)) To the following: 676 Status''' % '\n'.join('%s - %s' % (i + 1, maturity_name(n)) Should display the numbers correctly and fix the problem. I tested this fix on my system (using python2.7.3) and it works correctly. Regards, Todd P.S. Apologies for not submitting a "Pull request".
msg161600 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-05-25 18:53
Thanks for the report and fix. Someone interested in contributing can turn your fix into a patch with a test.
msg161634 - (view) Author: Sharif Nassar (Sharif.Nassar) Date: 2012-05-26 01:59
Even better: diff -r 747eec42e7ae distutils2/create.py --- a/distutils2/create.py Mon May 21 17:01:44 2012 -0400 +++ b/distutils2/create.py Fri May 25 19:04:22 2012 -0700 @@ -674,7 +674,7 @@ %s Status''' % '\n'.join('%s - %s' % (i, maturity_name(n)) - for i, n in enumerate(PROJECT_MATURITY)) + for i, n in enumerate(PROJECT_MATURITY, 1 )) while True: choice = ask(dedent(maturity_question), required=False)
msg161637 - (view) Author: Todd DeLuca (todddeluca) Date: 2012-05-26 02:05
That was my first thought, but if python2.5 compatibility is important, I don't think using the start parameter is an option. http://docs.python.org/library/functions.html#enumerate "Changed in version 2.6: The start parameter was added." Regards, Todd On Fri, May 25, 2012 at 9:59 PM, Sharif Nassar <report@bugs.python.org>wrote: > > Sharif Nassar <mrwacky42@gmail.com> added the comment: > > Even better: > > diff -r 747eec42e7ae distutils2/create.py > --- a/distutils2/create.py Mon May 21 17:01:44 2012 -0400 > +++ b/distutils2/create.py Fri May 25 19:04:22 2012 -0700 > @@ -674,7 +674,7 @@ > %s > > Status''' % '\n'.join('%s - %s' % (i, maturity_name(n)) > - for i, n in enumerate(PROJECT_MATURITY)) > + for i, n in enumerate(PROJECT_MATURITY, > 1 )) > while True: > choice = ask(dedent(maturity_question), required=False) > > ---------- > nosy: +Sharif.Nassar > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue14858> > _______________________________________ >
msg161647 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-05-26 05:02
distutils indeed supports 2.5-2.7. The first proposed fix should be fine, what’s needed is a unit test (more info in the devguide).
msg161690 - (view) Author: Todd DeLuca (todddeluca) Date: 2012-05-27 00:01
I'm working on a unit test and fix for a patch. There are a couple other possible bugs in the function that I coud fix (and test). Should I submit separate patches for each bug or one patch that fixes all 3 (small) bugs? Also should I open issues for each bug? The other issues I could open are: - the function forces you to choose a maturity status (instead of being able to skip it) - you can enter an out of range number (0) and it sets a valid value (the last item in the list.). Thanks for your advice. Regards, Todd On Sat, May 26, 2012 at 1:02 AM, Éric Araujo <report@bugs.python.org> wrote: > > Éric Araujo <merwok@netwok.org> added the comment: > > distutils indeed supports 2.5-2.7. The first proposed fix should be fine, > what’s needed is a unit test (more info in the devguide). > > ---------- > stage: needs patch -> test needed > > _______________________________________ > Python tracker <report@bugs.python.org> > <http://bugs.python.org/issue14858> > _______________________________________ >
msg161706 - (view) Author: Todd DeLuca (todddeluca) Date: 2012-05-27 10:03
This patch fixes the problem where the user would select a maturity status when runnning 'pysetup create' and the resulting setup.cfq would have a maturity status one less than the user selected. It also fixes the behavior where a user can select '0' as a maturity status, which is not a valid selection, and setup.cfg will contain maturity status 'Development Status :: 7 - Inactive'. This behavior is related to the implementation of the off-by-one error above, since '0' is translated into a list lookup using the index -1. Finally, the patch addresses behavior where a user cannot enter a blank maturity status (e.g. by just pressing the 'return' key) in order to skip the question. The unit tests added to 'test_create.py' cover expected behavior when entering and blank selection, an invalid selection, and a valid selection. These tests were run using Python 2.7.3 on my Mac OS X 10.6.8 (Snow Leopard).
msg213238 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2014-03-12 10:15
distutils2 is replaced by other projects.
History
Date User Action Args
2022-04-11 14:57:30 admin set github: 59063
2014-03-12 10:15:49 eric.araujo set status: open -> closedresolution: out of datemessages: + stage: test needed -> resolved
2012-05-27 10:03:09 todddeluca set files: + issue14858.patchkeywords: + patchmessages: +
2012-05-27 00:01:11 todddeluca set messages: +
2012-05-26 05:02:43 eric.araujo set messages: + stage: needs patch -> test needed
2012-05-26 02:05:38 todddeluca set messages: +
2012-05-26 01:59:09 Sharif.Nassar set nosy: + Sharif.Nassarmessages: +
2012-05-25 18:53:05 eric.araujo set keywords: + easystage: needs patchmessages: + versions: + 3rd party, Python 3.3, - Python 2.7
2012-05-25 16:37:21 tshepang set nosy: + tshepang
2012-05-19 15:17:03 todddeluca create