treat an unknown key in a settings_pack as an error in python (#1287)
This commit is contained in:
parent
c1fbd31bf1
commit
11856d64e9
|
@ -112,7 +112,11 @@ namespace
|
|||
std::string const key = extract<std::string>(iterkeys[i]);
|
||||
|
||||
int sett = setting_by_name(key);
|
||||
if (sett < 0) continue;
|
||||
if (sett < 0)
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError, ("unknown name in settings_pack: " + key).c_str());
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
TORRENT_TRY
|
||||
{
|
||||
|
|
|
@ -81,7 +81,7 @@ class test_torrent_info(unittest.TestCase):
|
|||
idx = 0
|
||||
expected = ['bar.txt', 'var.txt']
|
||||
for f in files:
|
||||
print f.path
|
||||
print(f.path)
|
||||
|
||||
self.assertEqual(os.path.split(f.path)[1], expected[idx])
|
||||
self.assertEqual(os.path.split(os.path.split(f.path)[0]), ('temp', 'foo'))
|
||||
|
@ -165,6 +165,13 @@ class test_session(unittest.TestCase):
|
|||
self.assertTrue(isinstance(a.values, dict))
|
||||
self.assertTrue(len(a.values) > 0)
|
||||
|
||||
def test_unknown_settings(self):
|
||||
try:
|
||||
s = lt.session({'unexpected-key-name': 42})
|
||||
self.assertFalse('should have thrown an exception')
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def test_deprecated_settings(self):
|
||||
|
||||
# this detects whether libtorrent was built with deprecated APIs
|
||||
|
|
Loading…
Reference in New Issue