Skip to main content

pyjack

pyjack is a debug/test/monkey-patching toolset that allows you to reversibly replace all references to a function or object in memory with a proxy function or object. pyjack has two major functions:

  • function “connect” can connect a ‘proxy’ function to almost any python function/method. This proxy function is called instead of the original function. However, the original function is passed to the proxy function along with all args, kwargs so you can do things like:

    • Modify the args, kwargs first, print a debug message, then call the original function

    • Not call the function, rather just log it and print a debug message

    etc. etc. – it’s all up to you.

  • function “replace_all_refs” can be used to replace all references to a object with references to another object. This replaces all references in the _entire_ memory space. You get one final reference to the original reference, so it is possible to call this function again to restore the memory state back to it’s original state.

“connect” function

>>> import pyjack
>>>
>>> def fakeimport(orgopen, *args, **kwargs):
...     print 'Trying to import %s' % args[0]
...     return 'MODULE_%s' % args[0]
...
>>> pyjack.connect(__import__, proxyfn=fakeimport)
<..._PyjackFuncBuiltin object at 0x...>
>>>
>>> import time
Trying to import time
>>> print time
MODULE_time
>>>
>>> __import__.restore()
>>>
>>> import time
>>> print time
<module 'time' (built-in)>

“replace_all_refs” function

Setup an ‘item’ reference and put it in a few places:

>>> item = (100, 'one hundred')
>>> data = {item: True, 'itemdata': item}
>>>
>>> class Foobar(object):
...     the_item = item
...
>>> def outer(datum):
...     def inner():
...         return ("Here is the datum:", datum,)
...
...     return inner
...
>>> inner = outer(item)
>>>
>>> print item
(100, 'one hundred')
>>> print data
{'itemdata': (100, 'one hundred'), (100, 'one hundred'): True}
>>> print Foobar.the_item
(100, 'one hundred')
>>> print inner()
('Here is the datum:', (100, 'one hundred'))

Then replace them:

>>> new = (101, 'one hundred and one')
>>> org_item = pyjack.replace_all_refs(item, new)
>>>
>>> print item
(101, 'one hundred and one')
>>> print data
{'itemdata': (101, 'one hundred and one'), (101, 'one hundred and one'): True}
>>> print Foobar.the_item
(101, 'one hundred and one')
>>> print inner()
('Here is the datum:', (101, 'one hundred and one'))

But you still have one final reference to the org data:

>>> print org_item
(100, 'one hundred')

So the process is reversible:

>>> new = pyjack.replace_all_refs(new, org_item)
>>>
>>> print item
(100, 'one hundred')
>>> print data
{'itemdata': (100, 'one hundred'), (100, 'one hundred'): True}
>>> print Foobar.the_item
(100, 'one hundred')
>>> print inner()
('Here is the datum:', (100, 'one hundred'))

Other References

For full documentation and several examples please visit:

The git repo is here:

Metadata

Release files for pyjack 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for pyjack 0.3.2
File Size Uploaded Provenance Actions
pyjack-0.3.2.zip 9.0 kB Without provenance Details for pyjack-0.3.2.zip
pyjack-0.3.2.tar.gz 5.3 kB Without provenance Details for pyjack-0.3.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyjack 0.3.2
File Actions
pyjack-0.3.2.win-amd64-py2.7.exe Details for pyjack-0.3.2.win-amd64-py2.7.exe
pyjack-0.3.2.win-amd64-py2.6.exe Details for pyjack-0.3.2.win-amd64-py2.6.exe
pyjack-0.3.2.win32-py2.7.exe Details for pyjack-0.3.2.win32-py2.7.exe
pyjack-0.3.2.win32-py2.6.exe Details for pyjack-0.3.2.win32-py2.6.exe
pyjack-0.3.2.win32-py2.5.exe Details for pyjack-0.3.2.win32-py2.5.exe
pyjack-0.3.2.win32-py2.4.exe Details for pyjack-0.3.2.win32-py2.4.exe
pyjack-0.3.2-py2.7.egg Legacy Egg format - - Details for pyjack-0.3.2-py2.7.egg
pyjack-0.3.2-py2.6.egg Legacy Egg format - - Details for pyjack-0.3.2-py2.6.egg
pyjack-0.3.2-py2.5.egg Legacy Egg format - - Details for pyjack-0.3.2-py2.5.egg
pyjack-0.3.2-py2.4.egg Legacy Egg format - - Details for pyjack-0.3.2-py2.4.egg

Total release size: 941.2 kB

Release files / pyjack-0.3.2.zip

Download URL pyjack-0.3.2.zip
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
3b3d54b0c9900e4cbd688161ba8a93c6073258d2a2140b76c1a6c868415c1441
BLAKE2b-256 checksum
How to use checksums
5812632d618f2c33611e6d34a47bfdfc8567d83ae08c7d3dd640a0b48dd0a241
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2.tar.gz

Download URL pyjack-0.3.2.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1c0e55c66f69c89edcc7f24ad806d7712e702fb10adc1868285ec25971c5bf3b
BLAKE2b-256 checksum
How to use checksums
1a8fb51bba149c353b55a5ccea1d7c3040be22913d2d5bb9057f992e1e87784e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2.win-amd64-py2.7.exe

Download URL pyjack-0.3.2.win-amd64-py2.7.exe
Size 233.4 kB
Tags Source
SHA-256 checksum
How to use checksums
23951d9acea8562639ab83cbf2f17fa9d5c5a0d08d88d60afcc25ad0ee5cd07b
BLAKE2b-256 checksum
How to use checksums
3460b87a31e4725ce3dd9035897caa03e7a08c85d54f351940a6c8eb2e99076b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2.win-amd64-py2.6.exe

Download URL pyjack-0.3.2.win-amd64-py2.6.exe
Size 233.4 kB
Tags Source
SHA-256 checksum
How to use checksums
7b8cc3499bd517e81911e65fb86b15faa97132550101efc0b3126a76514309b6
BLAKE2b-256 checksum
How to use checksums
bbeace77c3c54c7593104adc362419b08365a63853dec4f1caea142c61d5a6e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2.win32-py2.7.exe

Download URL pyjack-0.3.2.win32-py2.7.exe
Size 205.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ab1faa47750ed7c4c6c9c2267e3b8fd2682e2e7f873fecddc734cb86abaec50a
BLAKE2b-256 checksum
How to use checksums
96db84579ebf91af55dcf668f7dbf75c640e1d0596fc34da623aaf906bb1b949
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2.win32-py2.6.exe

Download URL pyjack-0.3.2.win32-py2.6.exe
Size 75.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a3690ede6974f405ec92c8409da4b79f7760f5a25bc43373f271d6bfa136bafe
BLAKE2b-256 checksum
How to use checksums
6906ad6b38bf65f221a8b490998892349921edc7cde61cb6afdf5c1dfd66547f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2.win32-py2.5.exe

Download URL pyjack-0.3.2.win32-py2.5.exe
Size 71.1 kB
Tags Source
SHA-256 checksum
How to use checksums
928dd25ef5479575d1233c89a1355a907ffda6962531a205393c46e8fec2c92c
BLAKE2b-256 checksum
How to use checksums
8d5fb63046ece1abdbc04169495b11ac9f032815d34fcd7b8998b5c7a10a4bc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2.win32-py2.4.exe

Download URL pyjack-0.3.2.win32-py2.4.exe
Size 71.1 kB
Tags Source
SHA-256 checksum
How to use checksums
02d16aac42066397cc06c9b014d7b0333b73c9b3336f336ca75fae58986d9352
BLAKE2b-256 checksum
How to use checksums
4081e73561409d9b7cae33a58e37027d38cd5f8143d1a0ca9d49b8c7a2893893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2-py2.7.egg

Download URL pyjack-0.3.2-py2.7.egg
Size 9.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
979db3afdd182763ccd4e7b9734b2cd0d1cc3a7df5c15e532e19ffce89b08e0d
BLAKE2b-256 checksum
How to use checksums
812b55092919b048afd6c41126faafc82b53d34d4a2ab0bc4b2ed9471cc7a588
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2-py2.6.egg

Download URL pyjack-0.3.2-py2.6.egg
Size 9.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
f827766a7344fa0c5a86d4a95041cd3d038ccc15b27385d7be001a77ab16ffb2
BLAKE2b-256 checksum
How to use checksums
ba8212c5b08ae3a0c73528f4e89d0526ebc8bf9b2e210d724e3e42bf560dd0ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2-py2.5.egg

Download URL pyjack-0.3.2-py2.5.egg
Size 9.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
2f3b14b670c7a38002fcc312f9482774ee0ac7f80c8865a1dd70a7559fe49886
BLAKE2b-256 checksum
How to use checksums
90a39f22991ea3c3205076a13f51cb78f63c94f1235ac051181eed6b544f5830
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyjack-0.3.2-py2.4.egg

Download URL pyjack-0.3.2-py2.4.egg
Size 9.2 kB
Tags Egg
SHA-256 checksum
How to use checksums
02ccdc3661b7af9b846feae78fc06ca5dcf23f947a0b8d2566c5300a14606357
BLAKE2b-256 checksum
How to use checksums
faab5c36438099aaa003eaf0a66f1143fc6df0a0dc1161e7f484a9584d2416d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pyjack 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page