diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-03-31 22:14:52 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-03-31 22:14:52 +0200 |
| commit | 01ae32fec88cc63623874752f79b052fbb2cf028 (patch) | |
| tree | 691ce7320e5fb9d9eb268423bd90b46f3a7e4749 | |
| parent | 82dc1170b0b29f7bb264d046d1c9253f4d97fb10 (diff) | |
| parent | 0051fdbeff5e08248900cf0b8858178a3dceba7b (diff) | |
| download | python-apt-01ae32fec88cc63623874752f79b052fbb2cf028.tar.gz | |
merged from http://bzr.debian.org/apt/python-apt/debian-sid/
| -rw-r--r-- | apt/package.py | 14 | ||||
| -rw-r--r-- | debian/changelog | 19 | ||||
| -rw-r--r-- | python/cache.cc | 3 | ||||
| -rw-r--r-- | python/generic.cc | 5 | ||||
| -rw-r--r-- | python/indexfile.cc | 3 | ||||
| -rw-r--r-- | python/progress.cc | 1 | ||||
| -rw-r--r-- | tests/test_apt_cache.py | 10 | ||||
| -rwxr-xr-x | utils/migrate-0.8.py | 14 |
8 files changed, 48 insertions, 21 deletions
diff --git a/apt/package.py b/apt/package.py index 701872a8..342fb5cf 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: @@ -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 0013daf1..af93a755 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,22 @@ +python-apt (0.7.94.2ubuntu5) 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/cache.cc: + - Check that 2nd argument to Cache.update() really is a SourceList object. + * python/generic.cc: + - Map ArchiveURI property to archive_uri + * 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. + - 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 <michael.vogt@ubuntu.com> Wed, 31 Mar 2010 22:11:38 +0200 + python-apt (0.7.94.2ubuntu4) lucid; urgency=low * If PYTHON_APT_DEPRECATION_WARNINGS is unset, also disable the diff --git a/python/cache.cc b/python/cache.cc index ba620099..87902b1e 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; diff --git a/python/generic.cc b/python/generic.cc index d08b12c0..0719d1bb 100644 --- a/python/generic.cc +++ b/python/generic.cc @@ -31,11 +31,11 @@ PyObject *HandleErrors(PyObject *Res) Py_DECREF(Res); } - std::string Err; + string Err; int errcnt = 0; while (_error->empty() == false) { - std::string Msg; + string Msg; bool Type = _error->PopMessage(Msg); if (errcnt > 0) Err.append(", "); @@ -63,6 +63,7 @@ static PyObject *_PyApt_NewNameForAttribute(const char *attr) { if (strcasecmp(attr, "ReadPinFile") == 0) return PyString_FromString("read_pinfile"); if (strcasecmp(attr, "SetReInstall") == 0) return PyString_FromString("set_reinstall"); if (strcasecmp(attr, "URI") == 0) return PyString_FromString("uri"); + if (strcasecmp(attr, "ArchiveURI") == 0) return PyString_FromString("archive_uri"); if (strcasecmp(attr, "MD5Hash") == 0) return PyString_FromString("md5_hash"); if (strcasecmp(attr, "SHA1Hash") == 0) return PyString_FromString("sha1_hash"); if (strcasecmp(attr, "SHA256Hash") == 0) return PyString_FromString("sha256_hash"); diff --git a/python/indexfile.cc b/python/indexfile.cc index 5e66b06a..c6d0b1cc 100644 --- a/python/indexfile.cc +++ b/python/indexfile.cc @@ -28,9 +28,6 @@ static PyObject *IndexFileArchiveURI(PyObject *Self,PyObject *Args) static PyMethodDef IndexFileMethods[] = { {"archive_uri",IndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, -#ifdef COMPAT_0_7 - {"ArchiveURI",IndexFileArchiveURI,METH_VARARGS,"Returns the ArchiveURI"}, -#endif {} }; diff --git a/python/progress.cc b/python/progress.cc index 097f06cf..18081690 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -491,6 +491,7 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) StartUpdate(); + PyCbObj_END_ALLOW_THREADS if(PyObject_HasAttrString(callbackInst, "waitChild") || PyObject_HasAttrString(callbackInst, "wait_child")) { diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index 3c2961e1..fdcf482d 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -15,9 +15,9 @@ class TestAptCache(unittest.TestCase): """ test the apt cache """ def testAptCache(self): - """ simple test that iterates all packages and all dependencies """ + """cache: iterate all packages and all dependencies """ cache = apt.Cache() - # number is not meaningful and just need to be "big enough", + # number is not meaningful and just need to be "big enough", # the important bit is the test against __len__ self.assertTrue(len(cache) > 100) # go over the cache and all dependencies, just to see if @@ -26,9 +26,9 @@ class TestAptCache(unittest.TestCase): if pkg.candidate: for or_dep in pkg.candidate.dependencies: for dep in or_dep.or_dependencies: - name = dep.name - relation = dep.relation - preDepends = dep.pre_depend + self.assertTrue(dep.name) + self.assertTrue(isinstance(dep.relation, str)) + self.assertTrue(dep.pre_depend in (True, False)) if __name__ == "__main__": unittest.main() diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py index d0d8e9a1..9f7790f7 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.""" @@ -193,11 +193,19 @@ 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()) - for i in ast.walk(ast.parse(open(fname).read())): + 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: |
