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

Modulegraph: Warn on syntax error and unicode error. #2430

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion PyInstaller/lib/modulegraph/modulegraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,7 @@ def _load_module(self, fqname, fp, pathname, info):
except SyntaxError:
co = None
cls = InvalidSourceModule
self.msg(2, "load_module: InvalidSourceModule", pathname)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I've just seen that we are using level 2 and "InvalidSourceModule" here while below we are using level 1 and "SyntaxError". Is this intended?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The UnicodeDecode error should be level two.


else:
cls = SourceModule
Expand Down Expand Up @@ -2171,7 +2172,7 @@ def _load_module(self, fqname, fp, pathname, info):
co = self._replace_paths_in_code(co)
m.code = co
except SyntaxError:
self.msg(2, "load_module: SynaxError in ", pathname)
self.msg(1, "load_module: SyntaxError in ", pathname)
cls = InvalidSourceModule
m = self.createNode(cls, fqname)

Expand Down Expand Up @@ -3272,6 +3273,8 @@ def _find_module_path(self, fullname, module_name, search_dirs):
if namespace_dirs:
path_data = (None, namespace_dirs[0], (
'', namespace_dirs, imp.PKG_DIRECTORY))
except UnicodeDecodeError as exc:
self.msgout(1, "_find_module_path -> unicode error", exc)
# Ensure that exceptions are logged, as this function is typically
# called by the import_module() method which squelches ImportErrors.
except Exception as exc:
Expand Down