Skip to content

add checks to demandload to detect if reification is forced during parse time in modules #115

@ferringb

Description

@ferringb

Roughly, via checking the stack we can see if we're in a module parsing- thus demandload can detect if it just got reify'ied during a module parse, and should flag it since it's not delayed if it's immediately forced to reify. Effectively a demandload should never reify within a module parse.

The 'how' on this takes a bit of fiddling, but this should be doable and would allow eliminating the snakeoil SNAKEOIL_DEMANDLOAD_DISABLED hack.

Note this output: it is possible, so it's just a question of writing the code.

(Pdb) traceback.print_stack()
  File "<string>", line 1, in <module>
    import snakeoil.mappings
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/home/ferringb/gentoo/snakeoil/src/snakeoil/mappings.py", line 30, in <module>
    pdb.set_trace()
  File "/usr/lib/python3.13/bdb.py", line 116, in trace_dispatch
    return self.dispatch_opcode(frame, arg)
  File "/usr/lib/python3.13/bdb.py", line 215, in dispatch_opcode
    self.user_opcode(frame)
  File "/usr/lib/python3.13/pdb.py", line 448, in user_line
    self.interaction(frame, None)
  File "/usr/lib/python3.13/pdb.py", line 625, in interaction
    self._cmdloop()
  File "/usr/lib/python3.13/pdb.py", line 511, in _cmdloop
    self.cmdloop()
  File "/usr/lib/python3.13/cmd.py", line 146, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python3.13/pdb.py", line 865, in onecmd
    return cmd.Cmd.onecmd(self, line)
  File "/usr/lib/python3.13/cmd.py", line 223, in onecmd
    return self.default(line)
  File "/usr/lib/python3.13/pdb.py", line 773, in default
    exec(code, globals, locals)
  File "<stdin>", line 1, in <module>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions