-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
'str' object has no attribute 'parent' #6221
Comments
Possibly a windows only issue, the example does not crash for me. What is the commit used in your local pylint ? |
|
@edreamleo Could I ask you to print out L1057 was changed in #5544. It might be possible that this caused a regression? But honestly I don't immediately see how |
@DanielNoord What do you mean "on L1055"? |
Oh sorry, should have been clearer. Line 1055 in |
@DanielNoord Will do. Probably later today. |
At line 1057 I replaced the unguarded access to
The extra output was: BTW, |
@DanielNoord Sorry, wrong recipient the first time. On second thought, the "hang" is likely a Leo artifact. A pipe created by subprocess.Popen probably blocked. It's an ongoing Leo issue :-) |
I'm going to ping @jacobtylerwalls as this is probably related to his PR #5544. @edreamleo Do you have a short code snippet that always trigger this crash? |
@DanielNoord No, but I should be able to create one. One of the failing files is fairly short. |
@DanielNoord Here is a reduction of leo/core/leoPrinting.py that still crashes for me: """
Test file for pylint issue #6221: https://github.com/PyCQA/pylint/issues/6221
Adapted from leo/core/leoPrinting.py
"""
try: # #1973
from leo.core.leoQt import printsupport, QtGui
from leo.core.leoQt import DialogCode
except Exception:
printsupport = QtGui = None # type:ignore
DialogCode = None # type:ignore
class PrintingController:
"""A class supporting the commands in Leo's File:Print menu."""
document = None # #6221: Suppress extraneous pylint complaint.
c = None # #6221: Suppress extraneous pylint complaint.
def preview_body(self, event=None):
"""Preview the body of the selected node."""
doc = self.document(self.c.p.b)
self.preview_doc(doc)
def preview_doc(self, doc):
"""Preview the document."""
# pylint: disable=no-member
dialog = printsupport.QPrintPreviewDialog()
dialog.setSizeGripEnabled(True)
dialog.paintRequested.connect(doc.print) # <=== OOPS!
dialog.exec_() |
Hmm, I can't get that to crash on |
Might need to spin up a fresh venv with the packages from the report. That can affect inference. |
@DanielNoord Yes, the imports appear necessary. I admit, this particular snippet is very strange. If you like, I can try to find another snippet. |
Let's just continue bisecting this one. Can you include the entire crash output? My guess is that chained assignment to |
I did a fresh venv with |
@DanielNoord I may be able to simplify the example... |
@DanielNoord On my system all the imports succeed, so the example can just start with the following: from leo.core.leoQt import printsupport, QtGui
from leo.core.leoQt import DialogCode This still gives a fatal error, as expected. But: we should be able to simplify the example further by using PyQt6 imports defined in leoQt.py (via leoQt6.py): from PyQt6 import QtWidgets
from PyQt6 import QtPrintSupport as printsupport
DialogCode = QtWidgets.QDialog.DialogCode But now pylint doesn't crash, and instead complains:
|
@DanielNoord Hmm. leoQt.py gets access to the symbols in leoQt6.py this way:
So maybe this extra level of indirection is bothering pylint. |
@edreamleo could you post the entire crash report? You can wrap it in a like this
|
@jacobtylerwalls Will do. |
@jacobtylerwalls Here is the entire crash report, from pylint-crash-2022-04-08-05.txt:
First, please verify that the bug is not already filled:
https://github.com/PyCQA/pylint/issues/
Then create a new crash issue: Issue title: """
Test file for pylint issue #6221: https://github.com/PyCQA/pylint/issues/6221
Adapted from leo/core/leoPrinting.py
"""
# Crashes
from leo.core.leoQt import printsupport, QtGui
from leo.core.leoQt import DialogCode
# Does not crash
# from leo.core.leoQt6 import printsupport, QtGui
# from leo.core.leoQt6 import DialogCode
# Does not crash
# from PyQt6 import QtWidgets
# from PyQt6 import QtPrintSupport as printsupport
# DialogCode = QtWidgets.QDialog.DialogCode
class PrintingController:
"""A class supporting the commands in Leo's File:Print menu."""
document = None # #6221: Suppress extraneous pylint complaint.
c = None # #6221: Suppress extraneous pylint complaint.
def preview_body(self, event=None):
"""Preview the body of the selected node."""
doc = self.document(self.c.p.b)
self.preview_doc(doc)
def preview_doc(self, doc):
"""Preview the document."""
# pylint: disable=no-member
dialog = printsupport.QPrintPreviewDialog()
dialog.setSizeGripEnabled(True)
dialog.paintRequested.connect(doc.print)
dialog.exec_() pylint crashed with a
|
And here is the console output, with an extra trace inserted in typecheck.py:
|
Thanks, I can reproduce it now. I needed to:
Assigning myself with the intent of having a look soon at the root cause, but any help is welcome. Thanks for the report! |
Bisected it to #5544 in 2.14 (glad we didn't rush it into 2.13!) I just need to restore an |
@jacobtylerwalls You're welcome. Glad to hear the fix was straightforward. |
@jacobtylerwalls The code in ee94d81 works for me. Many thanks for the quick fix. |
@edreamleo actually, may I ask you to test an alternative solution? This is the root cause and actually testable in a real way! pylint-dev/astroid#1505 |
@jacobtylerwalls Will do. Probably tomorrow. |
Tests still fail for me, but I suspect that I have not installed the PR properly. Here is what I did:
Now
What should I do now? Thanks. |
Hmm. I suppose I should do |
Ok, from https://github.com/cli/cli I did: I'll get the gh command working and see if that helps :-) |
I think you need to switch the branch to the
|
@Pierre-Sassoulas Thanks. I'll try that. Also, I see that there is an msi installer for gh cli on Windows, which I've just installed. Now 'gh' works. |
@Pierre-Sassoulas I'm still running tests (they take over 1000 sec), but there are no crashes in the files that crashed before, only new pylint warnings :-)
c:\leo.repo\ekr-pylint-6221>python -m pip install .
c:\leo.repo\ekr-pylint-6221>echo off |
@Pierre-Sassoulas All tests just completed: So I have done all the testing that I can. Thanks again for the quick fix. |
Reopening to make sure we release |
Fixed in #6398 |
Bug description
Note: Crash appeared several times in different files. Including all of pylint-crash-2022-04-07-07.txt made the body text of this issue too big.
pylint crashed with a
AttributeError
and with the following stacktrace:Note Several more similar crashes appear in the crash report.
Configuration
No response
Command used
Pylint output
Expected behavior
No pylint crashes :-) The pylint messages appear reasonable.
Pylint version
OS / Environment
Leo 6.6.1-devel, ekr-unit-tests branch, build 77f47d62b3
2022-04-06 13:50:52 -0500
Python 3.10.4, PyQt version 6.2.4
Windows 10 AMD64 (build 10.0.22000) SP0
Additional dependencies
C:\leo.repo\leo-editor>python -m pip freeze
astroid==2.11.2
atomicwrites==1.4.0
attrs==21.4.0
beautifulsoup4==4.10.0
black==22.3.0
bleach==4.1.0
certifi==2021.10.8
charset-normalizer==2.0.12
click==8.1.0
colorama==0.4.4
coverage==6.3.2
cycler==0.11.0
defusedxml==0.7.1
dialite==0.5.3
dill==0.3.4
distlib==0.3.4
docutils==0.18.1
entrypoints==0.4
feedparser==6.0.8
filelock==3.6.0
flexx==0.8.3
fonttools==4.31.2
idna==3.3
ImageHash==4.2.1
iniconfig==1.1.1
isort==5.10.1
Jinja2==3.1.1
jsonschema==4.4.0
jupyter-client==7.2.1
jupyter-core==4.9.2
jupyterlab-pygments==0.1.2
kiwisolver==1.4.1
lazy-object-proxy==1.7.1
leo==6.6
lxml==4.8.0
Markdown==3.3.6
MarkupSafe==2.1.1
matplotlib==3.5.1
mccabe==0.7.0
mistune==0.8.4
mypy-extensions==0.4.3
nbclient==0.5.13
nbconvert==6.4.5
nbformat==5.2.0
nest-asyncio==1.5.5
numpy==1.22.3
packaging==21.3
pandocfilters==1.5.0
pathspec==0.9.0
Pillow==9.0.1
platformdirs==2.5.1
pluggy==1.0.0
pscript==0.7.7
py==1.11.0
pyenchant==3.2.2
Pygments==2.11.2
-e git+https://github.com/PyCQA/pylint.git@ba08c9d1ab8b624b4491a29bfc2f274dc00eeab8#egg=pylint
pyparsing==3.0.7
PyQt5==5.15.6
PyQt5-Qt5==5.15.2
PyQt5-sip==12.9.1
PyQt6==6.2.3
PyQt6-Qt6==6.2.4
PyQt6-sip==13.2.1
PyQt6-WebEngine==6.2.1
PyQt6-WebEngine-Qt6==6.2.4
pyrsistent==0.18.1
pytest==7.1.1
pytest-cov==3.0.0
python-dateutil==2.8.2
PyWavelets==1.3.0
pywin32==303
PyYAML==6.0
pyzmq==22.3.0
requests==2.27.1
scipy==1.8.0
Send2Trash==1.8.0
sgmllib3k==1.0.0
six==1.16.0
soupsieve==2.3.1
testpath==0.6.0
toml==0.10.2
tomli==2.0.1
tornado==6.1
tox==3.24.5
traitlets==5.1.1
types-docutils==0.18.0
types-requests==2.27.15
types-urllib3==1.26.11
typing_extensions==4.1.1
urllib3==1.26.9
virtualenv==20.14.0
webencodings==0.5.1
webruntime==0.5.8
websockets==10.2
windows-curses==2.3.0
wrapt==1.14.0
The text was updated successfully, but these errors were encountered: