Skip to main content

Allows for runtime hooking of static class functions

Project description

Fishhook

This module allows for swapping out the slot pointers contained in static classes with the generic slot pointers used by python for heap classes. This allows for assigning arbitrary python functions to static class dunders using hook and hook_cls and for applying new functionality to previously unused dunders. A hooked static dunder can be restored to original functionality using the unhook function

Calling original methods

orig(self, *args, **kwargs) is a special function that looks up the original implementation of a hooked dunder in the methods cache. It will only work properly when used inside a hooked method where an original implementation existed

hooking single methods

@hook(int)
def __add__(self, other):
  ...
  return orig(self, other)

hooking multiple methods

@hook_cls(int)
class int_hook:
  attr = ...

  def __add__(self, other):
    ...

Links

Github

PyPi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fishhook-0.1.3.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fishhook-0.1.3-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file fishhook-0.1.3.tar.gz.

File metadata

  • Download URL: fishhook-0.1.3.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for fishhook-0.1.3.tar.gz
Algorithm Hash digest
SHA256 62f6f5b802900c9249ddde3b087a9ad3043e8beea11ea616f6ddfd296ef53f4d
MD5 1aadbe231a57e635a259742fa106ccb0
BLAKE2b-256 cac5e583af23c851fcf7e9fb79a6165a9918017fb139075fdcf34ef1a3f3ab74

See more details on using hashes here.

File details

Details for the file fishhook-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: fishhook-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for fishhook-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b831013d2de3754d73ccd28ab14e76f4eb8a399892b157f15a9c992575eab465
MD5 e0c9c859a267e845543a32952198a58b
BLAKE2b-256 d1067bec08a45d54d53939d73e13446cff8875bdc9b2bb44a7759777dfb3b0e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page