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 stitched 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.2.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.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fishhook-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 4fcc1a0dbcdb1d9c5235982a4c902f9e91f1a213b5f7d3da861ef1c475db9e72
MD5 2477b5d01014b515b1ef0e22eea23548
BLAKE2b-256 4f79f9cb0b68dbf954687694e5d739dc2d2c2dd4b78f466f16339e14a3beaf48

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fishhook-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1ee2eb20b96d5feb03adaab68e44f9f26d54fed48638e9ed906ab00edd0a1512
MD5 ebeb190bf8d7ccb776aa5f284a444f3b
BLAKE2b-256 264bad2a252ea842530bcb4a446e619bc0f91c01e33d1ac7343544ad676cc65b

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