pylint-bot / test

0 stars 0 forks source link

repr fails on AST fragments #158

Closed pylint-bot closed 8 years ago

pylint-bot commented 9 years ago

Originally reported by: BitBucket: ceridwenv, GitHub: @ceridwen?


NodeNG's __repr__ includes a call to self.root().name, which will fail on an AST fragment whose root doesn't have a name attribute. This is mostly an inconvenience when trying to debug the process of building ASTs.


pylint-bot commented 9 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):


Could you give me an example where the root doesn't have a name attribute? I presume this is the case for nodes for which their root is not a Module, which is wrong, .root() should always return a Module.

pylint-bot commented 8 years ago

Original comment by BitBucket: ceridwenv, GitHub: @ceridwen?:


I first encountered this problem in debugging astroid, which may well have involved an incorrectly-generated AST. However, I'm more thinking about Macropy and similar code generation applications which can involve splicing pieces of an AST into another AST or building an AST from the bottom up rather than the top down.

pylint-bot commented 8 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):


Right, it makes sense for an AST not to have Module as root. Care to work on a patch?

pylint-bot commented 8 years ago

Original comment by BitBucket: ceridwenv, GitHub: @ceridwen?:


I will work on a patch once I'm finished with the node constructor patch.

pylint-bot commented 8 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):


No problem. I'll do more reviews for your PR next week, since I'm pretty full with EuroPython right now.

pylint-bot commented 8 years ago

Original comment by BitBucket: ceridwenv, GitHub: @ceridwen?:


Fixed by https://bitbucket.org/logilab/astroid/commits/7b127880987d8896349e070debaccc587a3c6570