-1

I think this is a bug since the documentation does not mention anything about a scheme 'c'.

Why does the output of the following code out 'c' ? What is scheme 'c' ? As mentioned before the scheme 'c' does not exist in the documentation.

from urllib.parse import urlparse

print(urlparse('C:/ProgramData/Anaconda3/lib/site-packages/impala/thrift/ExecStats.thrift').scheme)

By the way I am using Anaconda3.

ng.newbie
  • 2,807
  • 3
  • 23
  • 57
  • 3
    `C:/ProgramData/Anaconda3/lib/site-packages/impala/thrift/ExecStats.thrift` is not a URL. – user2357112 Oct 25 '19 at 09:06
  • @user2357112 this seems to be bug in the impyla library as it uses urlparse to find the thrift file. Since Windows file paths are different thus it does not work. – ng.newbie Oct 25 '19 at 09:18
  • I don't see anything in impyla that tries to parse a non-URL as a URL. I do see several places where you might mistakenly pass it a filesystem path instead of a URL, though. If you're doing that, that's your bug, not impyla's. – user2357112 Oct 25 '19 at 09:20
  • @user2357112 Sorry I meant it as a bug in ThriftPy. Please check line 487 in thriftpy\parser\parser.py – ng.newbie Oct 25 '19 at 09:23
  • Yeah, that's a bug. It looks like ThriftPy is dead and the developers recommend ThriftPy2 now, and ThriftPy2 supports the [file URI scheme](https://en.wikipedia.org/wiki/File_URI_scheme). I don't know if I'd use either of these projects, though. – user2357112 Oct 25 '19 at 09:31
  • @user2357112 Yeah but the Impyla project uses the buggy release. So what do I do ? – ng.newbie Oct 25 '19 at 09:32
  • Uh, no, it looks like they're using ThriftPy2. You should be able to use file URIs, as in `file:///...` – user2357112 Oct 25 '19 at 09:35
  • @user2357112 thats weird but it seems when I installed from PyCharm this is the error I am getting. What am i doing wrong ? I didn't obviously intentionally uses an older release. – ng.newbie Oct 25 '19 at 09:40
  • @user2357112 thanks. I had to update my release to 0.16 – ng.newbie Oct 25 '19 at 09:48

1 Answers1

1

Garbage in, garbage out.

You've told urlparse to parse something that is not a URL. urlparse did its best. In this case, the C: looks like a URL scheme specifier, like the "http:" in http://blah.blah.blah/..., so urlparse decides the scheme is c.

user2357112
  • 260,549
  • 28
  • 431
  • 505