Coder Social home page Coder Social logo

pyspy's Introduction

Hi there ๐Ÿ‘‹

  • Discord: svenskithesource
  • Python ๐Ÿคฉ
  • Reverse Engineering (especially in Python, send over any samples you have)
  • Currently working on many projects, feel free to contribute

pyspy's People

Contributors

svenskithesource avatar tcortega avatar thatbirdguythatuknownot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pyspy's Issues

'NoneType' object is not iterable

Ok so i tried to edit some random .pyc that and i just changed 1 letter and when i export them i got this error, any fix?

used
used
used
used
used
used
used
used
used
used
used
used
Traceback (most recent call last):
File "C:\Users[MyPc'sNamexD]\Desktop\pySpy\pyspy.py", line 31, in export
file.write(header + marshal.dumps(main_code.to_native()))
File "C:\Users[MyPc'sNamexD]\Desktop\pySpy\editor.py", line 112, in to_native
const = code[0].to_native()
File "C:\Users[MyPc'sNamexD]\Desktop\pySpy\editor.py", line 111, in to_native
code = [e for e in code_objects if str(const.uid) == str(e.uid)]
TypeError: 'NoneType' object is not iterable

error

when I edit a file . pyc, after I save the file and execute it I get an error:
Fatal Python error: PyFrame_BlockPop: block stack underflow
Python runtime state: initialized

Current thread 0x00002df0 (most recent call first):
File "test.py", line 199 in

Extension modules: _brotli, _cffi_backend, cchardet._cchardet, lxml._elementpath, lxml.etree, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, PIL._imaging (total: 19)

[BUG] Add const feature doesn't work as expect

There is currently two bugs with the current state of the code, the first one is present at:

pySpy/pyspy/pyspy.py

Lines 120 to 122 in 31bc912

current_file.co_names = list(current_file.co_consts)
current_file.co_consts.append(value)
current_file.co_names = tuple(current_file.co_consts)

It's applying the co_consts value in the co_names property incorrectly.

The second bug is here:

pySpy/pyspy/pyspy.py

Lines 326 to 330 in 31bc912

if not isinstance(value, types.CodeType) and not isinstance(value, editor.Code):
with dpg.table_row():
dpg.add_text(index)
dpg.add_input_text(default_value=repr(value), tag=f"const_{index}", width=400,
user_data="co_consts_apply", callback=apply_changes, on_enter=True)

Whenever there is a code object within the co_consts attribute, this object gets skipped, but the index does not remain the same, since it is coming from an enumerate function.

This results in a bug in the function that applies the changes that happened to the consts, since the index of the code object that was skipped, will return None.

pySpy/pyspy/pyspy.py

Lines 65 to 71 in 31bc912

while True:
value = dpg.get_value(f"const_{i}")
if value is None:
break
new_consts.append(ast.literal_eval(value))
i += 1

The "ideal" solution would be having a custom counter, but this would result on yet another bug, if we look closely at the code mentioned above, we can see that it updates the co_consts based on the list that is saved at the Dear PyGui internals. But if we skip the code while adding and displaying it, the code will never be there, which would cause every code object to be lost from the co_consts list.

We need to find a way to display the code objects but do not allow the user to modify it on the const view, and then get this code objects while saving the new co_const list, since simply calling ast.literal_eval wouldn't work in this scenario.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.