diff options
author | Georg Brandl <georg@python.org> | 2008-01-16 20:27:25 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-01-16 20:27:25 +0000 |
commit | b09e628b0f33614e81521ad60e94472a0db09a4d (patch) | |
tree | 9fde04d85255a2f7569f8f10def1f2cfe70f303e /sphinx/patchlevel.py | |
parent | 1fbdc410b71ab6515ad576ef277700b9dba92d47 (diff) | |
download | sphinx-git-b09e628b0f33614e81521ad60e94472a0db09a4d.tar.gz |
A few refactorings in Sphinx.
Diffstat (limited to 'sphinx/patchlevel.py')
-rw-r--r-- | sphinx/patchlevel.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sphinx/patchlevel.py b/sphinx/patchlevel.py index a3a6d6904..efd1ab73d 100644 --- a/sphinx/patchlevel.py +++ b/sphinx/patchlevel.py @@ -6,10 +6,11 @@ Extract version info from Include/patchlevel.h. Adapted from Doc/tools/getversioninfo. + XXX Python specific + :copyright: 2007-2008 by Georg Brandl. :license: BSD. """ -from __future__ import with_statement import os import re @@ -23,12 +24,15 @@ def get_version_info(srcdir): rx = re.compile(r"\s*#define\s+([a-zA-Z][a-zA-Z_0-9]*)\s+([a-zA-Z_0-9]+)") d = {} - with open(patchlevel_h) as f: + f = open(patchlevel_h) + try: for line in f: m = rx.match(line) if m is not None: name, value = m.group(1, 2) d[name] = value + finally: + f.close() release = version = "%s.%s" % (d["PY_MAJOR_VERSION"], d["PY_MINOR_VERSION"]) micro = int(d["PY_MICRO_VERSION"]) |