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

type of __builtins__ changes if in main module or not #48832

Closed
nnorwitz mannequin opened this issue Dec 7, 2008 · 2 comments
Closed

type of __builtins__ changes if in main module or not #48832

nnorwitz mannequin opened this issue Dec 7, 2008 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@nnorwitz
Copy link
Mannequin

nnorwitz mannequin commented Dec 7, 2008

BPO 4582
Nosy @loewis

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 2008-12-07.20:57:07.674>
created_at = <Date 2008-12-07.20:48:38.718>
labels = ['interpreter-core', 'type-bug']
title = 'type of __builtins__ changes if in main module or not'
updated_at = <Date 2008-12-07.20:57:07.673>
user = 'https://bugs.python.org/nnorwitz'

bugs.python.org fields:

activity = <Date 2008-12-07.20:57:07.673>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = <Date 2008-12-07.20:57:07.674>
closer = 'loewis'
components = ['Interpreter Core']
creation = <Date 2008-12-07.20:48:38.718>
creator = 'nnorwitz'
dependencies = []
files = []
hgrepos = []
issue_num = 4582
keywords = []
message_count = 2.0
messages = ['77252', '77254']
nosy_count = 2.0
nosy_names = ['loewis', 'nnorwitz']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue4582'
versions = []

@nnorwitz
Copy link
Mannequin Author

nnorwitz mannequin commented Dec 7, 2008

This happens on 2.4 and 3.0, probably all versions:

When running this simple program (save to a file):

print(type(__builtins__))
__import__(__file__.split('/')[-1][:-3])

I get:
<type 'module'>
<type 'dict'>

I would expect the type to be consistent regardless of whether executing
the main module or from the imported module. I haven't looked into why
this is happening or if it makes sense. It was unexpected.

@nnorwitz nnorwitz mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error labels Dec 7, 2008
@loewis
Copy link
Mannequin

loewis mannequin commented Dec 7, 2008

This is documented, intentional behavior:

http://docs.python.org/library/__builtin__.html?highlight=__builtins__

@loewis loewis mannequin closed this as completed Dec 7, 2008
@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

0 participants