Skip to content

fix __builtins__ for better compatibility - #7187

Closed
zjjott wants to merge 1 commit into
matplotlib:masterfrom
zjjott:master
Closed

zjjott wants to merge 1 commit into
matplotlib:masterfrom
zjjott:master

Conversation

@zjjott

@zjjott zjjott commented Sep 27, 2016 •

Copy link
Copy Markdown

issue #7186
Maybe I fix it or maybe it's no an error.....(:з」∠)

@zjjott

zjjott commented Sep 27, 2016

Copy link
Copy Markdown
Author

AttributeError: 'dict' object has no attribute 'bytes'
wtf....why __builtins__ is dict?

@Kojoley

Kojoley commented Sep 27, 2016

Copy link
Copy Markdown
Member

wtf....why __builtins__ is dict?

https://docs.python.org/2/reference/executionmodel.html

CPython implementation detail: Users should not touch __builtins__; it is strictly an implementation detail. Users wanting to override values in the builtins namespace should import the __builtin__ (no ‘s’) module and modify its attributes appropriately.

I agree that we need a fix, but then we should use __builtin__/builtins module.

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Sep 27, 2016
@zjjott

zjjott commented Sep 28, 2016 •

Copy link
Copy Markdown
Author

thanks~ @Kojoley

By default, when in the main module, builtins is the built-in module builtin (note: no ‘s’); when in any other module, builtins is an alias for the dictionary of the builtin module itself. builtins can be set to a user-created dictionary to create a weak form of restricted execution.

looks like __main__ module or other module have diffence __builtins__ and type,I'll close this PR

@anntzer

anntzer commented Oct 4, 2016

Copy link
Copy Markdown
Contributor

This should probably be

from six.moves import builtins
bytes = builtins.bytes

(feel free to re-close this if you want to make a separate PR).

@anntzer anntzer reopened this Oct 4, 2016
anntzer added a commit to anntzer/matplotlib that referenced this pull request Oct 15, 2016
Also smuggled in some minor reformattings.

Fixes matplotlib#7186.  Supersedes matplotlib#7187 (see discussion there).
@Kojoley

Kojoley commented Oct 15, 2016

Copy link
Copy Markdown
Member

Fixed by #7272

@Kojoley Kojoley closed this Oct 15, 2016
@Kojoley Kojoley removed this from the 2.0.1 (next bug fix release) milestone Oct 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants