Skip to content

Replace most uses of getfilesystemencoding by os.fs{en,de}code. #10513

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 1 commit into from
Jul 23, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 17, 2018

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@anntzer anntzer added this to the v3.0 milestone Feb 17, 2018
@QuLogic QuLogic added the Py3k label Feb 18, 2018
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Seems fine, though not sure about the mpl-data path stuff; would be nice to see more examples/tests of how that works.

if getattr(sys, 'frozen', None):
yield sys.executable
# Try again assuming we need to step up one more directory.
yield os.path.dirname(sys.executable)
Copy link
Member

Choose a reason for hiding this comment

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

The logic seems wrong for the last two as in the original they did not have dirname applied.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They do (original: exe_path = sys.path.dirname(...)). For the first one, the candidate will be

In [12]: Path(sys.executable).with_name("mpl-data")
Out[12]: PosixPath('/usr/bin/mpl-data')

In [13]: os.path.join(os.path.dirname(sys.executable), "mpl-data")
Out[13]: '/usr/bin/mpl-data'

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

I do not think the logic on the lest entry is correct.

It gives

In [37]: Path(sys.path[0]).with_name('mpl-data')
Out[37]: PosixPath('/home/tcaswell/.virtualenvs/dd36/lib/python3.6/mpl-data')

where as the orginal gives

In [40]: os.path.join(sys.path[0], 'mpl-data')
Out[40]: '/home/tcaswell/.virtualenvs/dd36/lib/python3.6/site-packages/mpl-data'

@anntzer
Copy link
Contributor Author

anntzer commented Jul 22, 2018

Indeed, the last entry was off by 1. I redid the logic, should be fixed now.

@tacaswell tacaswell merged commit 6edc7a8 into matplotlib:master Jul 23, 2018
@anntzer anntzer deleted the fsencodedecode branch July 23, 2018 19:04
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.

4 participants