the session constructor taking a settings_pack directly was deprecated, but this is still the only way to construct a session via the python bindings. session_params does not have a python binding (yet). When updating the python binding, there was an incorrect assumption that the session would be constructed via an implicitly created session_params object (which would happen if deprecated functions was disabled). However, when the session is constructed with the deprecated settings_pack, the flags actually matter for adding default plugins. The python binding could be improved in this regard, ideally to better match the C++ API by having a session_params object

This commit is contained in:
Arvid Norberg
2020-12-24 06:58:44 +01:00
committed by Arvid Norberg
parent 12ec9ee162
commit 634497af0e
2 changed files with 22 additions and 3 deletions
+1
View File
@@ -1,3 +1,4 @@
* fix python binding regression in session constructor flags
* fix unaligned piece requests in mmap_storage
* improve client_data_t ergonomics
* fix issue with concurrent access to part files
+21 -3
View File
@@ -180,7 +180,20 @@ namespace
{
settings_pack p;
make_settings_pack(p, sett);
return std::make_shared<lt::session>(p, flags);
#if TORRENT_ABI_VERSION <= 2
if (flags & lt::session::add_default_plugins)
{
#endif
session_params params(std::move(p));
return std::make_shared<lt::session>(std::move(params), flags);
#if TORRENT_ABI_VERSION <= 2
}
else
{
session_params params(std::move(p), {});
return std::make_shared<lt::session>(std::move(params), flags);
}
#endif
}
void session_apply_settings(lt::session& ses, dict const& sett_dict)
@@ -961,9 +974,14 @@ void bind_session()
scope s = class_<lt::session, boost::noncopyable>("session", no_init)
.def("__init__", boost::python::make_constructor(&make_session
, default_call_policies()
, (arg("settings"), arg("flags")=lt::session_flags_t{})
, (arg("settings"), arg("flags")=
#if TORRENT_ABI_VERSION <= 2
lt::session::add_default_plugins
#else
lt::session_flags_t{}
#endif
))
)
)
#if TORRENT_ABI_VERSION == 1
.def(
init<fingerprint, session_flags_t, alert_category_t>((