From 72c3745b28d64d43f6c21f960e13f0ee6142ec8d Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 29 Mar 2010 17:15:33 +0200 Subject: utils/migrate-0.8.py: Open files in universal newline support and pass filename to ast.parse. --- debian/changelog | 2 ++ utils/migrate-0.8.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 69eecc2b..a8211c5f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,8 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low - Map ArchiveURI property to archive_uri * debian/control: - Change priority to standard, keep -doc and -dev on optional. + * utils/migrate-0.8.py: + - Open files in universal newline support and pass filename to ast.parse. [ Michael Vogt ] * apt/cache.py: diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py index d0d8e9a1..56d51ef9 100755 --- a/utils/migrate-0.8.py +++ b/utils/migrate-0.8.py @@ -197,7 +197,7 @@ def find_occurences(all_old, files): continue words = defaultdict(lambda: set()) - for i in ast.walk(ast.parse(open(fname).read())): + for i in ast.walk(ast.parse(open(fname, "rU").read(), fname)): if isinstance(i, _ast.ImportFrom): for alias in i.names: if alias.name in all_old: -- cgit v1.2.3 From cbe639cf94a2fd80ca0ee0b2789eb93564b59edc Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 29 Mar 2010 21:26:06 +0200 Subject: Add has_key to the list of deprecated functions. --- debian/changelog | 1 + utils/migrate-0.8.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index a8211c5f..9a1ed281 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,7 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low - Change priority to standard, keep -doc and -dev on optional. * utils/migrate-0.8.py: - Open files in universal newline support and pass filename to ast.parse. + - Add has_key to the list of deprecated functions. [ Michael Vogt ] * apt/cache.py: diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py index 56d51ef9..bc3bc599 100755 --- a/utils/migrate-0.8.py +++ b/utils/migrate-0.8.py @@ -123,7 +123,7 @@ deprecated_cpp_stuff = set([ 'SelStateHold', 'SelStateInstall', 'SelStatePurge', 'SelStateUnknown', 'SizeToStr', 'StrToTime', 'StringToBool', 'Time', 'TimeRFC1123', 'TimeToStr', 'URItoFileName', 'UpstreamVersion', 'VersionCompare', - 'newConfiguration']) + 'newConfiguration', '.has_key']) def do_color(string, words): """Colorize (red) the given words in the given string.""" -- cgit v1.2.3 From 48b32fb4b820d92ca92b454a00131fb64ff6f883 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 29 Mar 2010 21:33:23 +0200 Subject: Don't abort if parsing failed. --- debian/changelog | 1 + utils/migrate-0.8.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 9a1ed281..66f78d06 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,7 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low * utils/migrate-0.8.py: - Open files in universal newline support and pass filename to ast.parse. - Add has_key to the list of deprecated functions. + - Don't abort if parsing failed. [ Michael Vogt ] * apt/cache.py: diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py index bc3bc599..49596fc4 100755 --- a/utils/migrate-0.8.py +++ b/utils/migrate-0.8.py @@ -197,7 +197,12 @@ def find_occurences(all_old, files): continue words = defaultdict(lambda: set()) - for i in ast.walk(ast.parse(open(fname, "rU").read(), fname)): + try: + node = ast.parse(open(fname, "rU").read(), fname) + except Exception, e: + print >> sys.stderr, "Ignoring %s: %s" % (fname, e) + continue + for i in ast.walk(node): if isinstance(i, _ast.ImportFrom): for alias in i.names: if alias.name in all_old: -- cgit v1.2.3 From e95acfe671c6c40ffdc92f466008dce3fce723a6 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 29 Mar 2010 21:42:11 +0200 Subject: do not require files to end in .py if they are passed on the command line or if they contain python somewhere in the shebang line. --- debian/changelog | 2 ++ utils/migrate-0.8.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 66f78d06..c0ff72c7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low - Open files in universal newline support and pass filename to ast.parse. - Add has_key to the list of deprecated functions. - Don't abort if parsing failed. + - do not require files to end in .py if they are passed on the command + line or if they contain python somewhere in the shebang line. [ Michael Vogt ] * apt/cache.py: diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py index 49596fc4..9f7790f7 100755 --- a/utils/migrate-0.8.py +++ b/utils/migrate-0.8.py @@ -193,7 +193,10 @@ def find_deprecated_py(): def find_occurences(all_old, files): """Find all ocurrences in the given Python files.""" for fname in files: - if fname.endswith('setup3.py') or not fname.endswith('.py'): + if not os.path.exists(fname): + continue + if not (fname in sys.argv or fname.endswith('.py') or + re.match('^#.*python.*', open(fname).readline())): continue words = defaultdict(lambda: set()) -- cgit v1.2.3 From 42e104ddb5dfb532d7bed66affbb2c7977684d16 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 30 Mar 2010 12:58:26 +0200 Subject: apt/package.py: Decode using utf-8 in installed_files (LP: #407953). --- apt/package.py | 4 ++-- debian/changelog | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apt/package.py b/apt/package.py index 0c026504..32480c39 100644 --- a/apt/package.py +++ b/apt/package.py @@ -955,9 +955,9 @@ class Package(object): """ path = "/var/lib/dpkg/info/%s.list" % self.name try: - file_list = open(path) + file_list = open(path, "rb") try: - return file_list.read().decode().split("\n") + return file_list.read().decode("utf-8").split(u"\n") finally: file_list.close() except EnvironmentError: diff --git a/debian/changelog b/debian/changelog index c0ff72c7..0e494a81 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low [ Julian Andres Klode ] + * apt/package.py: + - Decode using utf-8 in installed_files (LP: #407953). * python/generic.cc: - Fix a memory leak when using old attribute names. - Map ArchiveURI property to archive_uri -- cgit v1.2.3 From 4584144d57d4fe0b857c8e4d79645ffafa44409c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 31 Mar 2010 16:48:21 +0200 Subject: apt/package.py: Fix fetch_source() to work when source name = binary name (LP: #552400). --- apt/package.py | 10 +++++----- debian/changelog | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apt/package.py b/apt/package.py index 32480c39..817dfd55 100644 --- a/apt/package.py +++ b/apt/package.py @@ -536,13 +536,13 @@ class Version(object): dsc = None record = self._records - src.lookup(record.source_pkg) + source_name = record.source_pkg or self.package.name source_version = record.source_ver or self._cand.ver_str + source_lookup = src.lookup(source_name) - try: - while source_version != src.version: - src.lookup(record.source_pkg) - except AttributeError: + while source_lookup and source_version != src.version: + source_lookup = src.lookup(source_name) + if not source_lookup: raise ValueError("No source for %r" % self) files = list() for md5, size, path, type_ in src.files: diff --git a/debian/changelog b/debian/changelog index 0e494a81..5d287831 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low [ Julian Andres Klode ] * apt/package.py: - Decode using utf-8 in installed_files (LP: #407953). + - Fix fetch_source() to work when source name = binary name (LP: #552400). * python/generic.cc: - Fix a memory leak when using old attribute names. - Map ArchiveURI property to archive_uri -- cgit v1.2.3 From 0051fdbeff5e08248900cf0b8858178a3dceba7b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 31 Mar 2010 17:11:07 +0200 Subject: * python/cache.cc: - Check that 2nd argument to Cache.update() really is a SourceList object. --- debian/changelog | 2 ++ python/cache.cc | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 5d287831..b66f108e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ python-apt (0.7.94.3) UNRELEASED; urgency=low * apt/package.py: - Decode using utf-8 in installed_files (LP: #407953). - Fix fetch_source() to work when source name = binary name (LP: #552400). + * python/cache.cc: + - Check that 2nd argument to Cache.update() really is a SourceList object. * python/generic.cc: - Fix a memory leak when using old attribute names. - Map ArchiveURI property to archive_uri diff --git a/python/cache.cc b/python/cache.cc index 3c9bc785..e2f26dbb 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -90,7 +90,8 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) PyObject *pyFetchProgressInst = 0; PyObject *pySourcesList = 0; int pulseInterval = 0; - if (PyArg_ParseTuple(Args, "OO|i", &pyFetchProgressInst,&pySourcesList, &pulseInterval) == 0) + if (PyArg_ParseTuple(Args, "OO!|i", &pyFetchProgressInst, + &PySourceList_Type, &pySourcesList, &pulseInterval) == 0) return 0; PyFetchProgress progress; -- cgit v1.2.3