-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Remove dependency on six - we're Py3 only now! #11158
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bfaf390
Remove no-op imports of `six`
Zac-HD bd508b9
Strip out obsolete compatibility layer from `six`
Zac-HD 3f47076
Deprecate now-useless functions
Zac-HD 22ff3e2
Do not install `six` on py3-only version
Zac-HD 17f06ee
Final edits for anntzer's review
Zac-HD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,6 @@ | ||
| """ | ||
| A PostScript backend, which can produce both PostScript .ps and .eps | ||
| """ | ||
| import six | ||
| from six.moves import StringIO | ||
|
|
||
| import glob, os, shutil, sys, time, datetime | ||
| import io | ||
| import logging | ||
|
|
@@ -77,10 +74,7 @@ def gs_version(self): | |
| s = subprocess.Popen( | ||
| [self.gs_exe, "--version"], stdout=subprocess.PIPE) | ||
| pipe, stderr = s.communicate() | ||
| if six.PY3: | ||
| ver = pipe.decode('ascii') | ||
| else: | ||
| ver = pipe | ||
| ver = pipe.decode('ascii') | ||
| try: | ||
| gs_version = tuple(map(int, ver.strip().split("."))) | ||
| except ValueError: | ||
|
|
@@ -133,7 +127,7 @@ def _get_papertype(w, h): | |
| return 'a0' | ||
|
|
||
| def _num_to_str(val): | ||
| if isinstance(val, six.string_types): | ||
| if isinstance(val, str): | ||
| return val | ||
|
|
||
| ival = int(val) | ||
|
|
@@ -229,7 +223,7 @@ def track_characters(self, font, s): | |
| used_characters[1].update(map(ord, s)) | ||
|
|
||
| def merge_used_characters(self, other): | ||
| for stat_key, (realpath, charset) in six.iteritems(other): | ||
| for stat_key, (realpath, charset) in other.items(): | ||
| used_characters = self.used_characters.setdefault( | ||
| stat_key, (realpath, set())) | ||
| used_characters[1].update(charset) | ||
|
|
@@ -981,8 +975,7 @@ def _print_figure( | |
| the key 'Creator' is used. | ||
| """ | ||
| isEPSF = format == 'eps' | ||
| if isinstance(outfile, | ||
| (six.string_types, getattr(os, "PathLike", ()),)): | ||
| if isinstance(outfile, (str, getattr(os, "PathLike", ()),)): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| outfile = title = getattr(os, "fspath", lambda obj: obj)(outfile) | ||
| title = title.encode("latin-1", "replace").decode() | ||
| passed_in_file_object = False | ||
|
|
@@ -1102,8 +1095,8 @@ def print_figure_impl(fh): | |
| for l in d.split('\n'): | ||
| print(l.strip(), file=fh) | ||
| if not rcParams['ps.useafm']: | ||
| for font_filename, chars in six.itervalues( | ||
| ps_renderer.used_characters): | ||
| for font_filename, chars in \ | ||
| ps_renderer.used_characters.values(): | ||
| if len(chars): | ||
| font = get_font(font_filename) | ||
| glyph_ids = [] | ||
|
|
@@ -1148,7 +1141,7 @@ def print_figure_impl(fh): | |
|
|
||
| # write the figure | ||
| content = self._pswriter.getvalue() | ||
| if not isinstance(content, six.text_type): | ||
| if not isinstance(content, str): | ||
| content = content.decode('ascii') | ||
| print(content, file=fh) | ||
|
|
||
|
|
@@ -1181,8 +1174,7 @@ def print_figure_impl(fh): | |
| if passed_in_file_object: | ||
| requires_unicode = file_requires_unicode(outfile) | ||
|
|
||
| if (not requires_unicode and | ||
| (six.PY3 or not isinstance(outfile, StringIO))): | ||
| if not requires_unicode: | ||
| fh = io.TextIOWrapper(outfile, encoding="latin-1") | ||
|
|
||
| # Prevent the io.TextIOWrapper from closing the | ||
|
|
@@ -1211,7 +1203,7 @@ def _print_figure_tex( | |
| the key 'Creator' is used. | ||
| """ | ||
| isEPSF = format == 'eps' | ||
| if isinstance(outfile, six.string_types): | ||
| if isinstance(outfile, str): | ||
| title = outfile | ||
| elif is_writable_file_like(outfile): | ||
| title = None | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not use
StringIOin this module?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not anymore - it was only used in a
isinstancecheck in a Python-2-only branch.