| skipped 132 lines |
133 | 133 | | fp.write('Stack:\n') |
134 | 134 | | for frameRecord in trace: |
135 | 135 | | fp.write(f' File "{frameRecord.filename}", line {frameRecord.lineno}, in {frameRecord.function}\n') |
136 | | - | for line in frameRecord.code_context: |
137 | | - | fp.write(f' {line.strip()}\n') |
| 136 | + | if frameRecord.code_context is not None: |
| 137 | + | for line in frameRecord.code_context: |
| 138 | + | fp.write(f' {line.strip()}\n') |
138 | 139 | | fp.write('\n') |
139 | 140 | | |
140 | | - | for frameRecord in trace: |
141 | | - | module = inspect.getmodule(frameRecord[0]) |
| 141 | + | modules = [inspect.getmodule(frameRecord[0]) for frameRecord in trace] |
| 142 | + | for i, (module, frameRecord) in enumerate(zip(modules, trace)): |
| 143 | + | if module is None: |
| 144 | + | # Module-less frame, e.g. dataclass.__init__ |
| 145 | + | for j in reversed(range(i)): |
| 146 | + | if modules[j] is not None: |
| 147 | + | break |
| 148 | + | else: |
| 149 | + | # No previous module scope |
| 150 | + | continue |
| 151 | + | module = modules[j] |
142 | 152 | | if not module.__name__.startswith('snscrape.') and module.__name__ != 'snscrape': |
143 | 153 | | continue |
144 | 154 | | locals_ = frameRecord[0].f_locals |
| skipped 185 lines |