Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 365096 Details for
Bug 493906
sys-apps/paludis-2.0.0 - compilability with Python3
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Fixes for paludis 1.4.2 and Python 3
paludis-1.4.2-python3-fixes.patch (text/plain), 17.51 KB, created by
Alex Turbov
on 2013-12-11 06:16:59 UTC
(
hide
)
Description:
Fixes for paludis 1.4.2 and Python 3
Filename:
MIME Type:
Creator:
Alex Turbov
Created:
2013-12-11 06:16:59 UTC
Size:
17.51 KB
patch
obsolete
>diff -ub -rub paludis-1.4.2.org/configure.ac paludis-1.4.2/configure.ac >--- paludis-1.4.2.org/configure.ac 2013-12-05 10:57:47.000000000 +0400 >+++ paludis-1.4.2/configure.ac 2013-12-10 20:38:23.000000000 +0400 >@@ -1310,8 +1310,8 @@ > AC_MSG_ERROR([Your gcc is too old for Python support])) > > AC_MSG_CHECKING(for headers required to compile python extensions) >- py_prefix=`$PYTHON -c "import sys; print sys.prefix"` >- py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` >+ py_prefix=`$PYTHON -c "import sys; print(sys.prefix)"` >+ py_exec_prefix=`$PYTHON -c "import sys; print(sys.exec_prefix)"` > PYTHON_INCLUDE_DIR="${py_prefix}/include/python${PYTHON_VERSION}" > if test "$py_prefix" != "$py_exec_prefix"; then > PYTHON_INCLUDE_DIR="$PYTHON_INCLUDE_DIR -I${py_exec_prefix}/include/python${PYTHON_VERSION}" >diff -ub -rub paludis-1.4.2.org/python/choices_TEST.py paludis-1.4.2/python/choices_TEST.py >--- paludis-1.4.2.org/python/choices_TEST.py 2013-02-11 01:16:30.000000000 +0400 >+++ paludis-1.4.2/python/choices_TEST.py 2013-12-11 02:25:46.000000000 +0400 >@@ -34,7 +34,7 @@ > class TestCase_01_Choices(unittest.TestCase): > def setUp(self): > self.e = EnvironmentFactory.instance.create("") >- self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next() >+ self.pid = next(iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", []))) > self.choices = self.pid.find_metadata("PALUDIS_CHOICES").parse_value() > > def test_01_choices(self): >@@ -50,7 +50,7 @@ > self.assert_(not self.choices.has_matching_contains_every_value_prefix("foo")) > > def test_04_iter(self): >- self.assert_(isinstance(iter(self.choices).next(), Choice)) >+ self.assert_(isinstance(next(iter(self.choices)), Choice)) > found = False > for f in self.choices: > if f.raw_name == "USE": >@@ -60,7 +60,7 @@ > class TestCase_02_Choice(unittest.TestCase): > def setUp(self): > self.e = EnvironmentFactory.instance.create("") >- self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next() >+ self.pid = next(iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", []))) > self.choices = self.pid.find_metadata("PALUDIS_CHOICES").parse_value() > self.use = None > self.linguas = None >@@ -91,7 +91,7 @@ > self.assertEquals(self.linguas.consider_added_or_changed, True) > > def test_03_use_iter(self): >- self.assert_(isinstance(iter(self.use).next(), ChoiceValue)) >+ self.assert_(isinstance(next(iter(self.use)), ChoiceValue)) > found = False > for f in self.use: > if f.name_with_prefix == "testflag": >@@ -99,7 +99,7 @@ > self.assert_(found) > > def test_04_linguas_iter(self): >- self.assert_(isinstance(iter(self.linguas).next(), ChoiceValue)) >+ self.assert_(isinstance(next(iter(self.linguas)), ChoiceValue)) > found = False > for f in self.linguas: > if f.name_with_prefix == "linguas_en": >@@ -109,7 +109,7 @@ > class TestCase_03_ChoiceValue(unittest.TestCase): > def setUp(self): > self.e = EnvironmentFactory.instance.create("") >- self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next() >+ self.pid = next(iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", []))) > self.choices = self.pid.find_metadata("PALUDIS_CHOICES").parse_value() > self.use_testflag = self.choices.find_by_name_with_prefix("testflag") > self.linguas_en = self.choices.find_by_name_with_prefix("linguas_en") >diff -ub -rub paludis-1.4.2.org/python/dep_spec_TEST.py paludis-1.4.2/python/dep_spec_TEST.py >--- paludis-1.4.2.org/python/dep_spec_TEST.py 2013-02-11 01:16:30.000000000 +0400 >+++ paludis-1.4.2/python/dep_spec_TEST.py 2013-12-10 20:38:23.000000000 +0400 >@@ -79,8 +79,8 @@ > vrc = self.pds.version_requirements > > self.assertEquals(len(list(vrc)), 1) >- self.assertEquals(iter(vrc).next().version_spec, VersionSpec("1")) >- self.assertEquals(iter(vrc).next().version_operator.value, VersionOperator(">=").value) >+ self.assertEquals(next(iter(vrc)).version_spec, VersionSpec("1")) >+ self.assertEquals(next(iter(vrc)).version_operator.value, VersionOperator(">=").value) > > def test_08_version_requirements_mode(self): > self.get_depspecs() >@@ -88,7 +88,7 @@ > > ### def test_09_additional_requirements(self): > ### spec = parse_user_package_dep_spec("foo/monkey[foo]", UserPackageDepSpecOptions()) >-### ur = iter(spec.additional_requirements).next() >+### ur = next(iter(spec.additional_requirements)) > ### self.assert_(isinstance(ur, EnabledUseRequirement)) > > def test_11_name(self): >diff -ub -rub paludis-1.4.2.org/python/exception.hh paludis-1.4.2/python/exception.hh >--- paludis-1.4.2.org/python/exception.hh 2013-05-23 04:45:24.000000000 +0400 >+++ paludis-1.4.2/python/exception.hh 2013-12-10 20:38:23.000000000 +0400 >@@ -68,7 +68,12 @@ > _e(PyErr_NewException(const_cast<char*>(_longname.c_str()), base, NULL)) > { > PyModule_AddObject(boost::python::detail::current_scope, const_cast<char*>(_name.c_str()), _e); >- PyObject * doc_string = PyString_FromString(doc.c_str()); >+ PyObject * doc_string = >+#if PY_MAJOR_VERSION < 3 >+ PyString_FromString(doc.c_str()); >+# else >+ PyUnicode_FromString(doc.c_str()); >+# endif > PyObject_SetAttrString(_e, "__doc__", doc_string); > boost::python::register_exception_translator<Ex_>( > std::bind(std::mem_fn(&RegisteredException<Ex_>::translator), this, std::placeholders::_1)); >@@ -78,9 +83,15 @@ > void > RegisteredException<Ex_>::translator(const Ex_ & x) const > { >+#if PY_MAJOR_VERSION < 3 > PyObject * backtrace = PyString_FromString(x.backtrace("\n").c_str()); > PyObject * message = PyString_FromString(x.message().c_str()); > PyObject * what = PyString_FromString(x.what()); >+#else >+ PyObject * backtrace = PyUnicode_FromString(x.backtrace("\n").c_str()); >+ PyObject * message = PyUnicode_FromString(x.message().c_str()); >+ PyObject * what = PyUnicode_FromString(x.what()); >+#endif > PyObject_SetAttrString(_e, "backtrace", backtrace); > PyObject_SetAttrString(_e, "message", message); > PyObject_SetAttrString(_e, "what", what); >diff -ub -rub paludis-1.4.2.org/python/iterable.hh paludis-1.4.2/python/iterable.hh >--- paludis-1.4.2.org/python/iterable.hh 2013-05-23 04:45:24.000000000 +0400 >+++ paludis-1.4.2/python/iterable.hh 2013-12-10 20:38:23.000000000 +0400 >@@ -63,8 +63,7 @@ > { > static void add(Set<To_> & c, PyObject * ptr) > { >- const char * str = PyString_AsString(ptr); >- c.insert(To_(std::string(str))); >+ c.insert(To_(boost::python::extract<std::string>(ptr))); > } > }; > >@@ -73,8 +72,7 @@ > { > static void add(Sequence<To_> & c, PyObject * ptr) > { >- const char * str = PyString_AsString(ptr); >- c.push_back(To_(std::string(str))); >+ c.push_back(To_(boost::python::extract<std::string>(ptr))); > } > }; > >@@ -130,7 +128,14 @@ > V_ * ptr = boost::python::extract<V_ *>(o); > s->push_back(*ptr); > } >- else if (IsConvertible<std::string, V_>::value && PyString_Check(o.ptr())) >+ else if ( >+ IsConvertible<std::string, V_>::value >+#if PY_MAJOR_VERSION < 3 >+ && PyString_Check(o.ptr()) >+#else >+ && PyUnicode_Check(o.ptr()) >+#endif >+ ) > { > ConditionalAdd<V_, std::string, Sequence<V_>, > IsConvertible<std::string, V_>::value>::add(*s, o.ptr()); >@@ -200,7 +205,14 @@ > V_ * ptr = boost::python::extract<V_ *>(o); > s->insert(*ptr); > } >- else if (IsConvertible<std::string, V_>::value && PyString_Check(o.ptr())) >+ else if ( >+ IsConvertible<std::string, V_>::value >+#if PY_MAJOR_VERSION < 3 >+ && PyString_Check(o.ptr()) >+#else >+ && PyUnicode_Check(o.ptr()) >+#endif >+ ) > { > ConditionalAdd<V_, std::string, Set<V_>, > IsConvertible<std::string, V_>::value>::add(*s, o.ptr()); >diff -ub -rub paludis-1.4.2.org/python/mask_TEST.py paludis-1.4.2/python/mask_TEST.py >--- paludis-1.4.2.org/python/mask_TEST.py 2013-02-11 01:16:31.000000000 +0400 >+++ paludis-1.4.2/python/mask_TEST.py 2013-12-10 20:38:23.000000000 +0400 >@@ -36,8 +36,8 @@ > def test_01_user_mask(self): > q = Selection.RequireExactlyOne(Generator.Matches( > parse_user_package_dep_spec("=masked/user-1.0", self.e, []), [])) >- pid = iter(self.e[q]).next() >- m = iter(pid.masks).next() >+ pid = next(iter(self.e[q])) >+ m = next(iter(pid.masks)) > > self.assert_(isinstance(m, Mask)) > self.assert_(isinstance(m, UserMask)) >@@ -48,8 +48,8 @@ > def test_02_unaccepted_mask(self): > q = Selection.RequireExactlyOne(Generator.Matches( > parse_user_package_dep_spec("=masked/unaccepted-1.0", self.e, []), [])) >- pid = iter(self.e[q]).next() >- m = iter(pid.masks).next() >+ pid = next(iter(self.e[q])) >+ m = next(iter(pid.masks)) > > self.assert_(isinstance(m, Mask)) > self.assert_(isinstance(m, UnacceptedMask)) >@@ -61,8 +61,8 @@ > def test_03_repository_mask(self): > q = Selection.RequireExactlyOne(Generator.Matches( > parse_user_package_dep_spec("=masked/repo-1.0", self.e, []), [])) >- pid = iter(self.e[q]).next() >- m = iter(pid.masks).next() >+ pid = next(iter(self.e[q])) >+ m = next(iter(pid.masks)) > > self.assert_(isinstance(m, Mask)) > self.assert_(isinstance(m, RepositoryMask)) >@@ -76,8 +76,8 @@ > def test_04_unsupported_mask(self): > q = Selection.RequireExactlyOne(Generator.Matches( > parse_user_package_dep_spec("=masked/unsupported-1.0", self.e, []), [])) >- pid = iter(self.e[q]).next() >- m = iter(pid.masks).next() >+ pid = next(iter(self.e[q])) >+ m = next(iter(pid.masks)) > > self.assert_(isinstance(m, Mask)) > self.assert_(isinstance(m, UnsupportedMask)) >diff -ub -rub paludis-1.4.2.org/python/metadata_key_TEST.py paludis-1.4.2/python/metadata_key_TEST.py >--- paludis-1.4.2.org/python/metadata_key_TEST.py 2013-02-11 01:16:31.000000000 +0400 >+++ paludis-1.4.2/python/metadata_key_TEST.py 2013-12-10 20:38:23.000000000 +0400 >@@ -35,8 +35,8 @@ > class TestCase_01_MetadataKeys(unittest.TestCase): > def setUp(self): > self.e = EnvironmentFactory.instance.create("") >- self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next() >- self.ipid = iter(self.e.fetch_repository("installed").package_ids("cat-one/pkg-one", [])).next() >+ self.pid = next(iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", []))) >+ self.ipid = next(iter(self.e.fetch_repository("installed").package_ids("cat-one/pkg-one", []))) > > def test_02_installed_time(self): > self.assertEquals(self.pid.find_metadata("INSTALLED_TIME"), None) >@@ -70,7 +70,7 @@ > > def parse_value(self): > e = EnvironmentFactory.instance.create("") >- pid = iter(e.fetch_repository("testrepo").package_ids("foo/bar", [])).next() >+ pid = next(iter(e.fetch_repository("testrepo").package_ids("foo/bar", []))) > return pid > > def raw_name(self): >diff -ub -rub paludis-1.4.2.org/python/name.cc paludis-1.4.2/python/name.cc >--- paludis-1.4.2.org/python/name.cc 2013-05-23 04:45:24.000000000 +0400 >+++ paludis-1.4.2/python/name.cc 2013-12-11 02:19:58.000000000 +0400 >@@ -188,7 +188,16 @@ > "[ro] PackageNamePart" > ) > >+#if PY_MAJOR_VERSION < 3 > .def("__cmp__", &py_cmp<QualifiedPackageName>) >+# else >+ .def(bp::self == bp::self) >+ .def(bp::self != bp::self) >+ .def(bp::self < bp::self) >+ .def(bp::self <= bp::self) >+ .def(bp::self > bp::self) >+ .def(bp::self >= bp::self) >+# endif > > .def(bp::self_ns::str(bp::self)) > ; >diff -ub -rub paludis-1.4.2.org/python/package_id_TEST.py paludis-1.4.2/python/package_id_TEST.py >--- paludis-1.4.2.org/python/package_id_TEST.py 2013-02-11 01:16:31.000000000 +0400 >+++ paludis-1.4.2/python/package_id_TEST.py 2013-12-10 20:38:23.000000000 +0400 >@@ -33,9 +33,9 @@ > class TestCase_01_PackageID(unittest.TestCase): > def setUp(self): > self.e = EnvironmentFactory.instance.create("") >- self.pid = iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", [])).next() >- self.ipid = iter(self.e.fetch_repository("installed").package_ids("cat-one/pkg-one", [])).next() >- self.mpid = iter(self.e.fetch_repository("testrepo").package_ids("cat/masked", [])).next() >+ self.pid = next(iter(self.e.fetch_repository("testrepo").package_ids("foo/bar", []))) >+ self.ipid = next(iter(self.e.fetch_repository("installed").package_ids("cat-one/pkg-one", []))) >+ self.mpid = next(iter(self.e.fetch_repository("testrepo").package_ids("cat/masked", []))) > > def test_01_get(self): > pass >@@ -102,7 +102,7 @@ > self.assert_(self.mpid.masked) > > def test_13_masks(self): >- mask = iter(self.mpid.masks).next() >+ mask = next(iter(self.mpid.masks)) > self.assert_(isinstance(mask, UnacceptedMask)) > > def test_18_build_dependencies_key(self): >@@ -139,7 +139,7 @@ > > def test_28_from_repositories_key(self): > self.assertEquals(self.pid.from_repositories_key(), None) >- self.assertEquals(iter(self.ipid.from_repositories_key().parse_value()).next(), "origin_test") >+ self.assertEquals(next(iter(self.ipid.from_repositories_key().parse_value())), "origin_test") > > def test_30_fs_location_key(self): > self.assert_(isinstance(self.ipid.fs_location_key(), MetadataFSPathKey)) >diff -ub -rub paludis-1.4.2.org/python/paludis_python.hh paludis-1.4.2/python/paludis_python.hh >--- paludis-1.4.2.org/python/paludis_python.hh 2013-09-02 12:13:14.000000000 +0400 >+++ paludis-1.4.2/python/paludis_python.hh 2013-12-10 20:38:23.000000000 +0400 >@@ -92,7 +92,15 @@ > doc += "\n\t" + e_name_up; > } > PyTypeObject * pto = reinterpret_cast<PyTypeObject *>(enum_.ptr()); >- PyDict_SetItemString(pto->tp_dict, "__doc__", PyString_FromString(doc.c_str())); >+ PyDict_SetItemString( >+ pto->tp_dict >+ , "__doc__" >+#if PY_MAJOR_VERSION < 3 >+ , PyString_FromString(doc.c_str()) >+#else >+ , PyUnicode_FromString(doc.c_str()) >+#endif >+ ); > } > > // Compare >@@ -128,7 +136,11 @@ > static PyObject * > convert(const T_ & x) > { >+#if PY_MAJOR_VERSION < 3 > return PyString_FromString(stringify<T_>(x).c_str()); >+#else >+ return PyUnicode_FromString(stringify<T_>(x).c_str()); >+#endif > } > }; > >diff -ub -rub paludis-1.4.2.org/python/version_spec.cc paludis-1.4.2/python/version_spec.cc >--- paludis-1.4.2.org/python/version_spec.cc 2013-05-23 04:45:24.000000000 +0400 >+++ paludis-1.4.2/python/version_spec.cc 2013-12-11 02:13:00.000000000 +0400 >@@ -95,7 +95,16 @@ > "Revision part only (or \"r0\")." > ) > >+#if PY_MAJOR_VERSION < 3 > .def("__cmp__", &VersionSpec::compare) >+#else >+ .def(bp::self == bp::self) >+ .def(bp::self != bp::self) >+ .def(bp::self < bp::self) >+ .def(bp::self <= bp::self) >+ .def(bp::self > bp::self) >+ .def(bp::self >= bp::self) >+#endif > > .def(bp::self_ns::str(bp::self)) > ; >diff -ub -rub paludis-1.4.2.org/python/wrapped_value.hh paludis-1.4.2/python/wrapped_value.hh >--- paludis-1.4.2.org/python/wrapped_value.hh 2013-05-23 04:45:24.000000000 +0400 >+++ paludis-1.4.2/python/wrapped_value.hh 2013-12-11 03:01:56.000000000 +0400 >@@ -43,10 +43,20 @@ > boost::python::init<const typename WrappedValueTraits<Tag_>::UnderlyingType &>(("__init__("+init_arg+")").c_str()) > ) > { >- this->def(boost::python::self_ns::str(boost::python::self)); >- this->def("__cmp__", >- &paludis::python::py_cmp<WrappedValue<Tag_> >); >- boost::python::implicitly_convertible<typename WrappedValueTraits<Tag_>::UnderlyingType, >+ namespace bp = boost::python; >+ this->def(bp::self_ns::str(bp::self)) >+#if PY_MAJOR_VERSION < 3 >+ .def("__cmp__", &paludis::python::py_cmp<WrappedValue<Tag_> >) >+# else >+ .def(bp::self == bp::self) >+ .def(bp::self != bp::self) >+ .def(bp::self < bp::self) >+ .def(bp::self <= bp::self) >+ .def(bp::self > bp::self) >+ .def(bp::self >= bp::self) >+# endif >+ ; >+ bp::implicitly_convertible<typename WrappedValueTraits<Tag_>::UnderlyingType, > WrappedValue<Tag_> >(); > } > };
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 493906
:
365096
|
365098