Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ast.__version__ calculation to provide consistent ordering #56482

Closed
ncoghlan opened this issue Jun 7, 2011 · 8 comments
Closed

Change ast.__version__ calculation to provide consistent ordering #56482

ncoghlan opened this issue Jun 7, 2011 · 8 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@ncoghlan
Copy link
Contributor

ncoghlan commented Jun 7, 2011

BPO 12273
Nosy @loewis, @brettcannon, @ncoghlan, @benjaminp, @merwok, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/ncoghlan'
closed_at = <Date 2011-07-16.02:06:05.440>
created_at = <Date 2011-06-07.04:12:13.849>
labels = ['library']
title = 'Change ast.__version__ calculation to provide consistent ordering'
updated_at = <Date 2011-07-16.10:38:00.014>
user = 'https://github.com/ncoghlan'

bugs.python.org fields:

activity = <Date 2011-07-16.10:38:00.014>
actor = 'ncoghlan'
assignee = 'ncoghlan'
closed = True
closed_date = <Date 2011-07-16.02:06:05.440>
closer = 'python-dev'
components = ['Library (Lib)']
creation = <Date 2011-06-07.04:12:13.849>
creator = 'ncoghlan'
dependencies = []
files = []
hgrepos = []
issue_num = 12273
keywords = []
message_count = 8.0
messages = ['137786', '137787', '137854', '137880', '138053', '140477', '140489', '140490']
nosy_count = 7.0
nosy_names = ['loewis', 'brett.cannon', 'ncoghlan', 'benjamin.peterson', 'eric.araujo', 'r.david.murray', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue12273'
versions = ['Python 3.3']

@ncoghlan
Copy link
Contributor Author

ncoghlan commented Jun 7, 2011

Benjamin's AST modification checkins switched directly from the SVN revision number (as a string) to the hg revision hash.

While that preserves uniqueness, it makes ordering difficult to determine.

The last AST version in 3.2 was '82163' (and it was '82160' in 2.7).

I would like to change the version number calculation to something like:

'9.x.y.zzzzzzz'

where

9 is a prefix to get 3.3+ ast.__version__ values to sort higher than earlier versions
x.y is the Python version so later versions sort higher than earlier versions in the future
zzzzzz is the hg version id, so versions during development of a release remain unique, even if they can't be readily ordered.

This would require changes to ast.py (to add the 9.x.y prefix) and to release.py (to check that the 'x.y' prefix is correct in the current release)

@ncoghlan ncoghlan self-assigned this Jun 7, 2011
@ncoghlan ncoghlan added the stdlib Python modules in the Lib dir label Jun 7, 2011
@loewis
Copy link
Mannequin

loewis mannequin commented Jun 7, 2011

I would like to change the version number calculation to something
like:

'9.x.y.zzzzzzz'

where

9 is a prefix to get 3.3+ ast.__version__ values to sort higher than
earlier versions x.y is the Python version so later versions sort
higher than earlier versions in the future zzzzzz is the hg version
id, so versions during development of a release remain unique, even
if they can't be readily ordered.

I'd drop the 9. part. People doing comparison on these numbers possibly
performed int() conversions first (expecting that svn revisions might
have exceeded 100,000 some day); they would have to special-case 3.3
anyway. Also, in the long run, the 2.x/3.1/3.2 copies of ast will be
gone, and we are stuck with this odd prefix.

OTOH, most people probably don't do ordering comparisons at all, but
have explicit lists of versions they support (barking if it's an
unknown version); those won't be helped by the 9. prefix at all.

This would require changes to ast.py (to add the 9.x.y prefix) and to
release.py (to check that the 'x.y' prefix is correct in the current
release)

I'd synthesize x.y from patchlevel.h, in which case it would be fully
automatic again.

@loewis loewis mannequin changed the title Change ast.__version__ calculation to provide consistent ordering Change ast.__version__ calculation to provide consistent ordering Jun 7, 2011
@benjaminp
Copy link
Contributor

I propose we leave ast.__version__ alone. Using ast.__version__ at all should be a very advanced usecase. Generally, you should just be able to look at sys.version_info. We could document this rather than duplicating sys.version_info in ast.__version__. I think ast.__version__ is mostly useful for things like:

print("Running with Python {} and AST {}".format(sys.mercurial[2], ast.__version__)

@bitdancer
Copy link
Member

I think you should just kill ast.__version__ in that case. There was a discussion on python-dev and packaging about __version__ and PEP-396 was the result. If you want the VCS info put it somewhere else (like __vcs_version__?).

@brettcannon
Copy link
Member

sys.version_info and sys._mercurial provide all the info needed for someone (like me for mnfy) to know if their code will work against the AST nodes used by the running interpreter. I say drop __version__.

@python-dev
Copy link
Mannequin

python-dev mannequin commented Jul 16, 2011

New changeset b23ad0a6cf87 by Benjamin Peterson in branch 'default':
remove ast.__version__ (closes bpo-12273)
http://hg.python.org/cpython/rev/b23ad0a6cf87

@python-dev python-dev mannequin closed this as completed Jul 16, 2011
@loewis
Copy link
Mannequin

loewis mannequin commented Jul 16, 2011

sys.version_info and sys._mercurial provide all the info needed for someone (like me for mnfy)

Can you please elaborate? How do you know from looking at
sys._mercurial whether you can support that AST version?
sys._mercurial changes with every commit, but the AST doesn't
change that often.

@ncoghlan
Copy link
Contributor Author

On Sat, Jul 16, 2011 at 8:24 PM, Martin v. Löwis <report@bugs.python.org> wrote:

> sys.version_info and sys._mercurial provide all the info needed for someone (like me for mnfy)

Can you please elaborate? How do you know from looking at
sys._mercurial whether you can support that AST version?
sys._mercurial changes with every commit, but the AST doesn't
change that often.

For anyone not following CPython tip, the real version indicator is
sys.version_info (i.e. assuming the AST changes with each major Python
version and bumping your version check once you've determined that
your code is compatible with a later release).

Life is more difficult for anyone following CPython tip, but in that
case it is probably easier to just assume compatibility and
investigate further if a "hg pull" ever breaks anything. Since
"ast.__version__" wasn't usefully orderable post-Hg migration, the
previous best you could have done is checked for a specific version,
guaranteeing failure if we changed the AST in any respect. Agreed that
sys._mercurial changes too often to be useful in even that limited
way, though.

@ncoghlan ncoghlan changed the title Change ast.__version__ calculation to provide consistent ordering Change ast.__version__ calculation to provide consistent ordering Jul 16, 2011
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

4 participants