Skip to content

Commit

Permalink
More python deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
AllSeeingEyeTolledEweSew authored and arvidn committed Jul 25, 2021
1 parent b568b12 commit beb15f8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 27 deletions.
2 changes: 1 addition & 1 deletion bindings/python/src/create_torrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void bind_create_torrent()
.def("set_creation_date", &create_torrent::set_creation_date)
.def("set_hash", &set_hash)
#if TORRENT_ABI_VERSION < 3
.def("set_file_hash", &set_file_hash)
.def("set_file_hash", depr(&set_file_hash))
#endif
.def("add_url_seed", &create_torrent::add_url_seed)
#if TORRENT_ABI_VERSION < 4
Expand Down
9 changes: 8 additions & 1 deletion bindings/python/src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <libtorrent/bencode.hpp>
#include <libtorrent/bdecode.hpp>
#include "bytes.hpp"
#include "gil.hpp"

using namespace boost::python;
using namespace lt;
Expand Down Expand Up @@ -88,6 +89,12 @@ struct bytes_from_python
};

#if TORRENT_ABI_VERSION == 1
std::string identify_client_(const peer_id& p)
{
python_deprecated("identify_client is deprecated");
return lt::identify_client(p);
}

object client_fingerprint_(peer_id const& id)
{
python_deprecated("client_fingerprint is deprecated");
Expand Down Expand Up @@ -117,7 +124,7 @@ void bind_utility()
bytes_from_python();

#if TORRENT_ABI_VERSION == 1
def("identify_client", &lt::identify_client);
def("identify_client", &identify_client_);
def("client_fingerprint", &client_fingerprint_);
#endif
def("bdecode", &bdecode_);
Expand Down
9 changes: 1 addition & 8 deletions bindings/python/tests/create_torrent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,19 +390,12 @@ def test_set_hash_short(self) -> None:
with self.assertRaises(ValueError):
ct.set_hash(0, lib.get_random_bytes(19))

@unittest.skip("https://github.com/arvidn/libtorrent/issues/5967")
def test_set_file_hash_deprecated(self) -> None:
def test_set_file_hash(self) -> None:
fs = lt.file_storage()
fs.add_file("test.txt", 1024)
ct = lt.create_torrent(fs)
with self.assertWarns(DeprecationWarning):
ct.set_file_hash(0, lib.get_random_bytes(20))

def test_set_file_hash(self) -> None:
fs = lt.file_storage()
fs.add_file("test.txt", 1024)
ct = lt.create_torrent(fs)
ct.set_file_hash(0, lib.get_random_bytes(20))
ct.set_hash(0, lib.get_random_bytes(20))
entry = ct.generate()
self.assertIn(b"sha1", entry[b"info"])
Expand Down
5 changes: 0 additions & 5 deletions bindings/python/tests/torrent_handle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,6 @@ def test_info_hash(self) -> None:
self.handle.info_hashes(), lt.info_hash_t(self.torrent.sha1_hash)
)

@unittest.skip("https://github.com/arvidn/libtorrent/issues/5967")
def test_info_hash_deprecated(self) -> None:
with self.assertWarns(DeprecationWarning):
self.handle.info_hash()


class ForceRecheckTest(TorrentHandleTest):
def test_force_recheck(self) -> None:
Expand Down
6 changes: 0 additions & 6 deletions bindings/python/tests/torrent_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,6 @@ def test_info_hash(self) -> None:
ti = lt.torrent_info(lt.info_hash_t(sha1))
self.assertEqual(ti.info_hashes(), lt.info_hash_t(sha1))

@unittest.skip("https://github.com/arvidn/libtorrent/issues/5967")
def test_sha1_hash_deprecated(self) -> None:
sha1 = lt.sha1_hash(lib.get_random_bytes(20))
with self.assertWarns(DeprecationWarning):
lt.torrent_info(sha1)

def test_sha1_hash(self) -> None:
sha1 = lt.sha1_hash(lib.get_random_bytes(20))
ti = lt.torrent_info(sha1)
Expand Down
8 changes: 2 additions & 6 deletions bindings/python/tests/utility_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,9 @@ def test_nonstandard_types(self) -> None:


class IdentifyClientTest(unittest.TestCase):
@unittest.skip("https://github.com/arvidn/libtorrent/issues/5967")
def test_deprecated(self) -> None:
with self.assertWarns(DeprecationWarning):
lt.identify_client(lt.sha1_hash())

def test_identify_client(self) -> None:
self.assertEqual(lt.identify_client(lt.sha1_hash()), "Unknown")
with self.assertWarns(DeprecationWarning):
self.assertEqual(lt.identify_client(lt.sha1_hash()), "Unknown")


class ClientFingerprintTest(unittest.TestCase):
Expand Down

0 comments on commit beb15f8

Please sign in to comment.