• 0 Posts
  • 2 Comments
Joined 1 year ago
cake
Cake day: August 6th, 2023

help-circle
  • Yeah. ‘lib’ isn’t a standard Python library, it’s the name of the abomination that this person created. Since python has quite a bit of useful introspection, they can do something like:

    • get the stack
    • find the exact call to abomination.add()
    • reparse the text of that line, turn the text of the comment into actual numbers, and add them

    Now, I don’t know if python keeps the comments around, so it may involve getting the filename and line number, reading the file, and manually extracting the comment text from that line.


  • Sure, but let’s just clarify that this is someone going out of their way to create this problem, using Python’s ability to read it’s own code.

    Basically, you can load any text file, including a source code file, and do whatever you want with it.

    So, a function can be written that finds out whatever’s calling it, reads that file, parses the comments, and uses them as values. This can also be done with introspection, using the same mechanism that displays tracebacks.