This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hroncok
Recipients hroncok, petr.viktorin
Date 2022-02-23.12:43:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645620216.31.0.535281755903.issue46835@roundup.psfhosted.org>
In-reply-to
Content
Recently I've been debugging a very nasty bug report that looked like this:

    Traceback (most recent call last):
      File "/usr/bin/jupyter-notebook", line 5, in <module>
        from notebook.notebookapp import main
      File "/usr/lib/python3.10/site-packages/notebook/notebookapp.py", line 78, in <module>
        from .services.kernels.kernelmanager import MappingKernelManager, AsyncMappingKernelManager
      File "/usr/lib/python3.10/site-packages/notebook/services/kernels/kernelmanager.py", line 18, in <module>
        from jupyter_client.session import Session
      File "/usr/lib/python3.10/site-packages/jupyter_client/session.py", line 41, in <module>
        from jupyter_client.jsonutil import extract_dates, squash_dates, date_default
      File "/usr/lib/python3.10/site-packages/jupyter_client/jsonutil.py", line 10, in <module>
        from dateutil.parser import parse as _dateutil_parse
      File "/usr/lib/python3.10/site-packages/dateutil/parser/__init__.py", line 2, in <module>
        from ._parser import parse, parser, parserinfo, ParserError
      File "/usr/lib/python3.10/site-packages/dateutil/parser/_parser.py", line 42, in <module>
        import six
    ImportError: bad magic number in 'six': b'\x03\xf3\r\n'

For details, see https://bugzilla.redhat.com/2057340 and https://github.com/benjaminp/six/issues/359


What would really make things much easier to understand would be if the exception mentioned what is the path of 'six'.


Consider this example:

A rogue .py file in /usr/bin:

    $ sudo touch /usr/bin/copy.py

Programs fail with:

    Traceback (most recent call last):
      File "/usr/bin/...", line ..., in <module>
        ...
    ImportError: cannot import name 'deepcopy' from 'copy' (/usr/bin/copy.py)

Immediately I can see there is /usr/bin/copy.py which is probably not supposed to be there.

However, when it is a pyc instead:

    $ sudo touch /usr/bin/copy.pyc

Programs fail with:

    Traceback (most recent call last):
      File "/usr/bin/...", line ..., in <module>
        ...
    ImportError: bad magic number in 'copy': b''

Now I have no idea where "copy" is.


The is a request for that exception to give that infomartion.
History
Date User Action Args
2022-02-23 12:43:36hroncoksetrecipients: + hroncok, petr.viktorin
2022-02-23 12:43:36hroncoksetmessageid: <1645620216.31.0.535281755903.issue46835@roundup.psfhosted.org>
2022-02-23 12:43:36hroncoklinkissue46835 messages
2022-02-23 12:43:36hroncokcreate