Skip to content

TST: win32 paths cannot be turned into URLs by prefixing them with "file://" #4580

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

Closed
wants to merge 3 commits into from

Conversation

mindw
Copy link
Contributor

@mindw mindw commented Aug 16, 2013

@@ -27,6 +27,12 @@
from pandas.util.testing import makeCustomDataframe as mkdf


import urlparse, urllib
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put this in pandas/io/common.py ?

@jreback
Copy link
Contributor

jreback commented Aug 16, 2013

  • pls hook up travis (see contributing.md)
  • add an entry in doc/source/release.rst


def path2url(path):
return urlparse.urljoin(
'file:', urllib.pathname2url(path))
Copy link
Contributor

Choose a reason for hiding this comment

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

this you can take out

@jreback
Copy link
Contributor

jreback commented Aug 21, 2013

@cpcloud can take a look...i think this is ONLY used in tests for io/html (though maybe make a more general mechansim?)

@cpcloud
Copy link
Member

cpcloud commented Aug 21, 2013

@mindw If you feel like renaming the test that's fine, as long as it passes. Also, your code is not Python 3 compatible without running 2to3 (we don't run that). To make it Python 3 compatible, you'll have to add the url* import stuff (handling ImportError and so forth for the different Python versions) to pandas/compat/__init__.py. This will be annoying for you since there was a lot of mixing of the contents of the url* libraries from Python 2 to Python 3, see here. One option is to just add what you need so that you don't have million try..except ImportError clauses everywhere. That's essentially what we do now: cherry pick from the six package.

Those Travis errors are spurious errors unrelated to your code.

@jtratner
Copy link
Contributor

Here's what you need for Py3 compatibility:

In Python 3:

  • urljoin - from urllib.parse import urljoin
  • pathname2url - from urllib.request import pathname2url

Python 2:

  • urljoin from urllib import urljoin
  • pathname2url - from urllib import pathname2url

Please add these to the top of io/common in the midst of the imports under the appropriate branch.

@mindw
Copy link
Contributor Author

mindw commented Sep 4, 2013

Fixes submitted as requested.

BTW six 1.4.1 is out - it includes urllib fixes. I was wandering what was the rational to avoid using it (internally or as a dependency)?

import urllib.parse as urlparse
from urllib.parse import urljoin
from urllib.request import pathname2url
from io import StringIO
Copy link
Contributor

Choose a reason for hiding this comment

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

you should import StringIO from compat. only io specific things should come from here.

@jtratner
Copy link
Contributor

jtratner commented Sep 4, 2013

On your six comment:

There were a number of items that we needed to tweak from six. For example, iteritems and items return totally different things, so the compat.iteritems needed to try calling iteritems first and, if that's not available, call items. (Additionally, the way that six does it means that it produces an intermediary list in Python 2), similar rationale for itervalues and iterkeys. Plus, we added functions that produced lists instead of iterators (lrange, lmap, lfilter), because some pandas/numpy functions are sensitive to getting iterators instead of lists and needed to account for that. Finally, we needed to add moves for long and int and I preferred to flatten the namespace (i.e., StringIO is under six, whereas cStringIO is under six.moves) and have everything imported from the same place. Plus, it's a net positive to have fewer dependencies.

That said, as noted in the release notes, and the LICENSE directory (and I think in compat/__init__.py too), we did move over quite a bit of the concepts or code from the six module, which is why there is a SIX license included with pandas.

I really like the six module and I think the author used a very elegant model for turning a single file package into a module with multiple (and dynamic) namespaces, but I like the explicitness and clarity of having those imports localized into a single location within pandas.

I didn't even realize that the url imports weren't a part of six - at the time I had looked them up myself and added some of them to io/common.py.

@jtratner
Copy link
Contributor

jtratner commented Sep 4, 2013

Side note: please rebase on top of current master.

@jreback
Copy link
Contributor

jreback commented Sep 26, 2013

@mindw ping

@mindw
Copy link
Contributor Author

mindw commented Sep 26, 2013

On vacation - I'll handle this once back 10/01.

@jreback
Copy link
Contributor

jreback commented Oct 3, 2013

@mindw how's this coming? (I see you just got back)....no pressure!

@mindw
Copy link
Contributor Author

mindw commented Oct 3, 2013

Here you go - I was unable to re-use this issue for the master rebase. See #5100.

@jreback
Copy link
Contributor

jreback commented Oct 3, 2013

closing in favor of #5100

@jreback jreback closed this Oct 3, 2013
@jtratner
Copy link
Contributor

jtratner commented Oct 3, 2013

For future reference, all Github cares about is the branch name, so if you
have to give up and start over, you can still reuse the PR by pushing to
the same branch :)

@mindw
Copy link
Contributor Author

mindw commented Oct 3, 2013

Duly noted . ;]
On Oct 3, 2013 11:16 PM, "Jeff Tratner" notifications@github.com wrote:

For future reference, all Github cares about is the branch name, so if you
have to give up and start over, you can still reuse the PR by pushing to
the same branch :)


Reply to this email directly or view it on GitHubhttps://github.com//pull/4580#issuecomment-25658765
.

@jtratner
Copy link
Contributor

supplanted by #5100

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