Skip to content

How to debug Python part (gyp itself) of project? #2505

@owl-from-hogvarts

Description

@owl-from-hogvarts

Hello! Thanks for waiting) I'd like to debug the Python part of node-gyp (which is located in gyp folder). Within my previouse contribuiton (#2254 and #2428, which still is not applyed) i have modified some lines of code in gyp folder. For preciouse versions of gyp-next these modifications worked well but after certain update (don't know which exectly) the things have went wrong. So on Windows with Python 3.6 error occures:

Error message (path to file `gyp\pylib\gyp\easy_xml.py`):

Traceback (most recent call last):
  File "D:\a\node-gyp\node-gyp\gyp\gyp_main.py", line 45, in <module>
    sys.exit(gyp.script_main())
  File "D:\a\node-gyp\node-gyp\gyp\pylib\gyp\__init__.py", line 662, in script_main
    return main(sys.argv[1:])
  File "D:\a\node-gyp\node-gyp\gyp\pylib\gyp\__init__.py", line 654, in main
    return gyp_main(args)
  File "D:\a\node-gyp\node-gyp\gyp\pylib\gyp\__init__.py", line 639, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "D:\a\node-gyp\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 2129, in GenerateOutput
    _GenerateProject(project, options, msvs_version, generator_flags, spec)
  File "D:\a\node-gyp\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1016, in _GenerateProject
    return _GenerateMSBuildProject(project, options, version, generator_flags, spec)
  File "D:\a\node-gyp\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 3727, in _GenerateMSBuildProject
    toolset,
  File "D:\a\node-gyp\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 2208, in _GenerateMSBuildFiltersFile
    easy_xml.WriteXmlIfChanged(content, filters_path, pretty=True, win32=True)
  File "D:\a\node-gyp\node-gyp\gyp\pylib\gyp\easy_xml.py", line 127, in WriteXmlIfChanged
    xml_string = xml_string.decode("cp1251").encode(encoding)
AttributeError: 'str' object has no attribute 'decode'

From which we can conclude that there is a type mismatch. I want to figure out, do we still need to tweak in that line of code? The best way to figure this out is to see the args and return values of the function. And that is where the debugger comes into the game. BUT! I am JS programmer, not a Python, then I don't know how to use Python debugger. And there is one more issue. Python process is spawned by the js program, not by me/user. Then how I can guide Python to enter the debug mode?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions