Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwriting __repr__ for str subclasses results in ValueError: malformed node or string raised within the ast module #5864

Closed
tyralla opened this issue Nov 30, 2017 · 2 comments

Comments

@tyralla
Copy link

tyralla commented Nov 30, 2017

Description of the problem

Weird output in the internal console when trying to overwrite the special method __repr__ for subclasses of str.

Minimal test case

For reproducing the problem, the following test class should be sufficient:

class Test(str):
    def __repr__(self):
        return 'something'

Writing...

Test()

...returns (as expected):

something

But when I write...

test = Test()

...the following error message is returned:

raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.Name object at 0x000000005FD5B550>

So far, I could reproduce this problem only when using the IPython console in Spyder.

Versions and main components

  • Spyder Version: 3.2.3
  • Python Version: 3.6.3
  • Qt Version: 5.6.2
  • PyQt Version: 5.6.0
  • Operating system: Windows

Dependencies

IPython >=4.0 : 6.1.0 (OK)
cython >=0.21 : 0.25.2 (OK)
jedi >=0.9.0 : 0.10.2 (OK)
nbconvert >=4.0 : 5.1.1 (OK)
numpy >=1.7 : 1.13.3 (OK)
pandas >=0.13.1 : 0.20.1 (OK)
pycodestyle >=2.3: 2.3.1 (OK)
pyflakes >=0.6.0 : 1.5.0 (OK)
pygments >=2.0 : 2.2.0 (OK)
pylint >=0.25 : 1.6.4 (OK)
qtconsole >=4.2.0: 4.3.1 (OK)
rope >=0.9.4 : 0.9.4-1 (OK)
sphinx >=0.6.6 : 1.5.1 (OK)
sympy >=0.7.3 : 1.0 (OK)

@dalthviz
Copy link
Member

Thanks for reporting @tyralla. I think this is related with #5636, PR #5746 implements a fix. Would you like to help us testing the PR I mention to see if that fixes this issue?

@ccordoba12
Copy link
Member

Closing as a duplicate of issue #5636. Feel free to keep posting about this on PR #5746.

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

No branches or pull requests

3 participants