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

Add variable support into setup.py AST Parsing #49

Open
cooperlees opened this issue Jun 15, 2019 · 0 comments
Open

Add variable support into setup.py AST Parsing #49

cooperlees opened this issue Jun 15, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@cooperlees
Copy link
Contributor

How is ptr not doing what you expect?

Unable to use code to set a variable in the ptr_params dict

disabled = True if version_info < (3, 7) else False
ptr_params = {
    "disabled": disabled,
  • I feel we should be able to get the dict pre-ran before we parse? Unsure - Not an AST god.

What is your suggestion to make this better?

  • See if the code can be evaluated before we sparse the options

Code/Bug example?

[2019-06-15 08:45:14,189] INFO: Starting /tmp/tsp/bin/ptr (ptr.py:1043)
Traceback (most recent call last):
  File "/tmp/tsp/bin/ptr", line 10, in <module>
    sys.exit(main())
  File "/private/tmp/tsp/lib/python3.7/site-packages/ptr.py", line 1059, in main
    args.venv_timeout,
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/private/tmp/tsp/lib/python3.7/site-packages/ptr.py", line 944, in async_main
    tests_to_run = _get_test_modules(base_path, stats, run_disabled)
  File "/private/tmp/tsp/lib/python3.7/site-packages/ptr.py", line 335, in _get_test_modules
    ptr_params = ast.literal_eval(node.value)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 91, in literal_eval
    return _convert(node_or_string)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 79, in _convert
    map(_convert, node.values)))
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 90, in _convert
    return _convert_signed_num(node)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 63, in _convert_signed_num
    return _convert_num(node)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 55, in _convert_num
    raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.Name object at 0x103d4aac8>

How can a developer reproduce this?

Set disabled to a variable and you should get the stack trace above.

@cooperlees cooperlees added the bug Something isn't working label Jun 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant