Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Unable to open '<decorator-gen-660>': File not found (file:///.../myworkspace/<decorator-gen-660>). #1177

Closed
joseortiz3 opened this issue Feb 25, 2019 · 4 comments

Comments

@joseortiz3
Copy link

joseortiz3 commented Feb 25, 2019

Environment data

  • PTVSD version: Whatever is included in extension ms-python.python-2019.1.0
  • OS and version: Win 10 Pro build 17763
  • Python version (& distribution if applicable, e.g. Anaconda): plain python 3.7.1, no anaconda
  • Using VS Code or Visual Studio: VS Code

Actual behavior

I'm trying to debug-step-into the last line of this script:

import networkx as nx
import numpy as np
import matplotlib.pyplot as plt

edges = ((16103, 4423, {'sel_frac': 0.10104208846993425}), (58975, 4423, {'sel_frac': 0.11392450913277707}), (43510, 41220, {'sel_frac': 0.10052701693748936}), (45700, 41220, {'sel_frac': 0.11816510197282526}), (79350, 44800, {'sel_frac': 0.09355756316139689}), (15345, 50090, {'sel_frac': 0.10798202394419384}), (25610, 50090, {'sel_frac': 0.13080150443192698}), (21700, 51630, {'sel_frac': 0.13016626070338505}), (74510, 51630, {'sel_frac': 0.14163814697449248}), (75660, 86300, {'sel_frac': 0.10210561210316822}))

G = nx.DiGraph()
G.add_edges_from(edges)

# SET BREAKPOINT ON THE LINE BELOW, STEP INTO
pos = nx.spring_layout(G,iterations=5000)

with
image

Stepping into (F11) the function nx.spring_layout does not work. Nothing happens, no error message, nada. I right-click nx.spring_layout and click "go to definition", and it takes me to the correct file ...\python37\lib\site-packages\networkx-2.2-py3.7.egg\networkx\drawing\layout.py.

So the inability to step into the execution is one distinct failure.

I try setting a breakpoint in that layout.py file:

image

but when the breakpoint is hit, it results in the error

Unable to open '<decorator-gen-658>': File not found (file:///c:/users/joey/onedrive/documents/code/python/systemicrisk/dataexploration/<decorator-gen-658>).

image

This may be related to #85 from a year ago

Expected behavior

Feature should work

Steps to reproduce:

  1. Repeat what I did here.
@karthiknadig
Copy link
Member

Same as #1071

@joseortiz3
Copy link
Author

joseortiz3 commented Mar 1, 2019

Not quite the same, careful. They might have the same solution but they are different issues. The one you cited is for stepping over. This is stepping into in the first half, and notably there is no error message for stepping into. Also there is a failure even without stepping over - it is any break-point inside certain sections of the code.

@int19h
Copy link
Contributor

int19h commented Mar 1, 2019

The inability to step into this function is most likely because you do not have debugging on the standard library enabled - everything that is in site-packages is considered "standard library", so this includes pip-installed modules. See DebugStdLib here on how to enable it:

https://code.visualstudio.com/docs/python/debugging#_debugoptions

The exact semantics of Step In is basically "run until a different line of Python code starts executing", excluding any code that belongs to the debugger itself, or to the standard library depending on the setting mentioned earlier. So in that sense it can never fail and doesn't have any errors to report, but it can be equivalent to a Step Over in the most extreme case - if all the code that's inside the call is excluded, or if there was no Python code to run at all (e.g. for native functions).

So, if stdlib debugging is disabled, you cannot step into functions inside side-packages. However, if those functions in turn call some other code - e.g. your code via a callback - then that becomes the first different line of Python code when stepping in, and that's where the debugger stops. So if you step into something like foo(bar), where foo is an stdlib function, and bar is your callback, it will stop on the first line of bar.

In this particular case, though, the function is calling some other code that, so far as I can tell, it has generated dynamically at runtime. That code has <decorator-gen-658> as the associated source file name. Because it's not a path, the check for site-packages does not consider it a part of stdlib. Consequently, it's treated as user code, and that's where the step actually stops. But then it's not actually a file on disk, so VS Code cannot open it, producing the error that you're seeing.

So, the root cause for the error message that you see is the same as in #1071 - debugger should not stop on Python code that doesn't have a corresponding source file at all, regardless of what kind of step it's making. The expected behavior with steps as described would be to step over the line with nx.spring_layout.

OTOH, to be able to step into the implementation of spring_layout, or to set breakpoints inside that library and have debugger stop there, enabling DebugStdLib should do the trick. Can you give it a try and see if it does everything you expect then? If not, then we have a separate issue here that's related to the proper handling of that flag.

@joseortiz3
Copy link
Author

joseortiz3 commented Mar 1, 2019

Yep, that fixed the "no error message" part, I didn't have

    "configurations": [
        {
            "name": "Python: Current File (Integrated Terminal)",
            (blah blah blah),
            "debugStdLib": true
        }, ...

So never-mind, same issue as #1071.

Also I learned so much from your post!! Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants