Open pylint-bot opened 9 years ago
Original comment by BitBucket: ceridwenv, GitHub: @ceridwen?:
The immediate cause of this bug is that brain_builtin_inference was trying to alter the locals dictionary of str, bytes, and unicode ClassDef nodes. I changed this so that it instead replaces FunctionDef nodes in the body of those ClassDef nodes with others, which does fix the immediate problem. Unfortunately, there are still issues here.
type(b'') is type('')
, when from __future__ import unicode_literals
is in effect I'm concerned that things will break.bytes is str
and ast_from_object encounters bytes first, it builds a ClassDef node for bytes and a Name node for str. I worked around the problems introduced with the following ugly hack:if sys.version_info > (3, 0):
extend_builtins({'bytes': functools.partial(_extend_str, rvalue="b''"),
'str': functools.partial(_extend_str, rvalue="''")})
else:
extend_builtins({'bytes': functools.partial(_extend_str, rvalue="''"),
'unicode': functools.partial(_extend_str, rvalue="u''")})
This isn't a good solution though.
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):
For .2, that's true, there's currently no mechanism for handling this. Maybe something can be added along with the issue that's proposing a new API for the Arguments node, which could be enforced by Pylint with a specific rule.
Original comment by BitBucket: ceridwenv, GitHub: @ceridwen?:
This is improved in 8aca20dd1814, which handles alternate names in the builtins module. It roughly fixes 4 in the list above but doesn't tackle the other issues.
Originally reported by: BitBucket: ceridwenv, GitHub: @ceridwen?
I'm getting the following two errors.
The first error I'm reasonably sure is related to this:
I don't understand how this error didn't happen before, given the Python 2/3 differences. I assume that not testing all the string methods is deliberate, but I should also mention there are some string methods that are only on Python3, like isidentifier().