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

see http://stackoverflow.com/questions/11687478/convert-a-filename-to-a-file-url


Labels:

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

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

@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](http://pythonhosted.org/six/#module-six.moves). 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`](http://pythonhosted.org/six/) package.

Those Travis errors are spurious errors unrelated to your code.

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.

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)?

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`.

Side note: please rebase on top of current master.

@mindw ping

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

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

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

closing in favor of #5100

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 :)

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/pydata/pandas/pull/4580#issuecomment-25658765
> .

supplanted by #5100