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.0.6.tar.gz (3.9 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.0.6-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fishhook-0.0.6.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for fishhook-0.0.6.tar.gz
Algorithm Hash digest
SHA256 32f7376b74501db1e08dd861d2ef69456e23534bcb6cb877bcbfe40268b0bb13
MD5 18069aa026cd5aa2f327d2d8b527624e
BLAKE2b-256 4b7a26ffaa4db0b06e9e915a6a8b3d8e04e8e09c76443e0a001e23218179b29f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fishhook-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for fishhook-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 22bbdb644a0fed38fbe15467ba112bd3e61c32b82f421abb2a945e7c222ef107
MD5 63832b91ea60f318749fe180281d82e9
BLAKE2b-256 7e7cbe7d34327b5a1a6524f0b3d1bf1aa8d2828ab7e5834b7628151efdf3795d

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