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

decode a string containing unicode chars to unicode #502

Merged
merged 1 commit into from Jan 3, 2017

Conversation

Projects
None yet
3 participants
@srinivasreddy
Copy link
Contributor

srinivasreddy commented Dec 24, 2016

No description provided.

@@ -163,9 +163,9 @@ def from_notebook_node(self, nb, resources=None, **kw):
)
# set texinputs directory, so that local files will be found
if resources and resources.get('metadata', {}).get('path'):
self.texinputs = resources['metadata']['path']
self.texinputs = str_to_unicode(resources['metadata']['path'])

This comment has been minimized.

@takluyver

takluyver Dec 28, 2016

Member

The general rule with unicode is that we should convert this as soon as possible, i.e. where it's passed in to nbconvert, rather than here. Have a look in Exporter.from_filename.

else:
self.texinputs = os.getcwd()
self.texinputs = str_to_unicode(os.getcwd())

This comment has been minimized.

@takluyver

takluyver Dec 28, 2016

Member

The py3compat module should have a function getcwd which points to os.getcwdu() on Python 2, which is neater than converting.

@mpacer

This comment has been minimized.

Copy link
Member

mpacer commented Dec 28, 2016

Looks like str_to_unicode needs to be used slightly differently given that this errs on python 2.7 with an issue regarding ascii encoding. If you look in https://github.com/ipython/ipython_genutils/blob/master/ipython_genutils/py3compat.py you'll see it's mapped to decode on python2.7.

def decode(s, encoding=None):
    encoding = encoding or DEFAULT_ENCODING
    return s.decode(encoding, "replace")

Try running py.test --pyargs nbconvert in a python 2 environment (or even faster would be to find the specific tests that are failing and drill into the directory structure to test only them, though then you wouldn't use --pyargs. Those approaches should help when debugging this.

@srinivasreddy

This comment has been minimized.

Copy link
Contributor Author

srinivasreddy commented Dec 29, 2016

@takluyver Done. Please review again.

@srinivasreddy

This comment has been minimized.

Copy link
Contributor Author

srinivasreddy commented Jan 3, 2017

@michaelpacer What do you think?

@mpacer

This comment has been minimized.

Copy link
Member

mpacer commented Jan 3, 2017

LGTM, and it's passing the tests. Merging.

@mpacer mpacer merged commit 8967fa2 into jupyter:master Jan 3, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@mpacer mpacer added this to the 5.1 milestone Jan 21, 2017

@mpacer mpacer added unlogged and removed unlogged labels Jan 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment