fix python dictionary to settings_pack conversion bug (#652)

This commit is contained in:
Arvid Norberg 2016-04-27 12:28:22 -04:00
parent 96b7d3ad46
commit 80710abcbf
3 changed files with 8 additions and 5 deletions

View File

@ -1,5 +1,6 @@
1.1.1 release
* fix set_settings in python binding
* Added missing alert categories in python binding
* Added dht_get_peers_reply_alert alert in python binding

View File

@ -101,16 +101,17 @@ namespace
void make_settings_pack(lt::settings_pack& p, dict const& sett_dict)
{
list iterkeys = (list)sett_dict.keys();
for (int i = 0; i < boost::python::len(iterkeys); i++)
int const len = boost::python::len(iterkeys);
for (int i = 0; i < len; i++)
{
std::string key = extract<std::string>(iterkeys[i]);
std::string const key = extract<std::string>(iterkeys[i]);
int sett = setting_by_name(key);
if (sett == 0) continue;
if (sett < 0) continue;
TORRENT_TRY
{
object value = sett_dict[key];
object const value = sett_dict[key];
switch (sett & settings_pack::type_mask)
{
case settings_pack::string_type_base:

View File

@ -156,8 +156,9 @@ class test_session(unittest.TestCase):
def test_apply_settings(self):
s = lt.session({})
s.apply_settings({'num_want': 66})
s.apply_settings({'num_want': 66, 'user_agent': 'test123'})
self.assertEqual(s.get_settings()['num_want'], 66)
self.assertEqual(s.get_settings()['user_agent'], 'test123')
if __name__ == '__main__':