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

-v command line option is broken #59175

Closed
kristjanvalur mannequin opened this issue May 31, 2012 · 7 comments
Closed

-v command line option is broken #59175

kristjanvalur mannequin opened this issue May 31, 2012 · 7 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@kristjanvalur
Copy link
Mannequin

kristjanvalur mannequin commented May 31, 2012

BPO 14970
Nosy @loewis, @brettcannon, @kristjanvalur

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2012-05-31.15:50:03.033>
created_at = <Date 2012-05-31.14:40:42.407>
labels = ['interpreter-core', 'type-bug', 'invalid']
title = '-v command line option is broken'
updated_at = <Date 2012-05-31.16:50:13.895>
user = 'https://github.com/kristjanvalur'

bugs.python.org fields:

activity = <Date 2012-05-31.16:50:13.895>
actor = 'brett.cannon'
assignee = 'none'
closed = True
closed_date = <Date 2012-05-31.15:50:03.033>
closer = 'kristjan.jonsson'
components = ['Interpreter Core']
creation = <Date 2012-05-31.14:40:42.407>
creator = 'kristjan.jonsson'
dependencies = []
files = []
hgrepos = []
issue_num = 14970
keywords = []
message_count = 7.0
messages = ['162002', '162003', '162006', '162008', '162009', '162010', '162012']
nosy_count = 3.0
nosy_names = ['loewis', 'brett.cannon', 'kristjan.jonsson']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue14970'
versions = ['Python 3.3']

@kristjanvalur
Copy link
Mannequin Author

kristjanvalur mannequin commented May 31, 2012

Using the -v command line option to diagnose import problem is no longer useful. In stead of lines like this in version 2.7:

import UserDict # from D:\p4\games\branches\development\MAIN\eve\dust\tool\bin/../../../../carbon/src/stackless/Lib/UserDict.py

we now get:
import 'textwrap' # <_frozen_importlib.SourceFileLoader object at 0x0000000002E14438>

I don't even know what a _frozen_importlib.SourceFileLoader is.

@kristjanvalur kristjanvalur mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels May 31, 2012
@loewis
Copy link
Mannequin

loewis mannequin commented May 31, 2012

See http://hg.python.org/cpython/file/default/Lib/importlib/_bootstrap.py
for the source of SourceFileLoader.

@kristjanvalur
Copy link
Mannequin Author

kristjanvalur mannequin commented May 31, 2012

Yes, I found that. The line in question is, however, this:
_verbose_message('import {!r} # {!r}', name, loader)
(_bootstrap.py:1254).

Unfortunately, I see no way to get at the line from which the import occurred here. The loader itself is not useful for that. Perhaps the author of importlib knows more, e.g. whether the feature to know whence an import originates is useful or has been dropped.

@brettcannon
Copy link
Member

The information is still there, just in a different output line (i.e. http://hg.python.org/cpython/file/c7b16e2be71a/Lib/importlib/_bootstrap.py#l735 outputs the same info, just on its own line). I couldn't keep the old format as the code has been shifted around enough compared to how import.c was structured that reproducing the same output would have required a code refactor and contortion that wasn't worth it. I did my best to make sure no useful data was left out (and actually there is more since the loader is now also stated so you always have that info instead of only what Python's included loaders provide).

@brettcannon
Copy link
Member

I am setting this as pending since I consider the total output acceptable, but if Kristján has specific issues he wants to bring up or change he still can.

@kristjanvalur
Copy link
Mannequin Author

kristjanvalur mannequin commented May 31, 2012

Oh dear, silly me.
I misunderstood the point of -v _and_ misunderstood the output of 2.7 I was quoting.
I was looking for a way to find out where the import originated from, not which file would be imported as a result.

Import errors, along with pickling errors, are some of the most annoying ones to debug, because they tend to require so much detective work.

Ok, I'll close this then. Sorry about the noise.

@kristjanvalur kristjanvalur mannequin closed this as completed May 31, 2012
@kristjanvalur kristjanvalur mannequin added the invalid label May 31, 2012
@brettcannon
Copy link
Member

Not a problem. =)

If you want to know where an import originated from, you can probably do something as simple as overload builtins.__import__ with a version that does a quick stack look to see where the previous call is coming from.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant