Base: remove Py2 code

This commit is contained in:
luz paz
2021-04-23 12:48:46 -04:00
committed by wwmayer
parent 1d4722f32c
commit 59b7e9fdd0
16 changed files with 0 additions and 546 deletions

View File

@@ -572,7 +572,6 @@ PyStreambuf::int_type PyStreambuf::underflow()
try {
std::string c;
Py::Object res(meth.apply(arg));
#if PY_MAJOR_VERSION >= 3
if (res.isBytes()) {
c = static_cast<std::string>(Py::Bytes(res));
}
@@ -583,9 +582,6 @@ PyStreambuf::int_type PyStreambuf::underflow()
// wrong type
return traits_type::eof();
}
#else
c = static_cast<std::string>(Py::String(res));
#endif
n = c.size();
if (n == 0) {
return traits_type::eof();
@@ -656,11 +652,7 @@ bool PyStreambuf::writeStr(const char* str, std::streamsize num)
return true;
}
else if (type == BytesIO) {
#if PY_MAJOR_VERSION >= 3
arg.setItem(0, Py::Bytes(str, num));
#else
arg.setItem(0, Py::String(str, num));
#endif
meth.apply(arg);
return true;
}
@@ -675,11 +667,7 @@ bool PyStreambuf::writeStr(const char* str, std::streamsize num)
catch (Py::Exception& e) {
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
e.clear();
#if PY_MAJOR_VERSION >= 3
arg.setItem(0, Py::Bytes(str, num));
#else
arg.setItem(0, Py::String(str, num));
#endif
meth.apply(arg);
type = BytesIO;
return true;