diff --git a/.gitignore b/.gitignore index 7e1a952..0f7a21d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,11 @@ /tmp /MANIFEST /urlparse4/*.html -/dist \ No newline at end of file +/dist + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml +htmlcov +.pytest_cache diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..33d0266 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: python +sudo: false +branches: + only: + - master + - /^\d\.\d+$/ + - /^\d\.\d+\.\d+(rc\d+|\.dev\d+)?$/ +matrix: + include: + - python: 2.7 + env: TOXENV=py27 + - python: 2.7 + env: TOXENV=pypy + - python: 2.7 + env: TOXENV=pypy3 + - python: 3.4 + env: TOXENV=py34 + - python: 3.5 + env: TOXENV=py35 + - python: 3.6 + env: TOXENV=py36 +install: + - pip install -U pip tox +script: + - tox diff --git a/benchmarks/urls.py b/benchmarks/urls.py index fe0fce9..a082d54 100644 --- a/benchmarks/urls.py +++ b/benchmarks/urls.py @@ -27,7 +27,7 @@ URLS = [] for fp in os.listdir("tests/urls/"): - with open("tests/urls/%s" % fp) as f: + with open("urls/%s" % fp) as f: URLS += f.readlines() data = [] diff --git a/tests/urls/blink-performancetests.txt b/benchmarks/urls/blink-performancetests.txt similarity index 100% rename from tests/urls/blink-performancetests.txt rename to benchmarks/urls/blink-performancetests.txt diff --git a/tests/urls/seeds_es_dmoz.txt b/benchmarks/urls/seeds_es_dmoz.txt similarity index 100% rename from tests/urls/seeds_es_dmoz.txt rename to benchmarks/urls/seeds_es_dmoz.txt diff --git a/setup.py b/setup.py index ffb8a42..69dfde3 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ VERSION = "0.1.3" extension = Extension( - name="urlparse4/cgurl", + name="cgurl", sources=["urlparse4/cgurl.pyx", "vendor/gurl/base/third_party/icu/icu_utf.cc", "vendor/gurl/base/strings/string16.cc", @@ -43,7 +43,7 @@ from Cython.Build import cythonize ext_modules = cythonize(extension, annotate=True) except: - print "urlparse4/gurl.cpp not found and Cython failed to run to recreate it. Please install/upgrade Cython and try again." + print("urlparse4/cgurl.cpp not found and Cython failed to run to recreate it. Please install/upgrade Cython and try again.") raise else: ext_modules = [extension] diff --git a/tests/test_urlparse.py b/tests/test_urlparse.py index af3df33..a1fe0f5 100644 --- a/tests/test_urlparse.py +++ b/tests/test_urlparse.py @@ -1,20 +1,14 @@ -# https://github.com/python/cpython/blob/40dac3272231773af0015fc35df5353783d77c4e/Lib/test/test_urlparse.py -import sys -import os -sys.path.insert(-1, os.path.dirname(os.path.dirname(__file__))) - - -from test import test_support import unittest -import urlparse4 as urlparse +import urlparse4 +import warnings RFC1808_BASE = "http://a/b/c/d;p?q#f" RFC2396_BASE = "http://a/b/c/d;p?q" RFC3986_BASE = 'http://a/b/c/d;p?q' SIMPLE_BASE = 'http://a/b/c/d' -# A list of test cases. Each test case is a two-tuple that contains -# a string with the query and a dictionary with the expected result. +# Each parse_qsl testcase is a two-tuple that contains +# a string with the query and a list with the expected result. parse_qsl_test_cases = [ ("", []), @@ -24,10 +18,19 @@ ("=a", [('', 'a')]), ("a", [('a', '')]), ("a=", [('a', '')]), - ("a=", [('a', '')]), ("&a=b", [('a', 'b')]), ("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]), ("a=1&a=2", [('a', '1'), ('a', '2')]), + (b"", []), + (b"&", []), + (b"&&", []), + (b"=", [(b'', b'')]), + (b"=a", [(b'', b'a')]), + (b"a", [(b'a', b'')]), + (b"a=", [(b'a', b'')]), + (b"&a=b", [(b'a', b'b')]), + (b"a=a+b&b=b+c", [(b'a', b'a b'), (b'b', b'b c')]), + (b"a=1&a=2", [(b'a', b'1'), (b'a', b'2')]), (";", []), (";;", []), (";a=b", [('a', 'b')]), @@ -40,6 +43,9 @@ (b"a=1;a=2", [(b'a', b'1'), (b'a', b'2')]), ] +# Each parse_qs testcase is a two-tuple that contains +# a string with the query and a dictionary with the expected result. + parse_qs_test_cases = [ ("", {}), ("&", {}), @@ -76,19 +82,19 @@ class UrlParseTestCase(unittest.TestCase): def checkRoundtrips(self, url, parsed, split): - result = urlparse.urlparse(url) + result = urlparse4.urlparse(url) self.assertEqual(result, parsed) t = (result.scheme, result.netloc, result.path, result.params, result.query, result.fragment) self.assertEqual(t, parsed) # put it back together and it should be the same - result2 = urlparse.urlunparse(result) + result2 = urlparse4.urlunparse(result) self.assertEqual(result2, url) self.assertEqual(result2, result.geturl()) # the result of geturl() is a fixpoint; we can always parse it # again to get the same result: - result3 = urlparse.urlparse(result.geturl()) + result3 = urlparse4.urlparse(result.geturl()) self.assertEqual(result3.geturl(), result.geturl()) self.assertEqual(result3, result) self.assertEqual(result3.scheme, result.scheme) @@ -103,17 +109,17 @@ def checkRoundtrips(self, url, parsed, split): self.assertEqual(result3.port, result.port) # check the roundtrip using urlsplit() as well - result = urlparse.urlsplit(url) + result = urlparse4.urlsplit(url) self.assertEqual(result, split) t = (result.scheme, result.netloc, result.path, result.query, result.fragment) self.assertEqual(t, split) - result2 = urlparse.urlunsplit(result) + result2 = urlparse4.urlunsplit(result) self.assertEqual(result2, url) self.assertEqual(result2, result.geturl()) # check the fixpoint property of re-parsing the result of geturl() - result3 = urlparse.urlsplit(result.geturl()) + result3 = urlparse4.urlsplit(result.geturl()) self.assertEqual(result3.geturl(), result.geturl()) self.assertEqual(result3, result) self.assertEqual(result3.scheme, result.scheme) @@ -128,25 +134,25 @@ def checkRoundtrips(self, url, parsed, split): def test_qsl(self): for orig, expect in parse_qsl_test_cases: - result = urlparse.parse_qsl(orig, keep_blank_values=True) + result = urlparse4.parse_qsl(orig, keep_blank_values=True) self.assertEqual(result, expect, "Error parsing %r" % orig) expect_without_blanks = [v for v in expect if len(v[1])] - result = urlparse.parse_qsl(orig, keep_blank_values=False) + result = urlparse4.parse_qsl(orig, keep_blank_values=False) self.assertEqual(result, expect_without_blanks, - "Error parsing %r" % orig) + "Error parsing %r" % orig) def test_qs(self): for orig, expect in parse_qs_test_cases: - result = urlparse.parse_qs(orig, keep_blank_values=True) + result = urlparse4.parse_qs(orig, keep_blank_values=True) self.assertEqual(result, expect, "Error parsing %r" % orig) - expect_without_blanks = dict( - [(v, expect[v]) for v in expect if len(expect[v][0])]) - result = urlparse.parse_qs(orig, keep_blank_values=False) + expect_without_blanks = {v: expect[v] + for v in expect if len(expect[v][0])} + result = urlparse4.parse_qs(orig, keep_blank_values=False) self.assertEqual(result, expect_without_blanks, - "Error parsing %r" % orig) + "Error parsing %r" % orig) def test_roundtrips(self): - testcases = [ + str_cases = [ ('file:///tmp/junk.txt', ('file', '', '/tmp/junk.txt', '', '', ''), ('file', '', '/tmp/junk.txt', '', '')), @@ -159,7 +165,7 @@ def test_roundtrips(self): ('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf', '', '')), ('nfs://server/path/to/file.txt', - ('nfs', 'server', '/path/to/file.txt', '', '', ''), + ('nfs', 'server', '/path/to/file.txt', '', '', ''), ('nfs', 'server', '/path/to/file.txt', '', '')), ('svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/', ('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/', @@ -170,16 +176,21 @@ def test_roundtrips(self): ('git+ssh', 'git@github.com','/user/project.git', '','',''), ('git+ssh', 'git@github.com','/user/project.git', - '', '')) + '', '')), ] - for url, parsed, split in testcases: + def _encode(t): + return (t[0].encode('ascii'), + tuple(x.encode('ascii') for x in t[1]), + tuple(x.encode('ascii') for x in t[2])) + bytes_cases = [_encode(x) for x in str_cases] + for url, parsed, split in str_cases + bytes_cases: self.checkRoundtrips(url, parsed, split) def test_http_roundtrips(self): - # urlparse.urlsplit treats 'http:' as an optimized special case, + # urlparse4.urlsplit treats 'http:' as an optimized special case, # so we test both 'http:' and 'https:' in all the following. # Three cheers for white box knowledge! - testcases = [ + str_cases = [ ('://www.python.org', ('www.python.org', '', '', '', ''), ('www.python.org', '', '', '')), @@ -196,21 +207,36 @@ def test_http_roundtrips(self): ('a', '/b/c/d', 'p', 'q', 'f'), ('a', '/b/c/d;p', 'q', 'f')), ] - for scheme in ('http', 'https'): - for url, parsed, split in testcases: - url = scheme + url - parsed = (scheme,) + parsed - split = (scheme,) + split - self.checkRoundtrips(url, parsed, split) + def _encode(t): + return (t[0].encode('ascii'), + tuple(x.encode('ascii') for x in t[1]), + tuple(x.encode('ascii') for x in t[2])) + bytes_cases = [_encode(x) for x in str_cases] + str_schemes = ('http', 'https') + bytes_schemes = (b'http', b'https') + str_tests = str_schemes, str_cases + bytes_tests = bytes_schemes, bytes_cases + for schemes, test_cases in (str_tests, bytes_tests): + for scheme in schemes: + for url, parsed, split in test_cases: + url = scheme + url + parsed = (scheme,) + parsed + split = (scheme,) + split + self.checkRoundtrips(url, parsed, split) def checkJoin(self, base, relurl, expected): - self.assertEqual(urlparse.urljoin(base, relurl), expected, - (base, relurl, expected, urlparse.urljoin(base, relurl))) + str_components = (base, relurl, expected) + self.assertEqual(urlparse4.urljoin(base, relurl), expected) + bytes_components = baseb, relurlb, expectedb = [ + x.encode('ascii') for x in str_components] + self.assertEqual(urlparse4.urljoin(baseb, relurlb), expectedb) def test_unparse_parse(self): - for u in ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',]: - self.assertEqual(urlparse.urlunsplit(urlparse.urlsplit(u)), u) - self.assertEqual(urlparse.urlunparse(urlparse.urlparse(u)), u) + str_cases = ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',] + bytes_cases = [x.encode('ascii') for x in str_cases] + for u in str_cases + bytes_cases: + self.assertEqual(urlparse4.urlunsplit(urlparse4.urlsplit(u)), u) + self.assertEqual(urlparse4.urlunparse(urlparse4.urlparse(u)), u) def test_RFC1808(self): # "normal" cases from RFC 1808: @@ -239,10 +265,6 @@ def test_RFC1808(self): # "abnormal" cases from RFC 1808: self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q#f') - self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g') - self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g') - self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g') - self.checkJoin(RFC1808_BASE, '/../g', 'http://a/../g') self.checkJoin(RFC1808_BASE, 'g.', 'http://a/b/c/g.') self.checkJoin(RFC1808_BASE, '.g', 'http://a/b/c/.g') self.checkJoin(RFC1808_BASE, 'g..', 'http://a/b/c/g..') @@ -257,13 +279,21 @@ def test_RFC1808(self): #self.checkJoin(RFC1808_BASE, 'http:g', 'http:g') #self.checkJoin(RFC1808_BASE, 'http:', 'http:') + # XXX: The following tests are no longer compatible with RFC3986 + # self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g') + # self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g') + # self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g') + # self.checkJoin(RFC1808_BASE, '/../g', 'http://a/../g') + + def test_RFC2368(self): # Issue 11467: path that starts with a number is not parsed correctly - self.assertEqual(urlparse.urlparse('mailto:1337@example.org'), + self.assertEqual(urlparse4.urlparse('mailto:1337@example.org'), ('mailto', '', '1337@example.org', '', '', '')) def test_RFC2396(self): # cases from RFC 2396 + self.checkJoin(RFC2396_BASE, 'g:h', 'g:h') self.checkJoin(RFC2396_BASE, 'g', 'http://a/b/c/g') self.checkJoin(RFC2396_BASE, './g', 'http://a/b/c/g') @@ -285,10 +315,6 @@ def test_RFC2396(self): self.checkJoin(RFC2396_BASE, '../../', 'http://a/') self.checkJoin(RFC2396_BASE, '../../g', 'http://a/g') self.checkJoin(RFC2396_BASE, '', RFC2396_BASE) - self.checkJoin(RFC2396_BASE, '../../../g', 'http://a/../g') - self.checkJoin(RFC2396_BASE, '../../../../g', 'http://a/../../g') - self.checkJoin(RFC2396_BASE, '/./g', 'http://a/./g') - self.checkJoin(RFC2396_BASE, '/../g', 'http://a/../g') self.checkJoin(RFC2396_BASE, 'g.', 'http://a/b/c/g.') self.checkJoin(RFC2396_BASE, '.g', 'http://a/b/c/.g') self.checkJoin(RFC2396_BASE, 'g..', 'http://a/b/c/g..') @@ -304,10 +330,15 @@ def test_RFC2396(self): self.checkJoin(RFC2396_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x') self.checkJoin(RFC2396_BASE, 'g#s/../x', 'http://a/b/c/g#s/../x') + # XXX: The following tests are no longer compatible with RFC3986 + # self.checkJoin(RFC2396_BASE, '../../../g', 'http://a/../g') + # self.checkJoin(RFC2396_BASE, '../../../../g', 'http://a/../../g') + # self.checkJoin(RFC2396_BASE, '/./g', 'http://a/./g') + # self.checkJoin(RFC2396_BASE, '/../g', 'http://a/../g') + def test_RFC3986(self): - # Test cases from RFC3986 self.checkJoin(RFC3986_BASE, '?y','http://a/b/c/d;p?y') - self.checkJoin(RFC2396_BASE, ';x', 'http://a/b/c/;x') + self.checkJoin(RFC3986_BASE, ';x', 'http://a/b/c/;x') self.checkJoin(RFC3986_BASE, 'g:h','g:h') self.checkJoin(RFC3986_BASE, 'g','http://a/b/c/g') self.checkJoin(RFC3986_BASE, './g','http://a/b/c/g') @@ -331,17 +362,17 @@ def test_RFC3986(self): self.checkJoin(RFC3986_BASE, '../..','http://a/') self.checkJoin(RFC3986_BASE, '../../','http://a/') self.checkJoin(RFC3986_BASE, '../../g','http://a/g') + self.checkJoin(RFC3986_BASE, '../../../g', 'http://a/g') - #Abnormal Examples + # Abnormal Examples # The 'abnormal scenarios' are incompatible with RFC2986 parsing # Tests are here for reference. - #self.checkJoin(RFC3986_BASE, '../../../g','http://a/g') - #self.checkJoin(RFC3986_BASE, '../../../../g','http://a/g') - #self.checkJoin(RFC3986_BASE, '/./g','http://a/g') - #self.checkJoin(RFC3986_BASE, '/../g','http://a/g') - + self.checkJoin(RFC3986_BASE, '../../../g','http://a/g') + self.checkJoin(RFC3986_BASE, '../../../../g','http://a/g') + self.checkJoin(RFC3986_BASE, '/./g','http://a/g') + self.checkJoin(RFC3986_BASE, '/../g','http://a/g') self.checkJoin(RFC3986_BASE, 'g.','http://a/b/c/g.') self.checkJoin(RFC3986_BASE, '.g','http://a/b/c/.g') self.checkJoin(RFC3986_BASE, 'g..','http://a/b/c/g..') @@ -357,7 +388,7 @@ def test_RFC3986(self): self.checkJoin(RFC3986_BASE, 'g#s/./x','http://a/b/c/g#s/./x') self.checkJoin(RFC3986_BASE, 'g#s/../x','http://a/b/c/g#s/../x') #self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser - self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') # relaxed parser + self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') #relaxed parser # Test for issue9721 self.checkJoin('http://a/b/c/de', ';x','http://a/b/c/;x') @@ -381,10 +412,8 @@ def test_urljoins(self): self.checkJoin(SIMPLE_BASE, '../g','http://a/b/g') self.checkJoin(SIMPLE_BASE, '../..','http://a/') self.checkJoin(SIMPLE_BASE, '../../g','http://a/g') - self.checkJoin(SIMPLE_BASE, '../../../g','http://a/../g') self.checkJoin(SIMPLE_BASE, './../g','http://a/b/g') self.checkJoin(SIMPLE_BASE, './g/.','http://a/b/c/g/') - self.checkJoin(SIMPLE_BASE, '/./g','http://a/./g') self.checkJoin(SIMPLE_BASE, 'g/./h','http://a/b/c/g/h') self.checkJoin(SIMPLE_BASE, 'g/../h','http://a/b/c/h') self.checkJoin(SIMPLE_BASE, 'http:g','http://a/b/c/g') @@ -395,11 +424,32 @@ def test_urljoins(self): self.checkJoin('http:///', '..','http:///') self.checkJoin('', 'http://a/b/c/g?y/./x','http://a/b/c/g?y/./x') self.checkJoin('', 'http://a/./g', 'http://a/./g') - self.checkJoin('svn://pathtorepo/dir1','dir2','svn://pathtorepo/dir2') - self.checkJoin('svn+ssh://pathtorepo/dir1','dir2','svn+ssh://pathtorepo/dir2') + self.checkJoin('svn://pathtorepo/dir1', 'dir2', 'svn://pathtorepo/dir2') + self.checkJoin('svn+ssh://pathtorepo/dir1', 'dir2', 'svn+ssh://pathtorepo/dir2') + self.checkJoin('ws://a/b','g','ws://a/g') + self.checkJoin('wss://a/b','g','wss://a/g') + + # XXX: The following tests are no longer compatible with RFC3986 + # self.checkJoin(SIMPLE_BASE, '../../../g','http://a/../g') + # self.checkJoin(SIMPLE_BASE, '/./g','http://a/./g') + + # test for issue22118 duplicate slashes + self.checkJoin(SIMPLE_BASE + '/', 'foo', SIMPLE_BASE + '/foo') + + # Non-RFC-defined tests, covering variations of base and trailing + # slashes + self.checkJoin('http://a/b/c/d/e/', '../../f/g/', 'http://a/b/c/f/g/') + self.checkJoin('http://a/b/c/d/e', '../../f/g/', 'http://a/b/f/g/') + self.checkJoin('http://a/b/c/d/e/', '/../../f/g/', 'http://a/f/g/') + self.checkJoin('http://a/b/c/d/e', '/../../f/g/', 'http://a/f/g/') + self.checkJoin('http://a/b/c/d/e/', '../../f/g', 'http://a/b/c/f/g') + self.checkJoin('http://a/b/', '../../f/g/', 'http://a/f/g/') + + # issue 23703: don't duplicate filename + self.checkJoin('a', 'b', 'b') def test_RFC2732(self): - for url, hostname, port in [ + str_cases = [ ('http://Test.python.org:5432/foo/', 'test.python.org', 5432), ('http://12.34.56.78:5432/foo/', '12.34.56.78', 5432), ('http://[::1]:5432/foo/', '::1', 5432), @@ -430,20 +480,26 @@ def test_RFC2732(self): ('http://[::12.34.56.78]:/foo/', '::12.34.56.78', None), ('http://[::ffff:12.34.56.78]:/foo/', '::ffff:12.34.56.78', None), - ]: - urlparsed = urlparse.urlparse(url) + ] + def _encode(t): + return t[0].encode('ascii'), t[1].encode('ascii'), t[2] + bytes_cases = [_encode(x) for x in str_cases] + for url, hostname, port in str_cases + bytes_cases: + urlparsed = urlparse4.urlparse(url) self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port)) - for invalid_url in [ + str_cases = [ 'http://::12.34.56.78]/', 'http://[::1/foo/', 'ftp://[::1/foo/bad]/bad', 'http://[::1/foo/bad]/bad', - 'http://[::ffff:12.34.56.78']: - self.assertRaises(ValueError, urlparse.urlparse, invalid_url) + 'http://[::ffff:12.34.56.78'] + bytes_cases = [x.encode('ascii') for x in str_cases] + for invalid_url in str_cases + bytes_cases: + self.assertRaises(ValueError, urlparse4.urlparse, invalid_url) def test_urldefrag(self): - for url, defrag, frag in [ + str_cases = [ ('http://python.org#frag', 'http://python.org', 'frag'), ('http://python.org', 'http://python.org', ''), ('http://python.org/#frag', 'http://python.org/', 'frag'), @@ -454,12 +510,29 @@ def test_urldefrag(self): ('http://python.org/p?q', 'http://python.org/p?q', ''), (RFC1808_BASE, 'http://a/b/c/d;p?q', 'f'), (RFC2396_BASE, 'http://a/b/c/d;p?q', ''), - ]: - self.assertEqual(urlparse.urldefrag(url), (defrag, frag)) + ] + def _encode(t): + return type(t)(x.encode('ascii') for x in t) + bytes_cases = [_encode(x) for x in str_cases] + for url, defrag, frag in str_cases + bytes_cases: + result = urlparse4.urldefrag(url) + self.assertEqual(result.geturl(), url) + self.assertEqual(result, (defrag, frag)) + self.assertEqual(result.url, defrag) + self.assertEqual(result.fragment, frag) + + def test_urlsplit_scoped_IPv6(self): + p = urlparse4.urlsplit('http://[FE80::822a:a8ff:fe49:470c%tESt]:1234') + self.assertEqual(p.hostname, "fe80::822a:a8ff:fe49:470c%tESt") + self.assertEqual(p.netloc, '[FE80::822a:a8ff:fe49:470c%tESt]:1234') + + p = urlparse4.urlsplit(b'http://[FE80::822a:a8ff:fe49:470c%tESt]:1234') + self.assertEqual(p.hostname, b"fe80::822a:a8ff:fe49:470c%tESt") + self.assertEqual(p.netloc, b'[FE80::822a:a8ff:fe49:470c%tESt]:1234') def test_urlsplit_attributes(self): url = "HTTP://WWW.PYTHON.ORG/doc/#frag" - p = urlparse.urlsplit(url) + p = urlparse4.urlsplit(url) self.assertEqual(p.scheme, "http") self.assertEqual(p.netloc, "WWW.PYTHON.ORG") self.assertEqual(p.path, "/doc/") @@ -471,10 +544,11 @@ def test_urlsplit_attributes(self): self.assertEqual(p.port, None) # geturl() won't return exactly the original URL in this case # since the scheme is always case-normalized - #self.assertEqual(p.geturl(), url) + # We handle this by ignoring the first 4 characters of the URL + self.assertEqual(p.geturl()[4:], url[4:]) url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag" - p = urlparse.urlsplit(url) + p = urlparse4.urlsplit(url) self.assertEqual(p.scheme, "http") self.assertEqual(p.netloc, "User:Pass@www.python.org:080") self.assertEqual(p.path, "/doc/") @@ -491,7 +565,7 @@ def test_urlsplit_attributes(self): # and request email addresses as usernames. url = "http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag" - p = urlparse.urlsplit(url) + p = urlparse4.urlsplit(url) self.assertEqual(p.scheme, "http") self.assertEqual(p.netloc, "User@example.com:Pass@www.python.org:080") self.assertEqual(p.path, "/doc/") @@ -503,61 +577,67 @@ def test_urlsplit_attributes(self): self.assertEqual(p.port, 80) self.assertEqual(p.geturl(), url) - # Verify an illegal port of value greater than 65535 is set as None - url = "http://www.python.org:65536" - p = urlparse.urlsplit(url) + # And check them all again, only with bytes this time + url = b"HTTP://WWW.PYTHON.ORG/doc/#frag" + p = urlparse4.urlsplit(url) + self.assertEqual(p.scheme, b"http") + self.assertEqual(p.netloc, b"WWW.PYTHON.ORG") + self.assertEqual(p.path, b"/doc/") + self.assertEqual(p.query, b"") + self.assertEqual(p.fragment, b"frag") + self.assertEqual(p.username, None) + self.assertEqual(p.password, None) + self.assertEqual(p.hostname, b"www.python.org") self.assertEqual(p.port, None) + self.assertEqual(p.geturl()[4:], url[4:]) - def test_issue14072(self): - p1 = urlparse.urlsplit('tel:+31-641044153') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '+31-641044153') - - p2 = urlparse.urlsplit('tel:+31641044153') - self.assertEqual(p2.scheme, 'tel') - self.assertEqual(p2.path, '+31641044153') - - # Assert for urlparse - p1 = urlparse.urlparse('tel:+31-641044153') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '+31-641044153') - - p2 = urlparse.urlparse('tel:+31641044153') - self.assertEqual(p2.scheme, 'tel') - self.assertEqual(p2.path, '+31641044153') - - - def test_telurl_params(self): - p1 = urlparse.urlparse('tel:123-4;phone-context=+1-650-516') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '123-4') - self.assertEqual(p1.params, 'phone-context=+1-650-516') - - p1 = urlparse.urlparse('tel:+1-201-555-0123') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '+1-201-555-0123') - self.assertEqual(p1.params, '') - - p1 = urlparse.urlparse('tel:7042;phone-context=example.com') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '7042') - self.assertEqual(p1.params, 'phone-context=example.com') + url = b"http://User:Pass@www.python.org:080/doc/?query=yes#frag" + p = urlparse4.urlsplit(url) + self.assertEqual(p.scheme, b"http") + self.assertEqual(p.netloc, b"User:Pass@www.python.org:080") + self.assertEqual(p.path, b"/doc/") + self.assertEqual(p.query, b"query=yes") + self.assertEqual(p.fragment, b"frag") + self.assertEqual(p.username, b"User") + self.assertEqual(p.password, b"Pass") + self.assertEqual(p.hostname, b"www.python.org") + self.assertEqual(p.port, 80) + self.assertEqual(p.geturl(), url) - p1 = urlparse.urlparse('tel:863-1234;phone-context=+1-914-555') - self.assertEqual(p1.scheme, 'tel') - self.assertEqual(p1.path, '863-1234') - self.assertEqual(p1.params, 'phone-context=+1-914-555') + url = b"http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag" + p = urlparse4.urlsplit(url) + self.assertEqual(p.scheme, b"http") + self.assertEqual(p.netloc, b"User@example.com:Pass@www.python.org:080") + self.assertEqual(p.path, b"/doc/") + self.assertEqual(p.query, b"query=yes") + self.assertEqual(p.fragment, b"frag") + self.assertEqual(p.username, b"User@example.com") + self.assertEqual(p.password, b"Pass") + self.assertEqual(p.hostname, b"www.python.org") + self.assertEqual(p.port, 80) + self.assertEqual(p.geturl(), url) + # Verify an illegal port raises ValueError + url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag" + p = urlparse4.urlsplit(url) + with self.assertRaisesRegex(ValueError, "out of range"): + p.port def test_attributes_bad_port(self): - """Check handling of non-integer ports.""" - p = urlparse.urlsplit("http://www.example.net:foo") - self.assertEqual(p.netloc, "www.example.net:foo") - self.assertRaises(ValueError, lambda: p.port) - - p = urlparse.urlparse("http://www.example.net:foo") - self.assertEqual(p.netloc, "www.example.net:foo") - self.assertRaises(ValueError, lambda: p.port) + """Check handling of invalid ports.""" + for bytes in (False, True): + for parse in (urlparse4.urlsplit, urlparse4.urlparse): + for port in ("foo", "1.5", "-1", "0x10"): + with self.subTest(bytes=bytes, parse=parse, port=port): + netloc = "www.example.net:" + port + url = "http://" + netloc + if bytes: + netloc = netloc.encode("ascii") + url = url.encode("ascii") + p = parse(url) + self.assertEqual(p.netloc, netloc) + with self.assertRaises(ValueError): + p.port def test_attributes_without_netloc(self): # This example is straight from RFC 3261. It looks like it @@ -566,7 +646,7 @@ def test_attributes_without_netloc(self): # scheme://netloc syntax, the netloc and related attributes # should be left empty. uri = "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15" - p = urlparse.urlsplit(uri) + p = urlparse4.urlsplit(uri) self.assertEqual(p.netloc, "") self.assertEqual(p.username, None) self.assertEqual(p.password, None) @@ -574,7 +654,7 @@ def test_attributes_without_netloc(self): self.assertEqual(p.port, None) self.assertEqual(p.geturl(), uri) - p = urlparse.urlparse(uri) + p = urlparse4.urlparse(uri) self.assertEqual(p.netloc, "") self.assertEqual(p.username, None) self.assertEqual(p.password, None) @@ -582,56 +662,566 @@ def test_attributes_without_netloc(self): self.assertEqual(p.port, None) self.assertEqual(p.geturl(), uri) - def test_caching(self): - # Test case for bug #1313119 - uri = "http://example.com/doc/" - unicode_uri = unicode(uri) + # You guessed it, repeating the test with bytes input + uri = b"sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15" + p = urlparse4.urlsplit(uri) + self.assertEqual(p.netloc, b"") + self.assertEqual(p.username, None) + self.assertEqual(p.password, None) + self.assertEqual(p.hostname, None) + self.assertEqual(p.port, None) + self.assertEqual(p.geturl(), uri) - urlparse.urlparse(unicode_uri) - p = urlparse.urlparse(uri) - self.assertEqual(type(p.scheme), type(uri)) - self.assertEqual(type(p.hostname), type(uri)) - self.assertEqual(type(p.path), type(uri)) + p = urlparse4.urlparse(uri) + self.assertEqual(p.netloc, b"") + self.assertEqual(p.username, None) + self.assertEqual(p.password, None) + self.assertEqual(p.hostname, None) + self.assertEqual(p.port, None) + self.assertEqual(p.geturl(), uri) def test_noslash(self): # Issue 1637: http://foo.com?query is legal - self.assertEqual(urlparse.urlparse("http://example.com?blahblah=/foo"), + self.assertEqual(urlparse4.urlparse("http://example.com?blahblah=/foo"), ('http', 'example.com', '', '', 'blahblah=/foo', '')) - - def test_anyscheme(self): - # Issue 7904: s3://foo.com/stuff has netloc "foo.com". - self.assertEqual(urlparse.urlparse("s3://foo.com/stuff"), - ('s3','foo.com','/stuff','','','')) - self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff"), - ('x-newscheme','foo.com','/stuff','','','')) - self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff?query#fragment"), - ('x-newscheme','foo.com','/stuff','','query','fragment')) - self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff?query"), - ('x-newscheme','foo.com','/stuff','','query','')) + self.assertEqual(urlparse4.urlparse(b"http://example.com?blahblah=/foo"), + (b'http', b'example.com', b'', b'', b'blahblah=/foo', b'')) def test_withoutscheme(self): # Test urlparse without scheme # Issue 754016: urlparse goes wrong with IP:port without scheme # RFC 1808 specifies that netloc should start with //, urlparse expects # the same, otherwise it classifies the portion of url as path. - self.assertEqual(urlparse.urlparse("path"), + self.assertEqual(urlparse4.urlparse("path"), ('','','path','','','')) - self.assertEqual(urlparse.urlparse("//www.python.org:80"), + self.assertEqual(urlparse4.urlparse("//www.python.org:80"), ('','www.python.org:80','','','','')) - self.assertEqual(urlparse.urlparse("http://www.python.org:80"), + self.assertEqual(urlparse4.urlparse("http://www.python.org:80"), ('http','www.python.org:80','','','','')) + # Repeat for bytes input + self.assertEqual(urlparse4.urlparse(b"path"), + (b'',b'',b'path',b'',b'',b'')) + self.assertEqual(urlparse4.urlparse(b"//www.python.org:80"), + (b'',b'www.python.org:80',b'',b'',b'',b'')) + self.assertEqual(urlparse4.urlparse(b"http://www.python.org:80"), + (b'http',b'www.python.org:80',b'',b'',b'',b'')) def test_portseparator(self): # Issue 754016 makes changes for port separator ':' from scheme separator - self.assertEqual(urlparse.urlparse("path:80"), + self.assertEqual(urlparse4.urlparse("path:80"), ('','','path:80','','','')) - self.assertEqual(urlparse.urlparse("http:"),('http','','','','','')) - self.assertEqual(urlparse.urlparse("https:"),('https','','','','','')) - self.assertEqual(urlparse.urlparse("http://www.python.org:80"), + self.assertEqual(urlparse4.urlparse("http:"),('http','','','','','')) + self.assertEqual(urlparse4.urlparse("https:"),('https','','','','','')) + self.assertEqual(urlparse4.urlparse("http://www.python.org:80"), ('http','www.python.org:80','','','','')) + # As usual, need to check bytes input as well + self.assertEqual(urlparse4.urlparse(b"path:80"), + (b'',b'',b'path:80',b'',b'',b'')) + self.assertEqual(urlparse4.urlparse(b"http:"),(b'http',b'',b'',b'',b'',b'')) + self.assertEqual(urlparse4.urlparse(b"https:"),(b'https',b'',b'',b'',b'',b'')) + self.assertEqual(urlparse4.urlparse(b"http://www.python.org:80"), + (b'http',b'www.python.org:80',b'',b'',b'',b'')) + + def test_usingsys(self): + # Issue 3314: sys module is used in the error + self.assertRaises(TypeError, urlparse4.urlencode, "foo") + + def test_anyscheme(self): + # Issue 7904: s3://foo.com/stuff has netloc "foo.com". + self.assertEqual(urlparse4.urlparse("s3://foo.com/stuff"), + ('s3', 'foo.com', '/stuff', '', '', '')) + self.assertEqual(urlparse4.urlparse("x-newscheme://foo.com/stuff"), + ('x-newscheme', 'foo.com', '/stuff', '', '', '')) + self.assertEqual(urlparse4.urlparse("x-newscheme://foo.com/stuff?query#fragment"), + ('x-newscheme', 'foo.com', '/stuff', '', 'query', 'fragment')) + self.assertEqual(urlparse4.urlparse("x-newscheme://foo.com/stuff?query"), + ('x-newscheme', 'foo.com', '/stuff', '', 'query', '')) + + # And for bytes... + self.assertEqual(urlparse4.urlparse(b"s3://foo.com/stuff"), + (b's3', b'foo.com', b'/stuff', b'', b'', b'')) + self.assertEqual(urlparse4.urlparse(b"x-newscheme://foo.com/stuff"), + (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b'')) + self.assertEqual(urlparse4.urlparse(b"x-newscheme://foo.com/stuff?query#fragment"), + (b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b'fragment')) + self.assertEqual(urlparse4.urlparse(b"x-newscheme://foo.com/stuff?query"), + (b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b'')) + + def test_default_scheme(self): + # Exercise the scheme parameter of urlparse() and urlsplit() + for func in (urlparse4.urlparse, urlparse4.urlsplit): + with self.subTest(function=func): + result = func("http://example.net/", "ftp") + self.assertEqual(result.scheme, "http") + result = func(b"http://example.net/", b"ftp") + self.assertEqual(result.scheme, b"http") + self.assertEqual(func("path", "ftp").scheme, "ftp") + self.assertEqual(func("path", scheme="ftp").scheme, "ftp") + self.assertEqual(func(b"path", scheme=b"ftp").scheme, b"ftp") + self.assertEqual(func("path").scheme, "") + self.assertEqual(func(b"path").scheme, b"") + self.assertEqual(func(b"path", "").scheme, b"") + + def test_parse_fragments(self): + # Exercise the allow_fragments parameter of urlparse() and urlsplit() + tests = ( + ("http:#frag", "path", "frag"), + ("//example.net#frag", "path", "frag"), + ("index.html#frag", "path", "frag"), + (";a=b#frag", "params", "frag"), + ("?a=b#frag", "query", "frag"), + ("#frag", "path", "frag"), + ("abc#@frag", "path", "@frag"), + ("//abc#@frag", "path", "@frag"), + ("//abc:80#@frag", "path", "@frag"), + ("//abc#@frag:80", "path", "@frag:80"), + ) + for url, attr, expected_frag in tests: + for func in (urlparse4.urlparse, urlparse4.urlsplit): + if attr == "params" and func is urlparse4.urlsplit: + attr = "path" + with self.subTest(url=url, function=func): + result = func(url, allow_fragments=False) + self.assertEqual(result.fragment, "") + self.assertTrue( + getattr(result, attr).endswith("#" + expected_frag)) + self.assertEqual(func(url, "", False).fragment, "") + + result = func(url, allow_fragments=True) + self.assertEqual(result.fragment, expected_frag) + self.assertFalse( + getattr(result, attr).endswith(expected_frag)) + self.assertEqual(func(url, "", True).fragment, + expected_frag) + self.assertEqual(func(url).fragment, expected_frag) + + def test_mixed_types_rejected(self): + # Several functions that process either strings or ASCII encoded bytes + # accept multiple arguments. Check they reject mixed type input + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urlparse("www.python.org", b"http") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urlparse(b"www.python.org", "http") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urlsplit("www.python.org", b"http") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urlsplit(b"www.python.org", "http") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urlunparse(( b"http", "www.python.org","","","","")) + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urlunparse(("http", b"www.python.org","","","","")) + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urlunsplit((b"http", "www.python.org","","","")) + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urlunsplit(("http", b"www.python.org","","","")) + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urljoin("http://python.org", b"http://python.org") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urlparse4.urljoin(b"http://python.org", "http://python.org") + + def _check_result_type(self, str_type): + num_args = len(str_type._fields) + bytes_type = str_type._encoded_counterpart + self.assertIs(bytes_type._decoded_counterpart, str_type) + str_args = ('',) * num_args + bytes_args = (b'',) * num_args + str_result = str_type(*str_args) + bytes_result = bytes_type(*bytes_args) + encoding = 'ascii' + errors = 'strict' + self.assertEqual(str_result, str_args) + self.assertEqual(bytes_result.decode(), str_args) + self.assertEqual(bytes_result.decode(), str_result) + self.assertEqual(bytes_result.decode(encoding), str_args) + self.assertEqual(bytes_result.decode(encoding), str_result) + self.assertEqual(bytes_result.decode(encoding, errors), str_args) + self.assertEqual(bytes_result.decode(encoding, errors), str_result) + self.assertEqual(bytes_result, bytes_args) + self.assertEqual(str_result.encode(), bytes_args) + self.assertEqual(str_result.encode(), bytes_result) + self.assertEqual(str_result.encode(encoding), bytes_args) + self.assertEqual(str_result.encode(encoding), bytes_result) + self.assertEqual(str_result.encode(encoding, errors), bytes_args) + self.assertEqual(str_result.encode(encoding, errors), bytes_result) + + def test_result_pairs(self): + # Check encoding and decoding between result pairs + result_types = [ + urlparse4.DefragResult, + urlparse4.SplitResult, + urlparse4.ParseResult, + ] + for result_type in result_types: + self._check_result_type(result_type) + + def test_parse_qs_encoding(self): + result = urlparse4.parse_qs("key=\u0141%E9", encoding="latin-1") + self.assertEqual(result, {'key': ['\u0141\xE9']}) + result = urlparse4.parse_qs("key=\u0141%C3%A9", encoding="utf-8") + self.assertEqual(result, {'key': ['\u0141\xE9']}) + result = urlparse4.parse_qs("key=\u0141%C3%A9", encoding="ascii") + self.assertEqual(result, {'key': ['\u0141\ufffd\ufffd']}) + result = urlparse4.parse_qs("key=\u0141%E9-", encoding="ascii") + self.assertEqual(result, {'key': ['\u0141\ufffd-']}) + result = urlparse4.parse_qs("key=\u0141%E9-", encoding="ascii", + errors="ignore") + self.assertEqual(result, {'key': ['\u0141-']}) + + def test_parse_qsl_encoding(self): + result = urlparse4.parse_qsl("key=\u0141%E9", encoding="latin-1") + self.assertEqual(result, [('key', '\u0141\xE9')]) + result = urlparse4.parse_qsl("key=\u0141%C3%A9", encoding="utf-8") + self.assertEqual(result, [('key', '\u0141\xE9')]) + result = urlparse4.parse_qsl("key=\u0141%C3%A9", encoding="ascii") + self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')]) + result = urlparse4.parse_qsl("key=\u0141%E9-", encoding="ascii") + self.assertEqual(result, [('key', '\u0141\ufffd-')]) + result = urlparse4.parse_qsl("key=\u0141%E9-", encoding="ascii", + errors="ignore") + self.assertEqual(result, [('key', '\u0141-')]) + + def test_urlencode_sequences(self): + # Other tests incidentally urlencode things; test non-covered cases: + # Sequence and object values. + result = urlparse4.urlencode({'a': [1, 2], 'b': (3, 4, 5)}, True) + # we cannot rely on ordering here + assert set(result.split('&')) == {'a=1', 'a=2', 'b=3', 'b=4', 'b=5'} + + class Trivial: + def __str__(self): + return 'trivial' + + result = urlparse4.urlencode({'a': Trivial()}, True) + self.assertEqual(result, 'a=trivial') + + def test_urlencode_quote_via(self): + result = urlparse4.urlencode({'a': 'some value'}) + self.assertEqual(result, "a=some+value") + result = urlparse4.urlencode({'a': 'some value/another'}, + quote_via=urlparse4.quote) + self.assertEqual(result, "a=some%20value%2Fanother") + result = urlparse4.urlencode({'a': 'some value/another'}, + safe='/', quote_via=urlparse4.quote) + self.assertEqual(result, "a=some%20value/another") + + def test_quote_from_bytes(self): + self.assertRaises(TypeError, urlparse4.quote_from_bytes, 'foo') + result = urlparse4.quote_from_bytes(b'archaeological arcana') + self.assertEqual(result, 'archaeological%20arcana') + result = urlparse4.quote_from_bytes(b'') + self.assertEqual(result, '') + + def test_unquote_to_bytes(self): + result = urlparse4.unquote_to_bytes('abc%20def') + self.assertEqual(result, b'abc def') + result = urlparse4.unquote_to_bytes('') + self.assertEqual(result, b'') + + def test_quote_errors(self): + self.assertRaises(TypeError, urlparse4.quote, b'foo', + encoding='utf-8') + self.assertRaises(TypeError, urlparse4.quote, b'foo', errors='strict') + + def test_issue14072(self): + p1 = urlparse4.urlsplit('tel:+31-641044153') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+31-641044153') + p2 = urlparse4.urlsplit('tel:+31641044153') + self.assertEqual(p2.scheme, 'tel') + self.assertEqual(p2.path, '+31641044153') + # assert the behavior for urlparse + p1 = urlparse4.urlparse('tel:+31-641044153') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+31-641044153') + p2 = urlparse4.urlparse('tel:+31641044153') + self.assertEqual(p2.scheme, 'tel') + self.assertEqual(p2.path, '+31641044153') + + def test_port_casting_failure_message(self): + message = "Port could not be cast to integer value as 'oracle'" + p1 = urlparse4.urlparse('http://Server=sde; Service=sde:oracle') + with self.assertRaisesRegex(ValueError, message): + p1.port + + p2 = urlparse4.urlsplit('http://Server=sde; Service=sde:oracle') + with self.assertRaisesRegex(ValueError, message): + p2.port + + def test_telurl_params(self): + p1 = urlparse4.urlparse('tel:123-4;phone-context=+1-650-516') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '123-4') + self.assertEqual(p1.params, 'phone-context=+1-650-516') + + p1 = urlparse4.urlparse('tel:+1-201-555-0123') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+1-201-555-0123') + self.assertEqual(p1.params, '') + + p1 = urlparse4.urlparse('tel:7042;phone-context=example.com') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '7042') + self.assertEqual(p1.params, 'phone-context=example.com') + + p1 = urlparse4.urlparse('tel:863-1234;phone-context=+1-914-555') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '863-1234') + self.assertEqual(p1.params, 'phone-context=+1-914-555') + + def test_Quoter_repr(self): + quoter = urlparse4.Quoter(urlparse4._ALWAYS_SAFE) + self.assertIn('Quoter', repr(quoter)) + + def test_all(self): + expected = [] + undocumented = { + 'splitattr', 'splithost', 'splitnport', 'splitpasswd', + 'splitport', 'splitquery', 'splittag', 'splittype', 'splituser', + 'splitvalue', + 'Quoter', 'ResultBase', 'clear_cache', 'to_bytes', 'unwrap', + } + for name in dir(urlparse4): + if name.startswith('_') or name in undocumented: + continue + object = getattr(urlparse4, name) + if getattr(object, '__module__', None) == 'urlparse4': + expected.append(name) + self.assertCountEqual(urlparse4.__all__, expected) + + +class Utility_Tests(unittest.TestCase): + """Testcase to test the various utility functions in the urllib.""" + # In Python 2 this test class was in test_urllib. + + def test_splittype(self): + splittype = urlparse4._splittype + self.assertEqual(splittype('type:opaquestring'), ('type', 'opaquestring')) + self.assertEqual(splittype('opaquestring'), (None, 'opaquestring')) + self.assertEqual(splittype(':opaquestring'), (None, ':opaquestring')) + self.assertEqual(splittype('type:'), ('type', '')) + self.assertEqual(splittype('type:opaque:string'), ('type', 'opaque:string')) + + def test_splithost(self): + splithost = urlparse4._splithost + self.assertEqual(splithost('//www.example.org:80/foo/bar/baz.html'), + ('www.example.org:80', '/foo/bar/baz.html')) + self.assertEqual(splithost('//www.example.org:80'), + ('www.example.org:80', '')) + self.assertEqual(splithost('/foo/bar/baz.html'), + (None, '/foo/bar/baz.html')) + + # bpo-30500: # starts a fragment. + self.assertEqual(splithost('//127.0.0.1#@host.com'), + ('127.0.0.1', '/#@host.com')) + self.assertEqual(splithost('//127.0.0.1#@host.com:80'), + ('127.0.0.1', '/#@host.com:80')) + self.assertEqual(splithost('//127.0.0.1:80#@host.com'), + ('127.0.0.1:80', '/#@host.com')) + + # Empty host is returned as empty string. + self.assertEqual(splithost("///file"), + ('', '/file')) + + # Trailing semicolon, question mark and hash symbol are kept. + self.assertEqual(splithost("//example.net/file;"), + ('example.net', '/file;')) + self.assertEqual(splithost("//example.net/file?"), + ('example.net', '/file?')) + self.assertEqual(splithost("//example.net/file#"), + ('example.net', '/file#')) + + def test_splituser(self): + splituser = urlparse4._splituser + self.assertEqual(splituser('User:Pass@www.python.org:080'), + ('User:Pass', 'www.python.org:080')) + self.assertEqual(splituser('@www.python.org:080'), + ('', 'www.python.org:080')) + self.assertEqual(splituser('www.python.org:080'), + (None, 'www.python.org:080')) + self.assertEqual(splituser('User:Pass@'), + ('User:Pass', '')) + self.assertEqual(splituser('User@example.com:Pass@www.python.org:080'), + ('User@example.com:Pass', 'www.python.org:080')) + + def test_splitpasswd(self): + # Some of the password examples are not sensible, but it is added to + # confirming to RFC2617 and addressing issue4675. + splitpasswd = urlparse4._splitpasswd + self.assertEqual(splitpasswd('user:ab'), ('user', 'ab')) + self.assertEqual(splitpasswd('user:a\nb'), ('user', 'a\nb')) + self.assertEqual(splitpasswd('user:a\tb'), ('user', 'a\tb')) + self.assertEqual(splitpasswd('user:a\rb'), ('user', 'a\rb')) + self.assertEqual(splitpasswd('user:a\fb'), ('user', 'a\fb')) + self.assertEqual(splitpasswd('user:a\vb'), ('user', 'a\vb')) + self.assertEqual(splitpasswd('user:a:b'), ('user', 'a:b')) + self.assertEqual(splitpasswd('user:a b'), ('user', 'a b')) + self.assertEqual(splitpasswd('user 2:ab'), ('user 2', 'ab')) + self.assertEqual(splitpasswd('user+1:a+b'), ('user+1', 'a+b')) + self.assertEqual(splitpasswd('user:'), ('user', '')) + self.assertEqual(splitpasswd('user'), ('user', None)) + self.assertEqual(splitpasswd(':ab'), ('', 'ab')) + + def test_splitport(self): + splitport = urlparse4._splitport + self.assertEqual(splitport('parrot:88'), ('parrot', '88')) + self.assertEqual(splitport('parrot'), ('parrot', None)) + self.assertEqual(splitport('parrot:'), ('parrot', None)) + self.assertEqual(splitport('127.0.0.1'), ('127.0.0.1', None)) + self.assertEqual(splitport('parrot:cheese'), ('parrot:cheese', None)) + self.assertEqual(splitport('[::1]:88'), ('[::1]', '88')) + self.assertEqual(splitport('[::1]'), ('[::1]', None)) + self.assertEqual(splitport(':88'), ('', '88')) + + def test_splitnport(self): + splitnport = urlparse4._splitnport + self.assertEqual(splitnport('parrot:88'), ('parrot', 88)) + self.assertEqual(splitnport('parrot'), ('parrot', -1)) + self.assertEqual(splitnport('parrot', 55), ('parrot', 55)) + self.assertEqual(splitnport('parrot:'), ('parrot', -1)) + self.assertEqual(splitnport('parrot:', 55), ('parrot', 55)) + self.assertEqual(splitnport('127.0.0.1'), ('127.0.0.1', -1)) + self.assertEqual(splitnport('127.0.0.1', 55), ('127.0.0.1', 55)) + self.assertEqual(splitnport('parrot:cheese'), ('parrot', None)) + self.assertEqual(splitnport('parrot:cheese', 55), ('parrot', None)) + + def test_splitquery(self): + # Normal cases are exercised by other tests; ensure that we also + # catch cases with no port specified (testcase ensuring coverage) + splitquery = urlparse4._splitquery + self.assertEqual(splitquery('http://python.org/fake?foo=bar'), + ('http://python.org/fake', 'foo=bar')) + self.assertEqual(splitquery('http://python.org/fake?foo=bar?'), + ('http://python.org/fake?foo=bar', '')) + self.assertEqual(splitquery('http://python.org/fake'), + ('http://python.org/fake', None)) + self.assertEqual(splitquery('?foo=bar'), ('', 'foo=bar')) + + def test_splittag(self): + splittag = urlparse4._splittag + self.assertEqual(splittag('http://example.com?foo=bar#baz'), + ('http://example.com?foo=bar', 'baz')) + self.assertEqual(splittag('http://example.com?foo=bar#'), + ('http://example.com?foo=bar', '')) + self.assertEqual(splittag('#baz'), ('', 'baz')) + self.assertEqual(splittag('http://example.com?foo=bar'), + ('http://example.com?foo=bar', None)) + self.assertEqual(splittag('http://example.com?foo=bar#baz#boo'), + ('http://example.com?foo=bar#baz', 'boo')) + + def test_splitattr(self): + splitattr = urlparse4._splitattr + self.assertEqual(splitattr('/path;attr1=value1;attr2=value2'), + ('/path', ['attr1=value1', 'attr2=value2'])) + self.assertEqual(splitattr('/path;'), ('/path', [''])) + self.assertEqual(splitattr(';attr1=value1;attr2=value2'), + ('', ['attr1=value1', 'attr2=value2'])) + self.assertEqual(splitattr('/path'), ('/path', [])) + + def test_splitvalue(self): + # Normal cases are exercised by other tests; test pathological cases + # with no key/value pairs. (testcase ensuring coverage) + splitvalue = urlparse4._splitvalue + self.assertEqual(splitvalue('foo=bar'), ('foo', 'bar')) + self.assertEqual(splitvalue('foo='), ('foo', '')) + self.assertEqual(splitvalue('=bar'), ('', 'bar')) + self.assertEqual(splitvalue('foobar'), ('foobar', None)) + self.assertEqual(splitvalue('foo=bar=baz'), ('foo', 'bar=baz')) + + def test_to_bytes(self): + result = urlparse4._to_bytes('http://www.python.org') + self.assertEqual(result, 'http://www.python.org') + self.assertRaises(UnicodeError, urlparse4._to_bytes, + 'http://www.python.org/medi\u00e6val') + + def test_unwrap(self): + url = urlparse4._unwrap('') + self.assertEqual(url, 'type://host/path') + + +class DeprecationTest(unittest.TestCase): + + def test_splittype_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splittype('') + self.assertEqual(str(cm.warning), + 'urlparse4.splittype() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') + + def test_splithost_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splithost('') + self.assertEqual(str(cm.warning), + 'urlparse4.splithost() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') + + def test_splituser_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splituser('') + self.assertEqual(str(cm.warning), + 'urlparse4.splituser() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') + + def test_splitpasswd_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splitpasswd('') + self.assertEqual(str(cm.warning), + 'urlparse4.splitpasswd() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') + + def test_splitport_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splitport('') + self.assertEqual(str(cm.warning), + 'urlparse4.splitport() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') + + def test_splitnport_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splitnport('') + self.assertEqual(str(cm.warning), + 'urlparse4.splitnport() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') + + def test_splitquery_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splitquery('') + self.assertEqual(str(cm.warning), + 'urlparse4.splitquery() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') + + def test_splittag_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splittag('') + self.assertEqual(str(cm.warning), + 'urlparse4.splittag() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') + + def test_splitattr_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splitattr('') + self.assertEqual(str(cm.warning), + 'urlparse4.splitattr() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') + + def test_splitvalue_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.splitvalue('') + self.assertEqual(str(cm.warning), + 'urlparse4.splitvalue() is deprecated as of 3.8, ' + 'use urlparse4.parse_qsl() instead') + + def test_to_bytes_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.to_bytes('') + self.assertEqual(str(cm.warning), + 'urlparse4.to_bytes() is deprecated as of 3.8') + + def test_unwrap(self): + with self.assertWarns(DeprecationWarning) as cm: + urlparse4.unwrap('') + self.assertEqual(str(cm.warning), + 'urlparse4.unwrap() is deprecated as of 3.8') -# def test_main(): -# test_support.run_unittest(UrlParseTestCase) -# if __name__ == "__main__": -# test_main() \ No newline at end of file +if __name__ == "__main__": + unittest.main() diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e74b66b --- /dev/null +++ b/tox.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py36 + +[testenv] +deps = + pytest + +commands = pytest tests/ diff --git a/urlparse4/__init__.py b/urlparse4/__init__.py index cb167ba..dc1c441 100644 --- a/urlparse4/__init__.py +++ b/urlparse4/__init__.py @@ -1,6 +1,12 @@ # https://github.com/python/cpython/blob/2.7/Lib/urlparse.py -from urlparse import * +import six + +if six.PY2: + from urlparse import * +else: + from urllib.parse import * + _original_urlsplit = urlsplit _original_urljoin = urljoin diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index c9a452c..a097cfa 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -1,26 +1,58 @@ -/* Generated by Cython 0.24 */ +/* Generated by Cython 0.28.3 */ /* BEGIN: Cython Metadata { "distutils": { "depends": [ - "vendor/gurl/url/gurl.h", + "vendor/gurl/url/gurl.h", "vendor/gurl/url/third_party/mozilla/url_parse.h" - ], + ], "extra_compile_args": [ - "-std=gnu++0x", - "-I./vendor/gurl/", - "-fPIC", - "-Ofast", - "-pthread", + "-std=gnu++0x", + "-I./vendor/gurl/", + "-fPIC", + "-Ofast", + "-pthread", "-w" - ], + ], "extra_link_args": [ - "-std=gnu++0x", + "-std=gnu++0x", "-w" - ], - "language": "c++" - } + ], + "include_dirs": [ + "./urlparse4" + ], + "language": "c++", + "name": "cgurl", + "sources": [ + "urlparse4/cgurl.pyx", + "vendor/gurl/base/third_party/icu/icu_utf.cc", + "vendor/gurl/base/strings/string16.cc", + "vendor/gurl/base/strings/string_piece.cc", + "vendor/gurl/base/strings/string_util.cc", + "vendor/gurl/base/strings/utf_string_conversions.cc", + "vendor/gurl/base/strings/utf_string_conversion_utils.cc", + "vendor/gurl/url/gurl.cc", + "vendor/gurl/url/url_canon_etc.cc", + "vendor/gurl/url/url_canon_filesystemurl.cc", + "vendor/gurl/url/url_canon_fileurl.cc", + "vendor/gurl/url/url_canon_host.cc", + "vendor/gurl/url/url_canon_internal.cc", + "vendor/gurl/url/url_canon_ip.cc", + "vendor/gurl/url/url_canon_mailtourl.cc", + "vendor/gurl/url/url_canon_path.cc", + "vendor/gurl/url/url_canon_pathurl.cc", + "vendor/gurl/url/url_canon_query.cc", + "vendor/gurl/url/url_canon_relative.cc", + "vendor/gurl/url/url_canon_stdstring.cc", + "vendor/gurl/url/url_canon_stdurl.cc", + "vendor/gurl/url/url_constants.cc", + "vendor/gurl/url/url_parse_file.cc", + "vendor/gurl/url/url_util.cc", + "vendor/gurl/url/third_party/mozilla/url_parse.cc" + ] + }, + "module_name": "cgurl" } END: Cython Metadata */ @@ -28,10 +60,11 @@ END: Cython Metadata */ #include "Python.h" #ifndef Py_PYTHON_H #error Python headers needed to compile C extensions, please install development version of Python. -#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) - #error Cython requires Python 2.6+ or Python 3.2+. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) + #error Cython requires Python 2.6+ or Python 3.3+. #else -#define CYTHON_ABI "0_24" +#define CYTHON_ABI "0_28_3" +#define CYTHON_FUTURE_DIVISION 0 #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -53,6 +86,12 @@ END: Cython Metadata */ #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif +#define __PYX_COMMA , +#ifndef HAVE_LONG_LONG + #if PY_VERSION_HEX >= 0x02070000 + #define HAVE_LONG_LONG + #endif +#endif #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif @@ -61,13 +100,138 @@ END: Cython Metadata */ #endif #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 + #define CYTHON_COMPILING_IN_PYSTON 0 + #define CYTHON_COMPILING_IN_CPYTHON 0 + #undef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 0 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #if PY_VERSION_HEX < 0x03050000 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #undef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #undef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 1 + #undef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 0 + #undef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 0 + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 +#elif defined(PYSTON_VERSION) + #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 1 #define CYTHON_COMPILING_IN_CPYTHON 0 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #undef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 0 + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #undef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 0 + #undef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 0 + #undef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT 0 + #undef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE 0 #else #define CYTHON_COMPILING_IN_PYPY 0 + #define CYTHON_COMPILING_IN_PYSTON 0 #define CYTHON_COMPILING_IN_CPYTHON 1 + #ifndef CYTHON_USE_TYPE_SLOTS + #define CYTHON_USE_TYPE_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYTYPE_LOOKUP + #define CYTHON_USE_PYTYPE_LOOKUP 0 + #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) + #define CYTHON_USE_PYTYPE_LOOKUP 1 + #endif + #if PY_MAJOR_VERSION < 3 + #undef CYTHON_USE_ASYNC_SLOTS + #define CYTHON_USE_ASYNC_SLOTS 0 + #elif !defined(CYTHON_USE_ASYNC_SLOTS) + #define CYTHON_USE_ASYNC_SLOTS 1 + #endif + #if PY_VERSION_HEX < 0x02070000 + #undef CYTHON_USE_PYLONG_INTERNALS + #define CYTHON_USE_PYLONG_INTERNALS 0 + #elif !defined(CYTHON_USE_PYLONG_INTERNALS) + #define CYTHON_USE_PYLONG_INTERNALS 1 + #endif + #ifndef CYTHON_USE_PYLIST_INTERNALS + #define CYTHON_USE_PYLIST_INTERNALS 1 + #endif + #ifndef CYTHON_USE_UNICODE_INTERNALS + #define CYTHON_USE_UNICODE_INTERNALS 1 + #endif + #if PY_VERSION_HEX < 0x030300F0 + #undef CYTHON_USE_UNICODE_WRITER + #define CYTHON_USE_UNICODE_WRITER 0 + #elif !defined(CYTHON_USE_UNICODE_WRITER) + #define CYTHON_USE_UNICODE_WRITER 1 + #endif + #ifndef CYTHON_AVOID_BORROWED_REFS + #define CYTHON_AVOID_BORROWED_REFS 0 + #endif + #ifndef CYTHON_ASSUME_SAFE_MACROS + #define CYTHON_ASSUME_SAFE_MACROS 1 + #endif + #ifndef CYTHON_UNPACK_METHODS + #define CYTHON_UNPACK_METHODS 1 + #endif + #ifndef CYTHON_FAST_THREAD_STATE + #define CYTHON_FAST_THREAD_STATE 1 + #endif + #ifndef CYTHON_FAST_PYCALL + #define CYTHON_FAST_PYCALL 1 + #endif + #ifndef CYTHON_PEP489_MULTI_PHASE_INIT + #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) + #endif + #ifndef CYTHON_USE_TP_FINALIZE + #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) + #endif #endif -#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000 - #define CYTHON_USE_PYLONG_INTERNALS 1 +#if !defined(CYTHON_FAST_PYCCALL) +#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) #endif #if CYTHON_USE_PYLONG_INTERNALS #include "longintrepr.h" @@ -75,6 +239,117 @@ END: Cython Metadata */ #undef BASE #undef MASK #endif +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif +#ifndef __has_cpp_attribute + #define __has_cpp_attribute(x) 0 +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +#ifndef CYTHON_MAYBE_UNUSED_VAR +# if defined(__cplusplus) + template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } +# else +# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) +# endif +#endif +#ifndef CYTHON_NCP_UNUSED +# if CYTHON_COMPILING_IN_CPYTHON +# define CYTHON_NCP_UNUSED +# else +# define CYTHON_NCP_UNUSED CYTHON_UNUSED +# endif +#endif +#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) +#ifdef _MSC_VER + #ifndef _MSC_STDINT_H_ + #if _MSC_VER < 1300 + typedef unsigned char uint8_t; + typedef unsigned int uint32_t; + #else + typedef unsigned __int8 uint8_t; + typedef unsigned __int32 uint32_t; + #endif + #endif +#else + #include +#endif +#ifndef CYTHON_FALLTHROUGH + #if defined(__cplusplus) && __cplusplus >= 201103L + #if __has_cpp_attribute(fallthrough) + #define CYTHON_FALLTHROUGH [[fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) + #define CYTHON_FALLTHROUGH [[clang::fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) + #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] + #endif + #endif + #ifndef CYTHON_FALLTHROUGH + #if __has_attribute(fallthrough) + #define CYTHON_FALLTHROUGH __attribute__((fallthrough)) + #else + #define CYTHON_FALLTHROUGH + #endif + #endif + #if defined(__clang__ ) && defined(__apple_build_version__) + #if __apple_build_version__ < 7000000 + #undef CYTHON_FALLTHROUGH + #define CYTHON_FALLTHROUGH + #endif + #endif +#endif + +#ifndef __cplusplus + #error "Cython files generated with the C++ option must be compiled with a C++ compiler." +#endif +#ifndef CYTHON_INLINE + #if defined(__clang__) + #define CYTHON_INLINE __inline__ __attribute__ ((__unused__)) + #else + #define CYTHON_INLINE inline + #endif +#endif +template +void __Pyx_call_destructor(T& x) { + x.~T(); +} +template +class __Pyx_FakeReference { + public: + __Pyx_FakeReference() : ptr(NULL) { } + __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } + T *operator->() { return ptr; } + T *operator&() { return ptr; } + operator T&() { return *ptr; } + template bool operator ==(U other) { return *ptr == other; } + template bool operator !=(U other) { return *ptr != other; } + private: + T *ptr; +}; + #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) #define Py_OptimizeFlag 0 #endif @@ -103,24 +378,116 @@ END: Cython Metadata */ #ifndef Py_TPFLAGS_HAVE_FINALIZE #define Py_TPFLAGS_HAVE_FINALIZE 0 #endif +#if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL) + #ifndef METH_FASTCALL + #define METH_FASTCALL 0x80 + #endif + typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs); + typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args, + Py_ssize_t nargs, PyObject *kwnames); +#else + #define __Pyx_PyCFunctionFast _PyCFunctionFast + #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords +#endif +#if CYTHON_FAST_PYCCALL +#define __Pyx_PyFastCFunction_Check(func)\ + ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) +#else +#define __Pyx_PyFastCFunction_Check(func) 0 +#endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) + #define PyObject_Malloc(s) PyMem_Malloc(s) + #define PyObject_Free(p) PyMem_Free(p) + #define PyObject_Realloc(p) PyMem_Realloc(p) +#endif +#if CYTHON_COMPILING_IN_PYSTON + #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno) +#else + #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0) + #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno) +#endif +#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#elif PY_VERSION_HEX >= 0x03060000 + #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() +#elif PY_VERSION_HEX >= 0x03000000 + #define __Pyx_PyThreadState_Current PyThreadState_GET() +#else + #define __Pyx_PyThreadState_Current _PyThreadState_Current +#endif +#if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT) +#include "pythread.h" +#define Py_tss_NEEDS_INIT 0 +typedef int Py_tss_t; +static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) { + *key = PyThread_create_key(); + return 0; // PyThread_create_key reports success always +} +static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) { + Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t)); + *key = Py_tss_NEEDS_INIT; + return key; +} +static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) { + PyObject_Free(key); +} +static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) { + return *key != Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) { + PyThread_delete_key(*key); + *key = Py_tss_NEEDS_INIT; +} +static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) { + return PyThread_set_key_value(*key, value); +} +static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) { + return PyThread_get_key_value(*key); +} +#endif // TSS (Thread Specific Storage) API +#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized) +#define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n)) +#else +#define __Pyx_PyDict_NewPresized(n) PyDict_New() +#endif +#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS +#define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash) +#else +#define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name) +#endif #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ 0 : _PyUnicode_Ready((PyObject *)(op))) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u) #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) #else #define CYTHON_PEP393_ENABLED 0 + #define PyUnicode_1BYTE_KIND 1 + #define PyUnicode_2BYTE_KIND 2 + #define PyUnicode_4BYTE_KIND 4 #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) + #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) #endif #if CYTHON_COMPILING_IN_PYPY @@ -134,14 +501,12 @@ END: Cython Metadata */ #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains) #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) #endif +#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) + #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) +#endif #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) #endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc) - #define PyObject_Malloc(s) PyMem_Malloc(s) - #define PyObject_Free(p) PyMem_Free(p) - #define PyObject_Realloc(p) PyMem_Realloc(p) -#endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) #if PY_MAJOR_VERSION >= 3 @@ -158,6 +523,7 @@ END: Cython Metadata */ #define PyString_Type PyUnicode_Type #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact + #define PyObject_Unicode PyObject_Str #endif #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) @@ -169,7 +535,11 @@ END: Cython Metadata */ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif -#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#if CYTHON_ASSUME_SAFE_MACROS + #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq) +#else + #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq) +#endif #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type @@ -204,56 +574,27 @@ END: Cython Metadata */ #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func)) #else #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) #endif -#if PY_VERSION_HEX >= 0x030500B1 -#define __Pyx_PyAsyncMethodsStruct PyAsyncMethods -#define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) -#elif CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 -typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; -} __Pyx_PyAsyncMethodsStruct; -#define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) -#else -#define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef CYTHON_RESTRICT - #if defined(__GNUC__) - #define CYTHON_RESTRICT __restrict__ - #elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define CYTHON_RESTRICT __restrict - #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - #define CYTHON_RESTRICT restrict +#if CYTHON_USE_ASYNC_SLOTS + #if PY_VERSION_HEX >= 0x030500B1 + #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods + #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) #else - #define CYTHON_RESTRICT + #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) #endif +#else + #define __Pyx_PyType_AsAsync(obj) NULL #endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) - -#ifndef __cplusplus - #error "Cython files generated with the C++ option must be compiled with a C++ compiler." -#endif -#ifndef CYTHON_INLINE - #define CYTHON_INLINE inline +#ifndef __Pyx_PyAsyncMethodsStruct + typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; + } __Pyx_PyAsyncMethodsStruct; #endif -template -void __Pyx_call_destructor(T& x) { - x.~T(); -} -template -class __Pyx_FakeReference { - public: - __Pyx_FakeReference() : ptr(NULL) { } - __Pyx_FakeReference(const T& ref) : ptr(const_cast(&ref)) { } - T *operator->() { return ptr; } - operator T&() { return *ptr; } - private: - T *ptr; -}; #if defined(WIN32) || defined(MS_WINDOWS) #define _USE_MATH_DEFINES @@ -268,6 +609,11 @@ static CYTHON_INLINE float __PYX_NAN() { return value; } #endif +#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) +#define __Pyx_truncl trunc +#else +#define __Pyx_truncl truncl +#endif #define __PYX_ERR(f_index, lineno, Ln_error) \ @@ -275,14 +621,6 @@ static CYTHON_INLINE float __PYX_NAN() { __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ } -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif - #ifndef __PYX_EXTERN_C #ifdef __cplusplus #define __PYX_EXTERN_C extern "C" @@ -291,44 +629,25 @@ static CYTHON_INLINE float __PYX_NAN() { #endif #endif -#define __PYX_HAVE__urlparse4__cgurl -#define __PYX_HAVE_API__urlparse4__cgurl +#define __PYX_HAVE__cgurl +#define __PYX_HAVE_API__cgurl +/* Early includes */ #include "../vendor/gurl/url/third_party/mozilla/url_parse.h" -#include "string.h" -#include +#include #include "ios" #include "new" #include "stdexcept" #include "typeinfo" +#include #include "../vendor/gurl/url/gurl.h" #ifdef _OPENMP #include #endif /* _OPENMP */ -#ifdef PYREX_WITHOUT_ASSERTIONS +#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) #define CYTHON_WITHOUT_ASSERTIONS #endif -#ifndef CYTHON_UNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) -# define CYTHON_UNUSED __attribute__ ((__unused__)) -# else -# define CYTHON_UNUSED -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; @@ -356,8 +675,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #define __Pyx_sst_abs(value) abs(value) #elif SIZEOF_LONG >= SIZEOF_SIZE_T #define __Pyx_sst_abs(value) labs(value) -#elif defined (_MSC_VER) && defined (_M_X64) - #define __Pyx_sst_abs(value) _abs64(value) +#elif defined (_MSC_VER) + #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value)) #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __Pyx_sst_abs(value) llabs(value) #elif defined (__GNUC__) @@ -365,8 +684,8 @@ typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* enc #else #define __Pyx_sst_abs(value) ((value<0) ? -value : value) #endif -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) #define __Pyx_PyBytes_FromString PyBytes_FromString @@ -379,34 +698,40 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize #endif -#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s)) +#define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -#if PY_MAJOR_VERSION < 3 -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) -{ +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { const Py_UNICODE *u_end = u; while (*u_end++) ; return (size_t)(u_end - u - 1); } -#else -#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen -#endif #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b); static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x); +#define __Pyx_PySequence_Tuple(obj)\ + (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj)) static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_ASSUME_SAFE_MACROS #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) #else #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) @@ -502,10 +827,12 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { #define likely(x) (x) #define unlikely(x) (x) #endif /* __GNUC__ */ +static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } -static PyObject *__pyx_m; +static PyObject *__pyx_m = NULL; static PyObject *__pyx_d; static PyObject *__pyx_b; +static PyObject *__pyx_cython_runtime = NULL; static PyObject *__pyx_empty_tuple; static PyObject *__pyx_empty_bytes; static PyObject *__pyx_empty_unicode; @@ -521,16 +848,16 @@ static const char *__pyx_f[] = { }; /*--- Type declarations ---*/ -struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__; +struct __pyx_obj_5cgurl___pyx_scope_struct____new__; -/* "urlparse4/cgurl.pyx":111 +/* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< * * cdef Parsed parsed */ -struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ { +struct __pyx_obj_5cgurl___pyx_scope_struct____new__ { PyObject_HEAD struct url::Parsed __pyx_v_parsed; PyObject *__pyx_v_url; @@ -602,17 +929,8 @@ struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ { #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) /* PyObjectGetAttrStr.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_getattro)) - return tp->tp_getattro(obj, attr_name); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name); #else #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) #endif @@ -621,25 +939,37 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject static PyObject *__Pyx_GetBuiltinName(PyObject *name); /* PyThreadStateGet.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = PyThreadState_GET(); +#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; +#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type #else #define __Pyx_PyThreadState_declare #define __Pyx_PyThreadState_assign +#define __Pyx_PyErr_Occurred() PyErr_Occurred() #endif /* PyErrFetchRestore.proto */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE +#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL) #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb) #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb) #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb) static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb); +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL)) #else +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) +#endif +#else +#define __Pyx_PyErr_Clear() PyErr_Clear() +#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc) #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb) +#define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb) +#define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb) #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb) #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb) #endif @@ -660,8 +990,10 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ const char* function_name); /* ArgTypeTest.proto */ -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact); +#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ + ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ + __Pyx__ArgTypeTest(obj, type, name, exact)) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); /* IncludeStringH.proto */ #include @@ -697,13 +1029,31 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_ (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int wraparound, int boundscheck); -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, int wraparound, int boundscheck); /* None.proto */ static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname); +/* PyCFunctionFastCall.proto */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); +#else +#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) +#endif + +/* PyFunctionFastCall.proto */ +#if CYTHON_FAST_PYCALL +#define __Pyx_PyFunction_FastCall(func, args, nargs)\ + __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); +#else +#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) +#endif +#endif + /* PyObjectCall.proto */ #if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); @@ -731,7 +1081,6 @@ static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type); /* CythonFunction.proto */ #define __Pyx_CyFunction_USED 1 -#include #define __Pyx_CYFUNCTION_STATICMETHOD 0x01 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02 #define __Pyx_CYFUNCTION_CCLASS 0x04 @@ -784,18 +1133,9 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m, static int __pyx_CyFunction_init(void); /* PyObjectSetAttrStr.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL) -static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { - PyTypeObject* tp = Py_TYPE(obj); - if (likely(tp->tp_setattro)) - return tp->tp_setattro(obj, attr_name, value); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_setattr)) - return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); -#endif - return PyObject_SetAttr(obj, attr_name, value); -} +#if CYTHON_USE_TYPE_SLOTS +#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL) +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value); #else #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) @@ -804,18 +1144,76 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr /* GetModuleGlobalName.proto */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); +/* decode_c_string_utf16.proto */ +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 0; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = -1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} +static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) { + int byteorder = 1; + return PyUnicode_DecodeUTF16(s, size, errors, &byteorder); +} + +/* decode_c_bytes.proto */ +static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( + const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)); + +/* decode_bytes.proto */ +static CYTHON_INLINE PyObject* __Pyx_decode_bytes( + PyObject* string, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + return __Pyx_decode_c_bytes( + PyBytes_AS_STRING(string), PyBytes_GET_SIZE(string), + start, stop, encoding, errors, decode_func); +} + +/* PyObject_GenericGetAttrNoDict.proto */ +#if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name); +#else +#define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr +#endif + /* Import.proto */ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); +/* ImportFrom.proto */ +static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); + /* CalculateMetaclass.proto */ static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases); +/* SetNameInClass.proto */ +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 +#define __Pyx_SetNameInClass(ns, name, value)\ + (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value)) +#elif CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_SetNameInClass(ns, name, value)\ + (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value)) +#else +#define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value) +#endif + /* Py3ClassCreate.proto */ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc); static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict, PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); +/* CLineInTraceback.proto */ +#ifdef CYTHON_CLINE_IN_TRACEBACK +#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) +#else +static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); +#endif + /* CodeObjectCache.proto */ typedef struct { PyCodeObject* code_object; @@ -844,6 +1242,19 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); /* CIntFromPy.proto */ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); +/* FastTypeChecks.proto */ +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type); +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2); +#else +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) +#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) +#endif +#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) + /* CheckBinaryVersion.proto */ static int __Pyx_check_binary_version(void); @@ -863,25 +1274,30 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /* Module declarations from 'cython' */ -/* Module declarations from 'urlparse4.cgurl' */ -static PyTypeObject *__pyx_ptype_9urlparse4_5cgurl___pyx_scope_struct____new__ = 0; -static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *, struct url::Component); /*proto*/ -static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *, struct url::Parsed); /*proto*/ +/* Module declarations from 'cgurl' */ +static PyTypeObject *__pyx_ptype_5cgurl___pyx_scope_struct____new__ = 0; +static PyObject *__pyx_f_5cgurl_slice_component(PyObject *, struct url::Component); /*proto*/ +static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *, struct url::Parsed); /*proto*/ static std::string __pyx_convert_string_from_py_std__in_string(PyObject *); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string(std::string const &); /*proto*/ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_string(std::string const &); /*proto*/ -#define __Pyx_MODULE_NAME "urlparse4.cgurl" -int __pyx_module_is_main_urlparse4__cgurl = 0; +#define __Pyx_MODULE_NAME "cgurl" +extern int __pyx_module_is_main_cgurl; +int __pyx_module_is_main_cgurl = 0; -/* Implementation of 'urlparse4.cgurl' */ +/* Implementation of 'cgurl' */ static PyObject *__pyx_builtin_ValueError; static const char __pyx_k_[] = ""; +static const char __pyx_k_PY2[] = "PY2"; static const char __pyx_k_cls[] = "cls"; static const char __pyx_k_doc[] = "__doc__"; static const char __pyx_k_new[] = "__new__"; +static const char __pyx_k_ref[] = "ref"; +static const char __pyx_k_six[] = "six"; +static const char __pyx_k_str[] = "str"; static const char __pyx_k_url[] = "url"; static const char __pyx_k_base[] = "base"; static const char __pyx_k_file[] = "file:"; @@ -891,9 +1307,12 @@ static const char __pyx_k_port[] = "port"; static const char __pyx_k_prop[] = "prop"; static const char __pyx_k_self[] = "self"; static const char __pyx_k_test[] = "__test__"; +static const char __pyx_k_cgurl[] = "cgurl"; static const char __pyx_k_lower[] = "lower"; static const char __pyx_k_query[] = "query"; static const char __pyx_k_slots[] = "__slots__"; +static const char __pyx_k_utf_8[] = "utf-8"; +static const char __pyx_k_decode[] = "decode"; static const char __pyx_k_geturl[] = "geturl"; static const char __pyx_k_import[] = "__import__"; static const char __pyx_k_module[] = "__module__"; @@ -908,21 +1327,25 @@ static const char __pyx_k_get_attr[] = "_get_attr"; static const char __pyx_k_hostname[] = "hostname"; static const char __pyx_k_password[] = "password"; static const char __pyx_k_qualname[] = "__qualname__"; -static const char __pyx_k_urlparse[] = "urlparse"; static const char __pyx_k_urlsplit[] = "urlsplit"; static const char __pyx_k_username[] = "username"; +static const char __pyx_k_bytes_str[] = "bytes_str"; static const char __pyx_k_metaclass[] = "__metaclass__"; static const char __pyx_k_ValueError[] = "ValueError"; static const char __pyx_k_urlunsplit[] = "urlunsplit"; +static const char __pyx_k_stdlib_urljoin[] = "stdlib_urljoin"; static const char __pyx_k_allow_fragments[] = "allow_fragments"; -static const char __pyx_k_stdlib_urlparse[] = "stdlib_urlparse"; -static const char __pyx_k_urlparse4_cgurl[] = "urlparse4.cgurl"; +static const char __pyx_k_unicode_handling[] = "unicode_handling"; +static const char __pyx_k_stdlib_urlunsplit[] = "stdlib_urlunsplit"; +static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; +static const char __pyx_k_urlparse4_cgurl_pyx[] = "urlparse4/cgurl.pyx"; static const char __pyx_k_SplitResultNamedTuple[] = "SplitResultNamedTuple"; +static const char __pyx_k_six_moves_urllib_parse[] = "six.moves.urllib.parse"; static const char __pyx_k_SplitResultNamedTuple___new[] = "SplitResultNamedTuple.__new__"; static const char __pyx_k_SplitResultNamedTuple_geturl[] = "SplitResultNamedTuple.geturl"; -static const char __pyx_k_cosr_urlparse4_urlparse4_cgurl[] = "/cosr/urlparse4/urlparse4/cgurl.pyx"; static const char __pyx_k_SplitResultNamedTuple___new___lo[] = "SplitResultNamedTuple.__new__.._get_attr"; static PyObject *__pyx_kp_b_; +static PyObject *__pyx_n_s_PY2; static PyObject *__pyx_n_s_SplitResultNamedTuple; static PyObject *__pyx_n_s_SplitResultNamedTuple___new; static PyObject *__pyx_n_s_SplitResultNamedTuple___new___lo; @@ -930,8 +1353,11 @@ static PyObject *__pyx_n_s_SplitResultNamedTuple_geturl; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_allow_fragments; static PyObject *__pyx_n_s_base; +static PyObject *__pyx_n_s_bytes_str; +static PyObject *__pyx_n_s_cgurl; +static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_cls; -static PyObject *__pyx_kp_s_cosr_urlparse4_urlparse4_cgurl; +static PyObject *__pyx_n_s_decode; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_kp_b_file; static PyObject *__pyx_n_s_fragment; @@ -954,52 +1380,63 @@ static PyObject *__pyx_n_s_prepare; static PyObject *__pyx_n_s_prop; static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_n_s_query; +static PyObject *__pyx_n_s_ref; static PyObject *__pyx_n_s_scheme; static PyObject *__pyx_n_s_self; +static PyObject *__pyx_n_s_six; +static PyObject *__pyx_n_s_six_moves_urllib_parse; static PyObject *__pyx_n_s_slots; -static PyObject *__pyx_n_s_stdlib_urlparse; +static PyObject *__pyx_n_s_stdlib_urljoin; +static PyObject *__pyx_n_s_stdlib_urlunsplit; +static PyObject *__pyx_n_s_str; static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_unicode_handling; static PyObject *__pyx_n_s_url; static PyObject *__pyx_n_s_urljoin; -static PyObject *__pyx_n_s_urlparse; -static PyObject *__pyx_n_s_urlparse4_cgurl; +static PyObject *__pyx_kp_s_urlparse4_cgurl_pyx; static PyObject *__pyx_n_s_urlsplit; static PyObject *__pyx_n_s_urlunsplit; static PyObject *__pyx_n_s_username; -static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_prop); /* proto */ -static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_url); /* proto */ -static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_9urlparse4_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url); /* proto */ -static PyObject *__pyx_pf_9urlparse4_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_base, PyObject *__pyx_v_url, PyObject *__pyx_v_allow_fragments); /* proto */ -static PyObject *__pyx_tp_new_9urlparse4_5cgurl___pyx_scope_struct____new__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_kp_s_utf_8; +static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_prop); /* proto */ +static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_url); /* proto */ +static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5cgurl_unicode_handling(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_str); /* proto */ +static PyObject *__pyx_pf_5cgurl_2urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url); /* proto */ +static PyObject *__pyx_pf_5cgurl_4urljoin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_base, PyObject *__pyx_v_url, PyObject *__pyx_v_allow_fragments); /* proto */ +static PyObject *__pyx_tp_new_5cgurl___pyx_scope_struct____new__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_65535; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__4; -static PyObject *__pyx_tuple__6; -static PyObject *__pyx_tuple__8; -static PyObject *__pyx_tuple__10; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__9; +static PyObject *__pyx_tuple__11; +static PyObject *__pyx_tuple__13; static PyObject *__pyx_codeobj__3; -static PyObject *__pyx_codeobj__5; -static PyObject *__pyx_codeobj__7; -static PyObject *__pyx_codeobj__9; -static PyObject *__pyx_codeobj__11; +static PyObject *__pyx_codeobj__6; +static PyObject *__pyx_codeobj__8; +static PyObject *__pyx_codeobj__10; +static PyObject *__pyx_codeobj__12; +static PyObject *__pyx_codeobj__14; +/* Late includes */ -/* "urlparse4/cgurl.pyx":6 - * cimport cython +/* "cgurl.pyx":11 + * * * cdef bytes slice_component(bytes pyurl, Component comp): # <<<<<<<<<<<<<< * if comp.len <= 0: * return b"" */ -static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct url::Component __pyx_v_comp) { +static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct url::Component __pyx_v_comp) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("slice_component", 0); - /* "urlparse4/cgurl.pyx":7 + /* "cgurl.pyx":12 * * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1009,7 +1446,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyu __pyx_t_1 = ((__pyx_v_comp.len <= 0) != 0); if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":8 + /* "cgurl.pyx":13 * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1021,7 +1458,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyu __pyx_r = __pyx_kp_b_; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":7 + /* "cgurl.pyx":12 * * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1030,7 +1467,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyu */ } - /* "urlparse4/cgurl.pyx":10 + /* "cgurl.pyx":15 * return b"" * * return pyurl[comp.begin:comp.begin + comp.len] # <<<<<<<<<<<<<< @@ -1040,16 +1477,16 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyu __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_pyurl == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 10, __pyx_L1_error) + __PYX_ERR(0, 15, __pyx_L1_error) } - __pyx_t_2 = PySequence_GetSlice(__pyx_v_pyurl, __pyx_v_comp.begin, (__pyx_v_comp.begin + __pyx_v_comp.len)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error) + __pyx_t_2 = PySequence_GetSlice(__pyx_v_pyurl, __pyx_v_comp.begin, (__pyx_v_comp.begin + __pyx_v_comp.len)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":6 - * cimport cython + /* "cgurl.pyx":11 + * * * cdef bytes slice_component(bytes pyurl, Component comp): # <<<<<<<<<<<<<< * if comp.len <= 0: @@ -1059,7 +1496,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyu /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("urlparse4.cgurl.slice_component", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.slice_component", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1067,7 +1504,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyu return __pyx_r; } -/* "urlparse4/cgurl.pyx":13 +/* "cgurl.pyx":18 * * * cdef bytes cslice_component(char * url, Component comp): # <<<<<<<<<<<<<< @@ -1075,14 +1512,14 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyu * return b"" */ -static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, struct url::Component __pyx_v_comp) { +static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url::Component __pyx_v_comp) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("cslice_component", 0); - /* "urlparse4/cgurl.pyx":14 + /* "cgurl.pyx":19 * * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1092,7 +1529,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, s __pyx_t_1 = ((__pyx_v_comp.len <= 0) != 0); if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":15 + /* "cgurl.pyx":20 * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1104,7 +1541,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, s __pyx_r = __pyx_kp_b_; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":14 + /* "cgurl.pyx":19 * * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1113,7 +1550,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":18 + /* "cgurl.pyx":23 * * # TODO: check if std::string brings any speedups * return url[comp.begin:comp.begin + comp.len] # <<<<<<<<<<<<<< @@ -1121,13 +1558,13 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, s * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_url + __pyx_v_comp.begin, (__pyx_v_comp.begin + __pyx_v_comp.len) - __pyx_v_comp.begin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_url + __pyx_v_comp.begin, (__pyx_v_comp.begin + __pyx_v_comp.len) - __pyx_v_comp.begin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":13 + /* "cgurl.pyx":18 * * * cdef bytes cslice_component(char * url, Component comp): # <<<<<<<<<<<<<< @@ -1138,7 +1575,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, s /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("urlparse4.cgurl.cslice_component", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.cslice_component", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1146,7 +1583,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, s return __pyx_r; } -/* "urlparse4/cgurl.pyx":21 +/* "cgurl.pyx":26 * * * cdef bytes build_netloc(bytes url, Parsed parsed): # <<<<<<<<<<<<<< @@ -1154,7 +1591,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, s * if parsed.host.len <= 0: */ -static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url::Parsed __pyx_v_parsed) { +static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url::Parsed __pyx_v_parsed) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -1162,7 +1599,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("build_netloc", 0); - /* "urlparse4/cgurl.pyx":23 + /* "cgurl.pyx":28 * cdef bytes build_netloc(bytes url, Parsed parsed): * * if parsed.host.len <= 0: # <<<<<<<<<<<<<< @@ -1172,7 +1609,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __pyx_t_1 = ((__pyx_v_parsed.host.len <= 0) != 0); if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":24 + /* "cgurl.pyx":29 * * if parsed.host.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1184,7 +1621,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __pyx_r = __pyx_kp_b_; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":23 + /* "cgurl.pyx":28 * cdef bytes build_netloc(bytes url, Parsed parsed): * * if parsed.host.len <= 0: # <<<<<<<<<<<<<< @@ -1193,7 +1630,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":27 + /* "cgurl.pyx":32 * * # Nothing at all * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1217,7 +1654,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":28 + /* "cgurl.pyx":33 * # Nothing at all * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len <= 0: * return url[parsed.host.begin: parsed.host.begin + parsed.host.len] # <<<<<<<<<<<<<< @@ -1227,15 +1664,15 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 28, __pyx_L1_error) + __PYX_ERR(0, 33, __pyx_L1_error) } - __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.host.begin, (__pyx_v_parsed.host.begin + __pyx_v_parsed.host.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error) + __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.host.begin, (__pyx_v_parsed.host.begin + __pyx_v_parsed.host.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 33, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":27 + /* "cgurl.pyx":32 * * # Nothing at all * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1244,7 +1681,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":31 + /* "cgurl.pyx":36 * * # Only port * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1268,7 +1705,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __pyx_L7_bool_binop_done:; if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":32 + /* "cgurl.pyx":37 * # Only port * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len > 0: * return url[parsed.host.begin: parsed.host.begin + parsed.host.len + 1 + parsed.port.len] # <<<<<<<<<<<<<< @@ -1278,15 +1715,15 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 32, __pyx_L1_error) + __PYX_ERR(0, 37, __pyx_L1_error) } - __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.host.begin, (((__pyx_v_parsed.host.begin + __pyx_v_parsed.host.len) + 1) + __pyx_v_parsed.port.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error) + __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.host.begin, (((__pyx_v_parsed.host.begin + __pyx_v_parsed.host.len) + 1) + __pyx_v_parsed.port.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":31 + /* "cgurl.pyx":36 * * # Only port * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1295,7 +1732,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":35 + /* "cgurl.pyx":40 * * # Only username * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1319,7 +1756,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __pyx_L10_bool_binop_done:; if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":36 + /* "cgurl.pyx":41 * # Only username * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len <= 0: * return url[parsed.username.begin: parsed.username.begin + parsed.host.len + 1 + parsed.username.len] # <<<<<<<<<<<<<< @@ -1329,15 +1766,15 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 36, __pyx_L1_error) + __PYX_ERR(0, 41, __pyx_L1_error) } - __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.username.begin, (((__pyx_v_parsed.username.begin + __pyx_v_parsed.host.len) + 1) + __pyx_v_parsed.username.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 36, __pyx_L1_error) + __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.username.begin, (((__pyx_v_parsed.username.begin + __pyx_v_parsed.host.len) + 1) + __pyx_v_parsed.username.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":35 + /* "cgurl.pyx":40 * * # Only username * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1346,7 +1783,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":39 + /* "cgurl.pyx":44 * * # Username + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1370,7 +1807,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __pyx_L13_bool_binop_done:; if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":40 + /* "cgurl.pyx":45 * # Username + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len <= 0: * return url[parsed.username.begin: parsed.username.begin + parsed.host.len + 2 + parsed.username.len + parsed.password.len] # <<<<<<<<<<<<<< @@ -1380,15 +1817,15 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 40, __pyx_L1_error) + __PYX_ERR(0, 45, __pyx_L1_error) } - __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.username.begin, ((((__pyx_v_parsed.username.begin + __pyx_v_parsed.host.len) + 2) + __pyx_v_parsed.username.len) + __pyx_v_parsed.password.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 40, __pyx_L1_error) + __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.username.begin, ((((__pyx_v_parsed.username.begin + __pyx_v_parsed.host.len) + 2) + __pyx_v_parsed.username.len) + __pyx_v_parsed.password.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":39 + /* "cgurl.pyx":44 * * # Username + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1397,7 +1834,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":43 + /* "cgurl.pyx":48 * * # Username + port * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1421,7 +1858,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __pyx_L16_bool_binop_done:; if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":44 + /* "cgurl.pyx":49 * # Username + port * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len > 0: * return url[parsed.username.begin: parsed.username.begin + parsed.host.len + 2 + parsed.username.len + parsed.port.len] # <<<<<<<<<<<<<< @@ -1431,15 +1868,15 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 44, __pyx_L1_error) + __PYX_ERR(0, 49, __pyx_L1_error) } - __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.username.begin, ((((__pyx_v_parsed.username.begin + __pyx_v_parsed.host.len) + 2) + __pyx_v_parsed.username.len) + __pyx_v_parsed.port.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) + __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.username.begin, ((((__pyx_v_parsed.username.begin + __pyx_v_parsed.host.len) + 2) + __pyx_v_parsed.username.len) + __pyx_v_parsed.port.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":43 + /* "cgurl.pyx":48 * * # Username + port * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1448,7 +1885,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":47 + /* "cgurl.pyx":52 * * # Username + port + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1470,9 +1907,9 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __pyx_t_2 = ((__pyx_v_parsed.port.len > 0) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; - if (__pyx_t_1) { + if (likely(__pyx_t_1)) { - /* "urlparse4/cgurl.pyx":48 + /* "cgurl.pyx":53 * # Username + port + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len > 0: * return url[parsed.username.begin: parsed.username.begin + parsed.host.len + 3 + parsed.port.len + parsed.username.len + parsed.password.len] # <<<<<<<<<<<<<< @@ -1482,15 +1919,15 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 48, __pyx_L1_error) + __PYX_ERR(0, 53, __pyx_L1_error) } - __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.username.begin, (((((__pyx_v_parsed.username.begin + __pyx_v_parsed.host.len) + 3) + __pyx_v_parsed.port.len) + __pyx_v_parsed.username.len) + __pyx_v_parsed.password.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error) + __pyx_t_3 = PySequence_GetSlice(__pyx_v_url, __pyx_v_parsed.username.begin, (((((__pyx_v_parsed.username.begin + __pyx_v_parsed.host.len) + 3) + __pyx_v_parsed.port.len) + __pyx_v_parsed.username.len) + __pyx_v_parsed.password.len)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":47 + /* "cgurl.pyx":52 * * # Username + port + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1499,7 +1936,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":51 + /* "cgurl.pyx":56 * * else: * raise ValueError # <<<<<<<<<<<<<< @@ -1508,10 +1945,10 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ /*else*/ { __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0); - __PYX_ERR(0, 51, __pyx_L1_error) + __PYX_ERR(0, 56, __pyx_L1_error) } - /* "urlparse4/cgurl.pyx":21 + /* "cgurl.pyx":26 * * * cdef bytes build_netloc(bytes url, Parsed parsed): # <<<<<<<<<<<<<< @@ -1522,7 +1959,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("urlparse4.cgurl.build_netloc", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.build_netloc", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -1530,7 +1967,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s return __pyx_r; } -/* "urlparse4/cgurl.pyx":111 +/* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -1539,9 +1976,9 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ /* Python wrapper */ -static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__ = {"__new__", (PyCFunction)__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_21SplitResultNamedTuple_1__new__ = {"__new__", (PyCFunction)__pyx_pw_5cgurl_21SplitResultNamedTuple_1__new__, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_cls = 0; PyObject *__pyx_v_url = 0; PyObject *__pyx_r = 0; @@ -1555,23 +1992,26 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__(PyO const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--; + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_url)) != 0)) kw_args--; + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_url)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__new__", 1, 2, 2, 1); __PYX_ERR(0, 111, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__new__", 1, 2, 2, 1); __PYX_ERR(0, 116, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(0, 111, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) __PYX_ERR(0, 116, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -1584,14 +2024,14 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__(PyO } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__new__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 111, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("__new__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 116, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("urlparse4.cgurl.SplitResultNamedTuple.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.SplitResultNamedTuple.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 111, __pyx_L1_error) - __pyx_r = __pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(__pyx_self, __pyx_v_cls, __pyx_v_url); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 116, __pyx_L1_error) + __pyx_r = __pyx_pf_5cgurl_21SplitResultNamedTuple___new__(__pyx_self, __pyx_v_cls, __pyx_v_url); /* function exit code */ goto __pyx_L0; @@ -1602,7 +2042,7 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__(PyO return __pyx_r; } -/* "urlparse4/cgurl.pyx":120 +/* "cgurl.pyx":125 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< @@ -1611,9 +2051,9 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__(PyO */ /* Python wrapper */ -static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr = {"_get_attr", (PyCFunction)__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr = {"_get_attr", (PyCFunction)__pyx_pw_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_prop = 0; PyObject *__pyx_r = 0; @@ -1627,23 +2067,26 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new___1_g const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_prop)) != 0)) kw_args--; + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_prop)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_get_attr", 1, 2, 2, 1); __PYX_ERR(0, 120, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_get_attr", 1, 2, 2, 1); __PYX_ERR(0, 125, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_attr") < 0)) __PYX_ERR(0, 120, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_get_attr") < 0)) __PYX_ERR(0, 125, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -1656,22 +2099,22 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new___1_g } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_get_attr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 120, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("_get_attr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 125, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("urlparse4.cgurl.SplitResultNamedTuple.__new__._get_attr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.SplitResultNamedTuple.__new__._get_attr", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____get_attr(__pyx_self, __pyx_v_self, __pyx_v_prop); + __pyx_r = __pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(__pyx_self, __pyx_v_self, __pyx_v_prop); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_prop) { - struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ *__pyx_cur_scope; - struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ *__pyx_outer_scope; +static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_prop) { + struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *__pyx_cur_scope; + struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *__pyx_outer_scope; PyObject *__pyx_v_port = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -1680,20 +2123,20 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("_get_attr", 0); - __pyx_outer_scope = (struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ *) __Pyx_CyFunction_GetClosure(__pyx_self); + __pyx_outer_scope = (struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; - /* "urlparse4/cgurl.pyx":121 + /* "cgurl.pyx":126 * * def _get_attr(self, prop): * if prop == "scheme": # <<<<<<<<<<<<<< * return self[0] * elif prop == "netloc": */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_scheme, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 121, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_scheme, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 126, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":122 + /* "cgurl.pyx":127 * def _get_attr(self, prop): * if prop == "scheme": * return self[0] # <<<<<<<<<<<<<< @@ -1701,13 +2144,13 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge * return self[1] */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":121 + /* "cgurl.pyx":126 * * def _get_attr(self, prop): * if prop == "scheme": # <<<<<<<<<<<<<< @@ -1716,17 +2159,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":123 + /* "cgurl.pyx":128 * if prop == "scheme": * return self[0] * elif prop == "netloc": # <<<<<<<<<<<<<< * return self[1] * elif prop == "path": */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_netloc, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 123, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_netloc, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 128, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":124 + /* "cgurl.pyx":129 * return self[0] * elif prop == "netloc": * return self[1] # <<<<<<<<<<<<<< @@ -1734,13 +2177,13 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge * return self[2] */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":123 + /* "cgurl.pyx":128 * if prop == "scheme": * return self[0] * elif prop == "netloc": # <<<<<<<<<<<<<< @@ -1749,17 +2192,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":125 + /* "cgurl.pyx":130 * elif prop == "netloc": * return self[1] * elif prop == "path": # <<<<<<<<<<<<<< * return self[2] * elif prop == "query": */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_path, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 125, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_path, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 130, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":126 + /* "cgurl.pyx":131 * return self[1] * elif prop == "path": * return self[2] # <<<<<<<<<<<<<< @@ -1767,13 +2210,13 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge * return self[3] */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":125 + /* "cgurl.pyx":130 * elif prop == "netloc": * return self[1] * elif prop == "path": # <<<<<<<<<<<<<< @@ -1782,17 +2225,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":127 + /* "cgurl.pyx":132 * elif prop == "path": * return self[2] * elif prop == "query": # <<<<<<<<<<<<<< * return self[3] * elif prop == "fragment": */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_query, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 127, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_query, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 132, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":128 + /* "cgurl.pyx":133 * return self[2] * elif prop == "query": * return self[3] # <<<<<<<<<<<<<< @@ -1800,13 +2243,13 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge * return self[4] */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":127 + /* "cgurl.pyx":132 * elif prop == "path": * return self[2] * elif prop == "query": # <<<<<<<<<<<<<< @@ -1815,17 +2258,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":129 + /* "cgurl.pyx":134 * elif prop == "query": * return self[3] * elif prop == "fragment": # <<<<<<<<<<<<<< * return self[4] * elif prop == "port": */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_fragment, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 129, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_fragment, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 134, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":130 + /* "cgurl.pyx":135 * return self[3] * elif prop == "fragment": * return self[4] # <<<<<<<<<<<<<< @@ -1833,13 +2276,13 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge * if parsed.port.len > 0: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_self, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":129 + /* "cgurl.pyx":134 * elif prop == "query": * return self[3] * elif prop == "fragment": # <<<<<<<<<<<<<< @@ -1848,17 +2291,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":131 + /* "cgurl.pyx":136 * elif prop == "fragment": * return self[4] * elif prop == "port": # <<<<<<<<<<<<<< * if parsed.port.len > 0: * port = int(slice_component(url, parsed.port)) */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_port, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 131, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_port, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 136, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":132 + /* "cgurl.pyx":137 * return self[4] * elif prop == "port": * if parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1868,38 +2311,38 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_parsed.port.len > 0) != 0); if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":133 + /* "cgurl.pyx":138 * elif prop == "port": * if parsed.port.len > 0: * port = int(slice_component(url, parsed.port)) # <<<<<<<<<<<<<< * if port <= 65535: * return port */ - if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 133, __pyx_L1_error) } + if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 138, __pyx_L1_error) } __pyx_t_2 = __pyx_cur_scope->__pyx_v_url; __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = __pyx_f_9urlparse4_5cgurl_slice_component(((PyObject*)__pyx_t_2), __pyx_cur_scope->__pyx_v_parsed.port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error) + __pyx_t_3 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_2), __pyx_cur_scope->__pyx_v_parsed.port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_port = __pyx_t_2; __pyx_t_2 = 0; - /* "urlparse4/cgurl.pyx":134 + /* "cgurl.pyx":139 * if parsed.port.len > 0: * port = int(slice_component(url, parsed.port)) * if port <= 65535: # <<<<<<<<<<<<<< * return port * */ - __pyx_t_2 = PyObject_RichCompare(__pyx_v_port, __pyx_int_65535, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 134, __pyx_L1_error) + __pyx_t_2 = PyObject_RichCompare(__pyx_v_port, __pyx_int_65535, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 139, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 139, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":135 + /* "cgurl.pyx":140 * port = int(slice_component(url, parsed.port)) * if port <= 65535: * return port # <<<<<<<<<<<<<< @@ -1911,7 +2354,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge __pyx_r = __pyx_v_port; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":134 + /* "cgurl.pyx":139 * if parsed.port.len > 0: * port = int(slice_component(url, parsed.port)) * if port <= 65535: # <<<<<<<<<<<<<< @@ -1920,7 +2363,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":132 + /* "cgurl.pyx":137 * return self[4] * elif prop == "port": * if parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1929,7 +2372,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":131 + /* "cgurl.pyx":136 * elif prop == "fragment": * return self[4] * elif prop == "port": # <<<<<<<<<<<<<< @@ -1939,17 +2382,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge goto __pyx_L3; } - /* "urlparse4/cgurl.pyx":137 + /* "cgurl.pyx":142 * return port * * elif prop == "username": # <<<<<<<<<<<<<< * return slice_component(url, parsed.username) or None * elif prop == "password": */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_username, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 137, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_username, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 142, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":138 + /* "cgurl.pyx":143 * * elif prop == "username": * return slice_component(url, parsed.username) or None # <<<<<<<<<<<<<< @@ -1957,13 +2400,13 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge * return slice_component(url, parsed.password) or None */ __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 138, __pyx_L1_error) } + if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 143, __pyx_L1_error) } __pyx_t_3 = __pyx_cur_scope->__pyx_v_url; __Pyx_INCREF(__pyx_t_3); - __pyx_t_4 = __pyx_f_9urlparse4_5cgurl_slice_component(((PyObject*)__pyx_t_3), __pyx_cur_scope->__pyx_v_parsed.username); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_t_4 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_3), __pyx_cur_scope->__pyx_v_parsed.username); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 138, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 143, __pyx_L1_error) if (!__pyx_t_1) { __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { @@ -1979,7 +2422,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":137 + /* "cgurl.pyx":142 * return port * * elif prop == "username": # <<<<<<<<<<<<<< @@ -1988,17 +2431,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":139 + /* "cgurl.pyx":144 * elif prop == "username": * return slice_component(url, parsed.username) or None * elif prop == "password": # <<<<<<<<<<<<<< * return slice_component(url, parsed.password) or None * elif prop == "hostname": */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_password, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 139, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_password, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 144, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":140 + /* "cgurl.pyx":145 * return slice_component(url, parsed.username) or None * elif prop == "password": * return slice_component(url, parsed.password) or None # <<<<<<<<<<<<<< @@ -2006,13 +2449,13 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge * return slice_component(url, parsed.host).lower() */ __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 140, __pyx_L1_error) } + if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 145, __pyx_L1_error) } __pyx_t_4 = __pyx_cur_scope->__pyx_v_url; __Pyx_INCREF(__pyx_t_4); - __pyx_t_3 = __pyx_f_9urlparse4_5cgurl_slice_component(((PyObject*)__pyx_t_4), __pyx_cur_scope->__pyx_v_parsed.password); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error) + __pyx_t_3 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_4), __pyx_cur_scope->__pyx_v_parsed.password); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 145, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 140, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 145, __pyx_L1_error) if (!__pyx_t_1) { __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { @@ -2028,7 +2471,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":139 + /* "cgurl.pyx":144 * elif prop == "username": * return slice_component(url, parsed.username) or None * elif prop == "password": # <<<<<<<<<<<<<< @@ -2037,17 +2480,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":141 + /* "cgurl.pyx":146 * elif prop == "password": * return slice_component(url, parsed.password) or None * elif prop == "hostname": # <<<<<<<<<<<<<< * return slice_component(url, parsed.host).lower() * */ - __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_hostname, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 141, __pyx_L1_error) + __pyx_t_1 = (__Pyx_PyString_Equals(__pyx_v_prop, __pyx_n_s_hostname, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 146, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":142 + /* "cgurl.pyx":147 * return slice_component(url, parsed.password) or None * elif prop == "hostname": * return slice_component(url, parsed.host).lower() # <<<<<<<<<<<<<< @@ -2055,17 +2498,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge * */ __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 142, __pyx_L1_error) } + if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 147, __pyx_L1_error) } __pyx_t_3 = __pyx_cur_scope->__pyx_v_url; __Pyx_INCREF(__pyx_t_3); - __pyx_t_4 = __pyx_f_9urlparse4_5cgurl_slice_component(((PyObject*)__pyx_t_3), __pyx_cur_scope->__pyx_v_parsed.host); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_4 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_3), __pyx_cur_scope->__pyx_v_parsed.host); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_lower); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) { + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); @@ -2075,10 +2518,10 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge } } if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -2086,7 +2529,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":141 + /* "cgurl.pyx":146 * elif prop == "password": * return slice_component(url, parsed.password) or None * elif prop == "hostname": # <<<<<<<<<<<<<< @@ -2096,7 +2539,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge } __pyx_L3:; - /* "urlparse4/cgurl.pyx":120 + /* "cgurl.pyx":125 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< @@ -2111,7 +2554,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("urlparse4.cgurl.SplitResultNamedTuple.__new__._get_attr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.SplitResultNamedTuple.__new__._get_attr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_port); @@ -2120,7 +2563,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge return __pyx_r; } -/* "urlparse4/cgurl.pyx":111 +/* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -2128,9 +2571,14 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge * cdef Parsed parsed */ -static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_url) { - struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ *__pyx_cur_scope; +static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_url) { + struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *__pyx_cur_scope; PyObject *__pyx_v__get_attr = 0; + PyObject *__pyx_v_scheme = NULL; + PyObject *__pyx_v_netloc = NULL; + PyObject *__pyx_v_path = NULL; + PyObject *__pyx_v_query = NULL; + PyObject *__pyx_v_ref = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2146,18 +2594,21 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH PyObject *__pyx_t_11 = NULL; PyObject *__pyx_t_12 = NULL; PyObject *__pyx_t_13 = NULL; + int __pyx_t_14; __Pyx_RefNannySetupContext("__new__", 0); - __pyx_cur_scope = (struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ *)__pyx_tp_new_9urlparse4_5cgurl___pyx_scope_struct____new__(__pyx_ptype_9urlparse4_5cgurl___pyx_scope_struct____new__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *)__pyx_tp_new_5cgurl___pyx_scope_struct____new__(__pyx_ptype_5cgurl___pyx_scope_struct____new__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { - __Pyx_RefNannyFinishContext(); - return NULL; + __pyx_cur_scope = ((struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *)Py_None); + __Pyx_INCREF(Py_None); + __PYX_ERR(0, 116, __pyx_L1_error) + } else { + __Pyx_GOTREF(__pyx_cur_scope); } - __Pyx_GOTREF(__pyx_cur_scope); __pyx_cur_scope->__pyx_v_url = __pyx_v_url; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_url); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_url); - /* "urlparse4/cgurl.pyx":115 + /* "cgurl.pyx":120 * cdef Parsed parsed * * if url[0:5] == b"file:": # <<<<<<<<<<<<<< @@ -2166,34 +2617,38 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH */ if (unlikely(__pyx_cur_scope->__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 115, __pyx_L1_error) + __PYX_ERR(0, 120, __pyx_L1_error) } - __pyx_t_1 = PySequence_GetSlice(__pyx_cur_scope->__pyx_v_url, 0, 5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_1 = PySequence_GetSlice(__pyx_cur_scope->__pyx_v_url, 0, 5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_t_1, __pyx_kp_b_file, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 115, __pyx_L1_error) + __pyx_t_2 = (__Pyx_PyBytes_Equals(__pyx_t_1, __pyx_kp_b_file, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 120, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { - /* "urlparse4/cgurl.pyx":116 + /* "cgurl.pyx":121 * * if url[0:5] == b"file:": * ParseFileURL(url, len(url), &parsed) # <<<<<<<<<<<<<< * else: * ParseStandardURL(url, len(url), &parsed) */ - __pyx_t_4 = __Pyx_PyObject_AsString(__pyx_cur_scope->__pyx_v_url); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 116, __pyx_L1_error) + if (unlikely(__pyx_cur_scope->__pyx_v_url == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 121, __pyx_L1_error) + } + __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_cur_scope->__pyx_v_url); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 121, __pyx_L1_error) __pyx_t_1 = __pyx_cur_scope->__pyx_v_url; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 116, __pyx_L1_error) + __PYX_ERR(0, 121, __pyx_L1_error) } - __pyx_t_5 = PyBytes_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 116, __pyx_L1_error) + __pyx_t_5 = PyBytes_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; url::ParseFileURL(__pyx_t_4, __pyx_t_5, (&__pyx_cur_scope->__pyx_v_parsed)); - /* "urlparse4/cgurl.pyx":115 + /* "cgurl.pyx":120 * cdef Parsed parsed * * if url[0:5] == b"file:": # <<<<<<<<<<<<<< @@ -2203,7 +2658,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH goto __pyx_L3; } - /* "urlparse4/cgurl.pyx":118 + /* "cgurl.pyx":123 * ParseFileURL(url, len(url), &parsed) * else: * ParseStandardURL(url, len(url), &parsed) # <<<<<<<<<<<<<< @@ -2211,193 +2666,406 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH * def _get_attr(self, prop): */ /*else*/ { - __pyx_t_6 = __Pyx_PyObject_AsString(__pyx_cur_scope->__pyx_v_url); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 118, __pyx_L1_error) + if (unlikely(__pyx_cur_scope->__pyx_v_url == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 123, __pyx_L1_error) + } + __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_cur_scope->__pyx_v_url); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 123, __pyx_L1_error) __pyx_t_1 = __pyx_cur_scope->__pyx_v_url; __Pyx_INCREF(__pyx_t_1); if (unlikely(__pyx_t_1 == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 118, __pyx_L1_error) + __PYX_ERR(0, 123, __pyx_L1_error) } - __pyx_t_5 = PyBytes_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 118, __pyx_L1_error) + __pyx_t_5 = PyBytes_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; url::ParseStandardURL(__pyx_t_6, __pyx_t_5, (&__pyx_cur_scope->__pyx_v_parsed)); } __pyx_L3:; - /* "urlparse4/cgurl.pyx":120 + /* "cgurl.pyx":125 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< * if prop == "scheme": * return self[0] */ - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr, 0, __pyx_n_s_SplitResultNamedTuple___new___lo, ((PyObject*)__pyx_cur_scope), __pyx_n_s_urlparse4_cgurl, __pyx_d, ((PyObject *)__pyx_codeobj__3)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error) + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr, 0, __pyx_n_s_SplitResultNamedTuple___new___lo, ((PyObject*)__pyx_cur_scope), __pyx_n_s_cgurl, __pyx_d, ((PyObject *)__pyx_codeobj__3)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v__get_attr = __pyx_t_1; __pyx_t_1 = 0; - /* "urlparse4/cgurl.pyx":145 + /* "cgurl.pyx":150 * * * cls.__getattr__ = _get_attr # <<<<<<<<<<<<<< * - * return tuple.__new__(cls, ( + * scheme, netloc, path, query, ref = (slice_component(url, parsed.scheme).lower(), */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_cls, __pyx_n_s_getattr, __pyx_v__get_attr) < 0) __PYX_ERR(0, 145, __pyx_L1_error) + if (__Pyx_PyObject_SetAttrStr(__pyx_v_cls, __pyx_n_s_getattr, __pyx_v__get_attr) < 0) __PYX_ERR(0, 150, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":147 + /* "cgurl.pyx":152 * cls.__getattr__ = _get_attr * - * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< - * slice_component(url, parsed.scheme).lower(), - * build_netloc(url, parsed), + * scheme, netloc, path, query, ref = (slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< + * build_netloc(url, parsed), + * slice_component(url, parsed.path), */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 147, __pyx_L1_error) + __pyx_t_7 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_7); + __pyx_t_8 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_7), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_lower); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - - /* "urlparse4/cgurl.pyx":148 - * - * return tuple.__new__(cls, ( - * slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< - * build_netloc(url, parsed), - * slice_component(url, parsed.path), - */ - __pyx_t_9 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_9); - __pyx_t_10 = __pyx_f_9urlparse4_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_lower); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_9))) { - __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); - if (likely(__pyx_t_10)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); - __Pyx_INCREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); + __Pyx_DECREF_SET(__pyx_t_7, function); } } - if (__pyx_t_10) { - __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (__pyx_t_8) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } else { - __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 148, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) } + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "cgurl.pyx":153 + * + * scheme, netloc, path, query, ref = (slice_component(url, parsed.scheme).lower(), + * build_netloc(url, parsed), # <<<<<<<<<<<<<< + * slice_component(url, parsed.path), + * slice_component(url, parsed.query), + */ + __pyx_t_7 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_7); + __pyx_t_8 = __pyx_f_5cgurl_build_netloc(((PyObject*)__pyx_t_7), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "urlparse4/cgurl.pyx":149 - * return tuple.__new__(cls, ( - * slice_component(url, parsed.scheme).lower(), - * build_netloc(url, parsed), # <<<<<<<<<<<<<< - * slice_component(url, parsed.path), - * slice_component(url, parsed.query), - */ - __pyx_t_9 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_9); - __pyx_t_10 = __pyx_f_9urlparse4_5cgurl_build_netloc(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 149, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "cgurl.pyx":154 + * scheme, netloc, path, query, ref = (slice_component(url, parsed.scheme).lower(), + * build_netloc(url, parsed), + * slice_component(url, parsed.path), # <<<<<<<<<<<<<< + * slice_component(url, parsed.query), + * slice_component(url, parsed.ref)) + */ + __pyx_t_7 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_7); + __pyx_t_9 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_7), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "cgurl.pyx":155 + * build_netloc(url, parsed), + * slice_component(url, parsed.path), + * slice_component(url, parsed.query), # <<<<<<<<<<<<<< + * slice_component(url, parsed.ref)) + * if six.PY2: + */ + __pyx_t_7 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_7); + __pyx_t_10 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_7), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 155, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "urlparse4/cgurl.pyx":150 - * slice_component(url, parsed.scheme).lower(), - * build_netloc(url, parsed), - * slice_component(url, parsed.path), # <<<<<<<<<<<<<< - * slice_component(url, parsed.query), - * slice_component(url, parsed.ref) - */ - __pyx_t_9 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_9); - __pyx_t_11 = __pyx_f_9urlparse4_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 150, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "cgurl.pyx":156 + * slice_component(url, parsed.path), + * slice_component(url, parsed.query), + * slice_component(url, parsed.ref)) # <<<<<<<<<<<<<< + * if six.PY2: + * return tuple.__new__(cls, ( + */ + __pyx_t_7 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_7); + __pyx_t_11 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_7), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 156, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "urlparse4/cgurl.pyx":151 - * build_netloc(url, parsed), - * slice_component(url, parsed.path), - * slice_component(url, parsed.query), # <<<<<<<<<<<<<< - * slice_component(url, parsed.ref) - * )) - */ - __pyx_t_9 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_9); - __pyx_t_12 = __pyx_f_9urlparse4_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "urlparse4/cgurl.pyx":152 - * slice_component(url, parsed.path), - * slice_component(url, parsed.query), - * slice_component(url, parsed.ref) # <<<<<<<<<<<<<< - * )) - * - */ - __pyx_t_9 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_9); - __pyx_t_13 = __pyx_f_9urlparse4_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "urlparse4/cgurl.pyx":148 - * - * return tuple.__new__(cls, ( - * slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< - * build_netloc(url, parsed), - * slice_component(url, parsed.path), - */ - __pyx_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_11); - __Pyx_GIVEREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_12); - __Pyx_GIVEREF(__pyx_t_13); - PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_13); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_v_scheme = __pyx_t_1; + __pyx_t_1 = 0; + __pyx_v_netloc = ((PyObject*)__pyx_t_8); __pyx_t_8 = 0; + __pyx_v_path = ((PyObject*)__pyx_t_9); + __pyx_t_9 = 0; + __pyx_v_query = ((PyObject*)__pyx_t_10); __pyx_t_10 = 0; + __pyx_v_ref = ((PyObject*)__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_12 = 0; - __pyx_t_13 = 0; - __pyx_t_13 = NULL; - __pyx_t_5 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_13)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_13); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - __pyx_t_5 = 1; + + /* "cgurl.pyx":157 + * slice_component(url, parsed.query), + * slice_component(url, parsed.ref)) + * if six.PY2: # <<<<<<<<<<<<<< + * return tuple.__new__(cls, ( + * scheme.decode('utf-8'), + */ + __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_PY2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (__pyx_t_3) { + + /* "cgurl.pyx":158 + * slice_component(url, parsed.ref)) + * if six.PY2: + * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< + * scheme.decode('utf-8'), + * netloc.decode('utf-8'), + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + + /* "cgurl.pyx":159 + * if six.PY2: + * return tuple.__new__(cls, ( + * scheme.decode('utf-8'), # <<<<<<<<<<<<<< + * netloc.decode('utf-8'), + * path.decode('utf-8'), + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_scheme, __pyx_n_s_decode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "cgurl.pyx":160 + * return tuple.__new__(cls, ( + * scheme.decode('utf-8'), + * netloc.decode('utf-8'), # <<<<<<<<<<<<<< + * path.decode('utf-8'), + * query.decode('utf-8'), + */ + if (unlikely(__pyx_v_netloc == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode"); + __PYX_ERR(0, 160, __pyx_L1_error) + } + __pyx_t_9 = __Pyx_decode_bytes(__pyx_v_netloc, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 160, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + + /* "cgurl.pyx":161 + * scheme.decode('utf-8'), + * netloc.decode('utf-8'), + * path.decode('utf-8'), # <<<<<<<<<<<<<< + * query.decode('utf-8'), + * ref.decode('utf-8') + */ + if (unlikely(__pyx_v_path == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode"); + __PYX_ERR(0, 161, __pyx_L1_error) + } + __pyx_t_1 = __Pyx_decode_bytes(__pyx_v_path, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + + /* "cgurl.pyx":162 + * netloc.decode('utf-8'), + * path.decode('utf-8'), + * query.decode('utf-8'), # <<<<<<<<<<<<<< + * ref.decode('utf-8') + * )) + */ + if (unlikely(__pyx_v_query == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode"); + __PYX_ERR(0, 162, __pyx_L1_error) + } + __pyx_t_7 = __Pyx_decode_bytes(__pyx_v_query, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + + /* "cgurl.pyx":163 + * path.decode('utf-8'), + * query.decode('utf-8'), + * ref.decode('utf-8') # <<<<<<<<<<<<<< + * )) + * else: + */ + if (unlikely(__pyx_v_ref == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "decode"); + __PYX_ERR(0, 163, __pyx_L1_error) + } + __pyx_t_12 = __Pyx_decode_bytes(__pyx_v_ref, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + + /* "cgurl.pyx":159 + * if six.PY2: + * return tuple.__new__(cls, ( + * scheme.decode('utf-8'), # <<<<<<<<<<<<<< + * netloc.decode('utf-8'), + * path.decode('utf-8'), + */ + __pyx_t_13 = PyTuple_New(5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_INCREF(((PyObject*)__pyx_t_8)); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_8); + __Pyx_INCREF(((PyObject*)__pyx_t_9)); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_9); + __Pyx_INCREF(((PyObject*)__pyx_t_1)); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_1); + __Pyx_INCREF(((PyObject*)__pyx_t_7)); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_7); + __Pyx_INCREF(((PyObject*)__pyx_t_12)); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_t_12); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = NULL; + __pyx_t_14 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_14 = 1; + } } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_cls, __pyx_t_13}; + __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_cls, __pyx_t_13}; + __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + { + __pyx_t_7 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_12) { + __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_12); __pyx_t_12 = NULL; + } + __Pyx_INCREF(__pyx_v_cls); + __Pyx_GIVEREF(__pyx_v_cls); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_14, __pyx_v_cls); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_14, __pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_7, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_r = __pyx_t_10; + __pyx_t_10 = 0; + goto __pyx_L0; + + /* "cgurl.pyx":157 + * slice_component(url, parsed.query), + * slice_component(url, parsed.ref)) + * if six.PY2: # <<<<<<<<<<<<<< + * return tuple.__new__(cls, ( + * scheme.decode('utf-8'), + */ } - __pyx_t_12 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 147, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - if (__pyx_t_13) { - __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL; + + /* "cgurl.pyx":166 + * )) + * else: + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) # <<<<<<<<<<<<<< + * + * def geturl(self): + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_7 = PyTuple_New(5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(__pyx_v_scheme); + __Pyx_GIVEREF(__pyx_v_scheme); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_scheme); + __Pyx_INCREF(__pyx_v_netloc); + __Pyx_GIVEREF(__pyx_v_netloc); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_netloc); + __Pyx_INCREF(__pyx_v_path); + __Pyx_GIVEREF(__pyx_v_path); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_v_path); + __Pyx_INCREF(__pyx_v_query); + __Pyx_GIVEREF(__pyx_v_query); + PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_v_query); + __Pyx_INCREF(__pyx_v_ref); + __Pyx_GIVEREF(__pyx_v_ref); + PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_v_ref); + __pyx_t_13 = NULL; + __pyx_t_14 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_13)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_13); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_14 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_cls, __pyx_t_7}; + __pyx_t_10 = __Pyx_PyFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { + PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_cls, __pyx_t_7}; + __pyx_t_10 = __Pyx_PyCFunction_FastCall(__pyx_t_11, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } else + #endif + { + __pyx_t_12 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + if (__pyx_t_13) { + __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13); __pyx_t_13 = NULL; + } + __Pyx_INCREF(__pyx_v_cls); + __Pyx_GIVEREF(__pyx_v_cls); + PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_14, __pyx_v_cls); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_14, __pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_r = __pyx_t_10; + __pyx_t_10 = 0; + goto __pyx_L0; } - __Pyx_INCREF(__pyx_v_cls); - __Pyx_GIVEREF(__pyx_v_cls); - PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_5, __pyx_v_cls); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_5, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - /* "urlparse4/cgurl.pyx":111 + /* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -2415,39 +3083,44 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH __Pyx_XDECREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_12); __Pyx_XDECREF(__pyx_t_13); - __Pyx_AddTraceback("urlparse4.cgurl.SplitResultNamedTuple.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.SplitResultNamedTuple.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v__get_attr); + __Pyx_XDECREF(__pyx_v_scheme); + __Pyx_XDECREF(__pyx_v_netloc); + __Pyx_XDECREF(__pyx_v_path); + __Pyx_XDECREF(__pyx_v_query); + __Pyx_XDECREF(__pyx_v_ref); __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "urlparse4/cgurl.pyx":155 - * )) +/* "cgurl.pyx":168 + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) * * def geturl(self): # <<<<<<<<<<<<<< - * return stdlib_urlparse.urlunsplit(self) + * return stdlib_urlunsplit(self) * */ /* Python wrapper */ -static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_3geturl(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ -static PyMethodDef __pyx_mdef_9urlparse4_5cgurl_21SplitResultNamedTuple_3geturl = {"geturl", (PyCFunction)__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_3geturl, METH_O, 0}; -static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_3geturl(PyObject *__pyx_self, PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_3geturl(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_21SplitResultNamedTuple_3geturl = {"geturl", (PyCFunction)__pyx_pw_5cgurl_21SplitResultNamedTuple_3geturl, METH_O, 0}; +static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_3geturl(PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("geturl (wrapper)", 0); - __pyx_r = __pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_2geturl(__pyx_self, ((PyObject *)__pyx_v_self)); + __pyx_r = __pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(__pyx_self, ((PyObject *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { +static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2456,53 +3129,68 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_2geturl(CYTH PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("geturl", 0); - /* "urlparse4/cgurl.pyx":156 + /* "cgurl.pyx":169 * * def geturl(self): - * return stdlib_urlparse.urlunsplit(self) # <<<<<<<<<<<<<< - * + * return stdlib_urlunsplit(self) # <<<<<<<<<<<<<< * + * def unicode_handling(str): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urlparse); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urlunsplit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_urlunsplit); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); + __Pyx_DECREF_SET(__pyx_t_2, function); } } - if (!__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) + if (!__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __pyx_t_2 = NULL; - __Pyx_INCREF(__pyx_v_self); - __Pyx_GIVEREF(__pyx_v_self); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_self}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_v_self); + __Pyx_GIVEREF(__pyx_v_self); + PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_self); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":155 - * )) + /* "cgurl.pyx":168 + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) * * def geturl(self): # <<<<<<<<<<<<<< - * return stdlib_urlparse.urlunsplit(self) + * return stdlib_urlunsplit(self) * */ @@ -2512,7 +3200,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_2geturl(CYTH __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("urlparse4.cgurl.SplitResultNamedTuple.geturl", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.SplitResultNamedTuple.geturl", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2520,91 +3208,288 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_2geturl(CYTH return __pyx_r; } -/* "urlparse4/cgurl.pyx":159 +/* "cgurl.pyx":171 + * return stdlib_urlunsplit(self) + * + * def unicode_handling(str): # <<<<<<<<<<<<<< + * cdef bytes bytes_str + * if isinstance(str, unicode): + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_5cgurl_1unicode_handling(PyObject *__pyx_self, PyObject *__pyx_v_str); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_1unicode_handling = {"unicode_handling", (PyCFunction)__pyx_pw_5cgurl_1unicode_handling, METH_O, 0}; +static PyObject *__pyx_pw_5cgurl_1unicode_handling(PyObject *__pyx_self, PyObject *__pyx_v_str) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("unicode_handling (wrapper)", 0); + __pyx_r = __pyx_pf_5cgurl_unicode_handling(__pyx_self, ((PyObject *)__pyx_v_str)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_5cgurl_unicode_handling(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_str) { + PyObject *__pyx_v_bytes_str = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + __Pyx_RefNannySetupContext("unicode_handling", 0); + + /* "cgurl.pyx":173 + * def unicode_handling(str): + * cdef bytes bytes_str + * if isinstance(str, unicode): # <<<<<<<<<<<<<< + * bytes_str = (str).encode('utf8') + * else: + */ + __pyx_t_1 = PyUnicode_Check(__pyx_v_str); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "cgurl.pyx":174 + * cdef bytes bytes_str + * if isinstance(str, unicode): + * bytes_str = (str).encode('utf8') # <<<<<<<<<<<<<< + * else: + * bytes_str = str + */ + if (unlikely(__pyx_v_str == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); + __PYX_ERR(0, 174, __pyx_L1_error) + } + __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_str)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __pyx_t_3; + __Pyx_INCREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_bytes_str = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + + /* "cgurl.pyx":173 + * def unicode_handling(str): + * cdef bytes bytes_str + * if isinstance(str, unicode): # <<<<<<<<<<<<<< + * bytes_str = (str).encode('utf8') + * else: + */ + goto __pyx_L3; + } + + /* "cgurl.pyx":176 + * bytes_str = (str).encode('utf8') + * else: + * bytes_str = str # <<<<<<<<<<<<<< + * return bytes_str + * + */ + /*else*/ { + if (!(likely(PyBytes_CheckExact(__pyx_v_str))||((__pyx_v_str) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_str)->tp_name), 0))) __PYX_ERR(0, 176, __pyx_L1_error) + __pyx_t_4 = __pyx_v_str; + __Pyx_INCREF(__pyx_t_4); + __pyx_v_bytes_str = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + } + __pyx_L3:; + + /* "cgurl.pyx":177 + * else: + * bytes_str = str + * return bytes_str # <<<<<<<<<<<<<< * + * def urlsplit(url): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_bytes_str); + __pyx_r = __pyx_v_bytes_str; + goto __pyx_L0; + + /* "cgurl.pyx":171 + * return stdlib_urlunsplit(self) + * + * def unicode_handling(str): # <<<<<<<<<<<<<< + * cdef bytes bytes_str + * if isinstance(str, unicode): + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("cgurl.unicode_handling", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_bytes_str); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "cgurl.pyx":179 + * return bytes_str * * def urlsplit(url): # <<<<<<<<<<<<<< + * url = unicode_handling(url) * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * */ /* Python wrapper */ -static PyObject *__pyx_pw_9urlparse4_5cgurl_1urlsplit(PyObject *__pyx_self, PyObject *__pyx_v_url); /*proto*/ -static PyMethodDef __pyx_mdef_9urlparse4_5cgurl_1urlsplit = {"urlsplit", (PyCFunction)__pyx_pw_9urlparse4_5cgurl_1urlsplit, METH_O, 0}; -static PyObject *__pyx_pw_9urlparse4_5cgurl_1urlsplit(PyObject *__pyx_self, PyObject *__pyx_v_url) { +static PyObject *__pyx_pw_5cgurl_3urlsplit(PyObject *__pyx_self, PyObject *__pyx_v_url); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_3urlsplit = {"urlsplit", (PyCFunction)__pyx_pw_5cgurl_3urlsplit, METH_O, 0}; +static PyObject *__pyx_pw_5cgurl_3urlsplit(PyObject *__pyx_self, PyObject *__pyx_v_url) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("urlsplit (wrapper)", 0); - __pyx_r = __pyx_pf_9urlparse4_5cgurl_urlsplit(__pyx_self, ((PyObject *)__pyx_v_url)); + __pyx_r = __pyx_pf_5cgurl_2urlsplit(__pyx_self, ((PyObject *)__pyx_v_url)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9urlparse4_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) { +static PyObject *__pyx_pf_5cgurl_2urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - Py_ssize_t __pyx_t_5; + int __pyx_t_5; PyObject *__pyx_t_6 = NULL; __Pyx_RefNannySetupContext("urlsplit", 0); + __Pyx_INCREF(__pyx_v_url); - /* "urlparse4/cgurl.pyx":160 + /* "cgurl.pyx":180 + * + * def urlsplit(url): + * url = unicode_handling(url) # <<<<<<<<<<<<<< + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_unicode_handling); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_url); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_url}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_url}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_v_url); + __Pyx_GIVEREF(__pyx_v_url); + PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_url); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_url, __pyx_t_1); + __pyx_t_1 = 0; + + /* "cgurl.pyx":181 * def urlsplit(url): + * url = unicode_handling(url) * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) # <<<<<<<<<<<<<< * - * def urljoin(bytes base, bytes url, allow_fragments=True): + * def urljoin(base, url, allow_fragments=True): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_new); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_new); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = NULL; + __pyx_t_3 = NULL; __pyx_t_5 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); + __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_5 = 1; } } - __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_2); - __Pyx_INCREF(__pyx_v_url); - __Pyx_GIVEREF(__pyx_v_url); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_url); - __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_2, __pyx_v_url}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_t_2, __pyx_v_url}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else + #endif + { + __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_3) { + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL; + } + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_2); + __Pyx_INCREF(__pyx_v_url); + __Pyx_GIVEREF(__pyx_v_url); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_url); + __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":159 - * + /* "cgurl.pyx":179 + * return bytes_str * * def urlsplit(url): # <<<<<<<<<<<<<< + * url = unicode_handling(url) * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * */ /* function exit code */ @@ -2614,26 +3499,27 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__p __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("urlparse4.cgurl.urlsplit", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.urlsplit", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_url); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "urlparse4/cgurl.pyx":162 +/* "cgurl.pyx":183 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< - * if allow_fragments and base: - * return GURL(base).Resolve(url).spec() + * def urljoin(base, url, allow_fragments=True): # <<<<<<<<<<<<<< + * base, url = unicode_handling(base), unicode_handling(url) + * */ /* Python wrapper */ -static PyObject *__pyx_pw_9urlparse4_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_9urlparse4_5cgurl_3urljoin = {"urljoin", (PyCFunction)__pyx_pw_9urlparse4_5cgurl_3urljoin, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_9urlparse4_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5cgurl_5urljoin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_5urljoin = {"urljoin", (PyCFunction)__pyx_pw_5cgurl_5urljoin, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5cgurl_5urljoin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_base = 0; PyObject *__pyx_v_url = 0; PyObject *__pyx_v_allow_fragments = 0; @@ -2649,170 +3535,275 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_3urljoin(PyObject *__pyx_self, PyObj const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--; + if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_base)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; + CYTHON_FALLTHROUGH; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_url)) != 0)) kw_args--; + if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_url)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, 1); __PYX_ERR(0, 162, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, 1); __PYX_ERR(0, 183, __pyx_L3_error) } + CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_allow_fragments); + PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_allow_fragments); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 162, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 183, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } - __pyx_v_base = ((PyObject*)values[0]); - __pyx_v_url = ((PyObject*)values[1]); + __pyx_v_base = values[0]; + __pyx_v_url = values[1]; __pyx_v_allow_fragments = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 162, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 183, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("urlparse4.cgurl.urljoin", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.urljoin", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyBytes_Type), 1, "base", 1))) __PYX_ERR(0, 162, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 162, __pyx_L1_error) - __pyx_r = __pyx_pf_9urlparse4_5cgurl_2urljoin(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); + __pyx_r = __pyx_pf_5cgurl_4urljoin(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_9urlparse4_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_base, PyObject *__pyx_v_url, PyObject *__pyx_v_allow_fragments) { +static PyObject *__pyx_pf_5cgurl_4urljoin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_base, PyObject *__pyx_v_url, PyObject *__pyx_v_allow_fragments) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - std::string __pyx_t_3; - std::string __pyx_t_4; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; + int __pyx_t_6; + int __pyx_t_7; + std::string __pyx_t_8; + std::string __pyx_t_9; __Pyx_RefNannySetupContext("urljoin", 0); + __Pyx_INCREF(__pyx_v_base); + __Pyx_INCREF(__pyx_v_url); + + /* "cgurl.pyx":184 + * + * def urljoin(base, url, allow_fragments=True): + * base, url = unicode_handling(base), unicode_handling(url) # <<<<<<<<<<<<<< + * + * if allow_fragments and base: + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_unicode_handling); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + } + } + if (!__pyx_t_3) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_base); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_base}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_base}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else + #endif + { + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_v_base); + __Pyx_GIVEREF(__pyx_v_base); + PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_base); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_unicode_handling); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = NULL; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_3) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_url); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + } else { + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_url}; + __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { + PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_url}; + __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else + #endif + { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __pyx_t_3 = NULL; + __Pyx_INCREF(__pyx_v_url); + __Pyx_GIVEREF(__pyx_v_url); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_url); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 184, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF_SET(__pyx_v_base, __pyx_t_1); + __pyx_t_1 = 0; + __Pyx_DECREF_SET(__pyx_v_url, __pyx_t_2); + __pyx_t_2 = 0; - /* "urlparse4/cgurl.pyx":163 + /* "cgurl.pyx":186 + * base, url = unicode_handling(base), unicode_handling(url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: # <<<<<<<<<<<<<< * return GURL(base).Resolve(url).spec() * else: */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_allow_fragments); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 163, __pyx_L1_error) - if (__pyx_t_2) { + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_allow_fragments); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 186, __pyx_L1_error) + if (__pyx_t_7) { } else { - __pyx_t_1 = __pyx_t_2; + __pyx_t_6 = __pyx_t_7; goto __pyx_L4_bool_binop_done; } - __pyx_t_2 = (__pyx_v_base != Py_None) && (PyBytes_GET_SIZE(__pyx_v_base) != 0); - __pyx_t_1 = __pyx_t_2; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_base); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 186, __pyx_L1_error) + __pyx_t_6 = __pyx_t_7; __pyx_L4_bool_binop_done:; - if (__pyx_t_1) { + if (__pyx_t_6) { - /* "urlparse4/cgurl.pyx":164 - * def urljoin(bytes base, bytes url, allow_fragments=True): + /* "cgurl.pyx":187 + * * if allow_fragments and base: * return GURL(base).Resolve(url).spec() # <<<<<<<<<<<<<< * else: - * return stdlib_urlparse.urljoin(base, url, allow_fragments=allow_fragments) + * return stdlib_urljoin(base, url, allow_fragments=allow_fragments) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_v_base); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L1_error) - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L1_error) - __pyx_t_5 = __pyx_convert_PyBytes_string_to_py_std__in_string(GURL(__pyx_t_3).Resolve(__pyx_t_4).spec()); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 164, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; + __pyx_t_8 = __pyx_convert_string_from_py_std__in_string(__pyx_v_base); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 187, __pyx_L1_error) + __pyx_t_9 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 187, __pyx_L1_error) + __pyx_t_2 = __pyx_convert_PyBytes_string_to_py_std__in_string(GURL(__pyx_t_8).Resolve(__pyx_t_9).spec()); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":163 + /* "cgurl.pyx":186 + * base, url = unicode_handling(base), unicode_handling(url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: # <<<<<<<<<<<<<< * return GURL(base).Resolve(url).spec() * else: */ } - /* "urlparse4/cgurl.pyx":166 + /* "cgurl.pyx":189 * return GURL(base).Resolve(url).spec() * else: - * return stdlib_urlparse.urljoin(base, url, allow_fragments=allow_fragments) # <<<<<<<<<<<<<< + * return stdlib_urljoin(base, url, allow_fragments=allow_fragments) # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urlparse); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_urljoin); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_base); __Pyx_GIVEREF(__pyx_v_base); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_base); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_base); __Pyx_INCREF(__pyx_v_url); __Pyx_GIVEREF(__pyx_v_url); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_url); - __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_allow_fragments, __pyx_v_allow_fragments) < 0) __PYX_ERR(0, 166, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_8; - __pyx_t_8 = 0; + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_url); + __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 189, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_allow_fragments, __pyx_v_allow_fragments) < 0) __PYX_ERR(0, 189, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 189, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; goto __pyx_L0; } - /* "urlparse4/cgurl.pyx":162 + /* "cgurl.pyx":183 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< - * if allow_fragments and base: - * return GURL(base).Resolve(url).spec() + * def urljoin(base, url, allow_fragments=True): # <<<<<<<<<<<<<< + * base, url = unicode_handling(base), unicode_handling(url) + * */ /* function exit code */ __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("urlparse4.cgurl.urljoin", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.urljoin", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_base); + __Pyx_XDECREF(__pyx_v_url); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -2823,30 +3814,30 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__p * @cname("__pyx_convert_string_from_py_std__in_string") * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< * cdef Py_ssize_t length - * cdef char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) */ static std::string __pyx_convert_string_from_py_std__in_string(PyObject *__pyx_v_o) { Py_ssize_t __pyx_v_length; - char *__pyx_v_data; + char const *__pyx_v_data; std::string __pyx_r; __Pyx_RefNannyDeclarations - char *__pyx_t_1; + char const *__pyx_t_1; __Pyx_RefNannySetupContext("__pyx_convert_string_from_py_std__in_string", 0); /* "string.from_py":15 * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: * cdef Py_ssize_t length - * cdef char* data = __Pyx_PyObject_AsStringAndSize(o, &length) # <<<<<<<<<<<<<< + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) # <<<<<<<<<<<<<< * return string(data, length) * */ - __pyx_t_1 = __Pyx_PyObject_AsStringAndSize(__pyx_v_o, (&__pyx_v_length)); if (unlikely(__pyx_t_1 == NULL)) __PYX_ERR(1, 15, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_AsStringAndSize(__pyx_v_o, (&__pyx_v_length)); if (unlikely(__pyx_t_1 == ((char const *)NULL))) __PYX_ERR(1, 15, __pyx_L1_error) __pyx_v_data = __pyx_t_1; /* "string.from_py":16 * cdef Py_ssize_t length - * cdef char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) * return string(data, length) # <<<<<<<<<<<<<< * * @@ -2859,12 +3850,13 @@ static std::string __pyx_convert_string_from_py_std__in_string(PyObject *__pyx_v * @cname("__pyx_convert_string_from_py_std__in_string") * cdef string __pyx_convert_string_from_py_std__in_string(object o) except *: # <<<<<<<<<<<<<< * cdef Py_ssize_t length - * cdef char* data = __Pyx_PyObject_AsStringAndSize(o, &length) + * cdef const char* data = __Pyx_PyObject_AsStringAndSize(o, &length) */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("string.from_py.__pyx_convert_string_from_py_std__in_string", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_pretend_to_initialize(&__pyx_r); __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -2889,7 +3881,7 @@ static CYTHON_INLINE PyObject *__pyx_convert_PyObject_string_to_py_std__in_strin * cdef inline object __pyx_convert_PyObject_string_to_py_std__in_string(const string& s): * return __Pyx_PyObject_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: - * cdef object __Pyx_PyUnicode_FromStringAndSize(char*, size_t) + * cdef object __Pyx_PyUnicode_FromStringAndSize(const char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 32, __pyx_L1_error) @@ -2936,7 +3928,7 @@ static CYTHON_INLINE PyObject *__pyx_convert_PyUnicode_string_to_py_std__in_stri * cdef inline object __pyx_convert_PyUnicode_string_to_py_std__in_string(const string& s): * return __Pyx_PyUnicode_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: - * cdef object __Pyx_PyStr_FromStringAndSize(char*, size_t) + * cdef object __Pyx_PyStr_FromStringAndSize(const char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyUnicode_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 38, __pyx_L1_error) @@ -2983,7 +3975,7 @@ static CYTHON_INLINE PyObject *__pyx_convert_PyStr_string_to_py_std__in_string(s * cdef inline object __pyx_convert_PyStr_string_to_py_std__in_string(const string& s): * return __Pyx_PyStr_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: - * cdef object __Pyx_PyBytes_FromStringAndSize(char*, size_t) + * cdef object __Pyx_PyBytes_FromStringAndSize(const char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyStr_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 44, __pyx_L1_error) @@ -3030,7 +4022,7 @@ static CYTHON_INLINE PyObject *__pyx_convert_PyBytes_string_to_py_std__in_string * cdef inline object __pyx_convert_PyBytes_string_to_py_std__in_string(const string& s): * return __Pyx_PyBytes_FromStringAndSize(s.data(), s.size()) # <<<<<<<<<<<<<< * cdef extern from *: - * cdef object __Pyx_PyByteArray_FromStringAndSize(char*, size_t) + * cdef object __Pyx_PyByteArray_FromStringAndSize(const char*, size_t) */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyBytes_FromStringAndSize(__pyx_v_s.data(), __pyx_v_s.size()); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 50, __pyx_L1_error) @@ -3104,14 +4096,14 @@ static CYTHON_INLINE PyObject *__pyx_convert_PyByteArray_string_to_py_std__in_st return __pyx_r; } -static struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ *__pyx_freelist_9urlparse4_5cgurl___pyx_scope_struct____new__[8]; -static int __pyx_freecount_9urlparse4_5cgurl___pyx_scope_struct____new__ = 0; +static struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *__pyx_freelist_5cgurl___pyx_scope_struct____new__[8]; +static int __pyx_freecount_5cgurl___pyx_scope_struct____new__ = 0; -static PyObject *__pyx_tp_new_9urlparse4_5cgurl___pyx_scope_struct____new__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { +static PyObject *__pyx_tp_new_5cgurl___pyx_scope_struct____new__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o; - if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_9urlparse4_5cgurl___pyx_scope_struct____new__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__)))) { - o = (PyObject*)__pyx_freelist_9urlparse4_5cgurl___pyx_scope_struct____new__[--__pyx_freecount_9urlparse4_5cgurl___pyx_scope_struct____new__]; - memset(o, 0, sizeof(struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__)); + if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_5cgurl___pyx_scope_struct____new__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_5cgurl___pyx_scope_struct____new__)))) { + o = (PyObject*)__pyx_freelist_5cgurl___pyx_scope_struct____new__[--__pyx_freecount_5cgurl___pyx_scope_struct____new__]; + memset(o, 0, sizeof(struct __pyx_obj_5cgurl___pyx_scope_struct____new__)); (void) PyObject_INIT(o, t); } else { o = (*t->tp_alloc)(t, 0); @@ -3120,22 +4112,22 @@ static PyObject *__pyx_tp_new_9urlparse4_5cgurl___pyx_scope_struct____new__(PyTy return o; } -static void __pyx_tp_dealloc_9urlparse4_5cgurl___pyx_scope_struct____new__(PyObject *o) { - struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ *p = (struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ *)o; +static void __pyx_tp_dealloc_5cgurl___pyx_scope_struct____new__(PyObject *o) { + struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *p = (struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *)o; Py_CLEAR(p->__pyx_v_url); - if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_9urlparse4_5cgurl___pyx_scope_struct____new__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__)))) { - __pyx_freelist_9urlparse4_5cgurl___pyx_scope_struct____new__[__pyx_freecount_9urlparse4_5cgurl___pyx_scope_struct____new__++] = ((struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__ *)o); + if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_5cgurl___pyx_scope_struct____new__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_5cgurl___pyx_scope_struct____new__)))) { + __pyx_freelist_5cgurl___pyx_scope_struct____new__[__pyx_freecount_5cgurl___pyx_scope_struct____new__++] = ((struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *)o); } else { (*Py_TYPE(o)->tp_free)(o); } } -static PyTypeObject __pyx_type_9urlparse4_5cgurl___pyx_scope_struct____new__ = { +static PyTypeObject __pyx_type_5cgurl___pyx_scope_struct____new__ = { PyVarObject_HEAD_INIT(0, 0) - "urlparse4.cgurl.__pyx_scope_struct____new__", /*tp_name*/ - sizeof(struct __pyx_obj_9urlparse4_5cgurl___pyx_scope_struct____new__), /*tp_basicsize*/ + "cgurl.__pyx_scope_struct____new__", /*tp_name*/ + sizeof(struct __pyx_obj_5cgurl___pyx_scope_struct____new__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_9urlparse4_5cgurl___pyx_scope_struct____new__, /*tp_dealloc*/ + __pyx_tp_dealloc_5cgurl___pyx_scope_struct____new__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -3173,7 +4165,7 @@ static PyTypeObject __pyx_type_9urlparse4_5cgurl___pyx_scope_struct____new__ = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_9urlparse4_5cgurl___pyx_scope_struct____new__, /*tp_new*/ + __pyx_tp_new_5cgurl___pyx_scope_struct____new__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -3193,17 +4185,31 @@ static PyMethodDef __pyx_methods[] = { }; #if PY_MAJOR_VERSION >= 3 +#if CYTHON_PEP489_MULTI_PHASE_INIT +static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ +static int __pyx_pymod_exec_cgurl(PyObject* module); /*proto*/ +static PyModuleDef_Slot __pyx_moduledef_slots[] = { + {Py_mod_create, (void*)__pyx_pymod_create}, + {Py_mod_exec, (void*)__pyx_pymod_exec_cgurl}, + {0, NULL} +}; +#endif + static struct PyModuleDef __pyx_moduledef = { - #if PY_VERSION_HEX < 0x03020000 - { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, - #else PyModuleDef_HEAD_INIT, - #endif "cgurl", 0, /* m_doc */ + #if CYTHON_PEP489_MULTI_PHASE_INIT + 0, /* m_size */ + #else -1, /* m_size */ + #endif __pyx_methods /* m_methods */, + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_moduledef_slots, /* m_slots */ + #else NULL, /* m_reload */ + #endif NULL, /* m_traverse */ NULL, /* m_clear */ NULL /* m_free */ @@ -3212,6 +4218,7 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_b_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 0, 0}, + {&__pyx_n_s_PY2, __pyx_k_PY2, sizeof(__pyx_k_PY2), 0, 0, 1, 1}, {&__pyx_n_s_SplitResultNamedTuple, __pyx_k_SplitResultNamedTuple, sizeof(__pyx_k_SplitResultNamedTuple), 0, 0, 1, 1}, {&__pyx_n_s_SplitResultNamedTuple___new, __pyx_k_SplitResultNamedTuple___new, sizeof(__pyx_k_SplitResultNamedTuple___new), 0, 0, 1, 1}, {&__pyx_n_s_SplitResultNamedTuple___new___lo, __pyx_k_SplitResultNamedTuple___new___lo, sizeof(__pyx_k_SplitResultNamedTuple___new___lo), 0, 0, 1, 1}, @@ -3219,8 +4226,11 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_allow_fragments, __pyx_k_allow_fragments, sizeof(__pyx_k_allow_fragments), 0, 0, 1, 1}, {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1}, + {&__pyx_n_s_bytes_str, __pyx_k_bytes_str, sizeof(__pyx_k_bytes_str), 0, 0, 1, 1}, + {&__pyx_n_s_cgurl, __pyx_k_cgurl, sizeof(__pyx_k_cgurl), 0, 0, 1, 1}, + {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1}, - {&__pyx_kp_s_cosr_urlparse4_urlparse4_cgurl, __pyx_k_cosr_urlparse4_urlparse4_cgurl, sizeof(__pyx_k_cosr_urlparse4_urlparse4_cgurl), 0, 0, 1, 0}, + {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1}, {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1}, {&__pyx_kp_b_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 0, 0}, {&__pyx_n_s_fragment, __pyx_k_fragment, sizeof(__pyx_k_fragment), 0, 0, 1, 1}, @@ -3243,22 +4253,28 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_prop, __pyx_k_prop, sizeof(__pyx_k_prop), 0, 0, 1, 1}, {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1}, {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 0, 0, 1, 1}, + {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1}, {&__pyx_n_s_scheme, __pyx_k_scheme, sizeof(__pyx_k_scheme), 0, 0, 1, 1}, {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1}, + {&__pyx_n_s_six, __pyx_k_six, sizeof(__pyx_k_six), 0, 0, 1, 1}, + {&__pyx_n_s_six_moves_urllib_parse, __pyx_k_six_moves_urllib_parse, sizeof(__pyx_k_six_moves_urllib_parse), 0, 0, 1, 1}, {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 0, 0, 1, 1}, - {&__pyx_n_s_stdlib_urlparse, __pyx_k_stdlib_urlparse, sizeof(__pyx_k_stdlib_urlparse), 0, 0, 1, 1}, + {&__pyx_n_s_stdlib_urljoin, __pyx_k_stdlib_urljoin, sizeof(__pyx_k_stdlib_urljoin), 0, 0, 1, 1}, + {&__pyx_n_s_stdlib_urlunsplit, __pyx_k_stdlib_urlunsplit, sizeof(__pyx_k_stdlib_urlunsplit), 0, 0, 1, 1}, + {&__pyx_n_s_str, __pyx_k_str, sizeof(__pyx_k_str), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_unicode_handling, __pyx_k_unicode_handling, sizeof(__pyx_k_unicode_handling), 0, 0, 1, 1}, {&__pyx_n_s_url, __pyx_k_url, sizeof(__pyx_k_url), 0, 0, 1, 1}, {&__pyx_n_s_urljoin, __pyx_k_urljoin, sizeof(__pyx_k_urljoin), 0, 0, 1, 1}, - {&__pyx_n_s_urlparse, __pyx_k_urlparse, sizeof(__pyx_k_urlparse), 0, 0, 1, 1}, - {&__pyx_n_s_urlparse4_cgurl, __pyx_k_urlparse4_cgurl, sizeof(__pyx_k_urlparse4_cgurl), 0, 0, 1, 1}, + {&__pyx_kp_s_urlparse4_cgurl_pyx, __pyx_k_urlparse4_cgurl_pyx, sizeof(__pyx_k_urlparse4_cgurl_pyx), 0, 0, 1, 0}, {&__pyx_n_s_urlsplit, __pyx_k_urlsplit, sizeof(__pyx_k_urlsplit), 0, 0, 1, 1}, {&__pyx_n_s_urlunsplit, __pyx_k_urlunsplit, sizeof(__pyx_k_urlunsplit), 0, 0, 1, 1}, {&__pyx_n_s_username, __pyx_k_username, sizeof(__pyx_k_username), 0, 0, 1, 1}, + {&__pyx_kp_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 56, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -3268,65 +4284,88 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "urlparse4/cgurl.pyx":120 + /* "cgurl.pyx":125 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< * if prop == "scheme": * return self[0] */ - __pyx_tuple__2 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_prop, __pyx_n_s_port); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 120, __pyx_L1_error) + __pyx_tuple__2 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_prop, __pyx_n_s_port); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cosr_urlparse4_urlparse4_cgurl, __pyx_n_s_get_attr, 120, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 120, __pyx_L1_error) + __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_get_attr, 125, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 125, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":111 + /* "cgurl.pyx":159 + * if six.PY2: + * return tuple.__new__(cls, ( + * scheme.decode('utf-8'), # <<<<<<<<<<<<<< + * netloc.decode('utf-8'), + * path.decode('utf-8'), + */ + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 159, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + + /* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< * * cdef Parsed parsed */ - __pyx_tuple__4 = PyTuple_Pack(5, __pyx_n_s_cls, __pyx_n_s_url, __pyx_n_s_parsed, __pyx_n_s_get_attr, __pyx_n_s_get_attr); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cosr_urlparse4_urlparse4_cgurl, __pyx_n_s_new, 111, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 111, __pyx_L1_error) + __pyx_tuple__5 = PyTuple_Pack(10, __pyx_n_s_cls, __pyx_n_s_url, __pyx_n_s_parsed, __pyx_n_s_get_attr, __pyx_n_s_get_attr, __pyx_n_s_scheme, __pyx_n_s_netloc, __pyx_n_s_path, __pyx_n_s_query, __pyx_n_s_ref); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 116, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(2, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_new, 116, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 116, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":155 - * )) + /* "cgurl.pyx":168 + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) * * def geturl(self): # <<<<<<<<<<<<<< - * return stdlib_urlparse.urlunsplit(self) + * return stdlib_urlunsplit(self) * */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 155, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); - __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cosr_urlparse4_urlparse4_cgurl, __pyx_n_s_geturl, 155, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 155, __pyx_L1_error) + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 168, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_geturl, 168, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 168, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":159 + /* "cgurl.pyx":171 + * return stdlib_urlunsplit(self) * + * def unicode_handling(str): # <<<<<<<<<<<<<< + * cdef bytes bytes_str + * if isinstance(str, unicode): + */ + __pyx_tuple__9 = PyTuple_Pack(2, __pyx_n_s_str, __pyx_n_s_bytes_str); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 171, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_unicode_handling, 171, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 171, __pyx_L1_error) + + /* "cgurl.pyx":179 + * return bytes_str * * def urlsplit(url): # <<<<<<<<<<<<<< + * url = unicode_handling(url) * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cosr_urlparse4_urlparse4_cgurl, __pyx_n_s_urlsplit, 159, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_n_s_url); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 179, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 179, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 179, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":162 + /* "cgurl.pyx":183 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< - * if allow_fragments and base: - * return GURL(base).Resolve(url).spec() + * def urljoin(base, url, allow_fragments=True): # <<<<<<<<<<<<<< + * base, url = unicode_handling(base), unicode_handling(url) + * */ - __pyx_tuple__10 = PyTuple_Pack(3, __pyx_n_s_base, __pyx_n_s_url, __pyx_n_s_allow_fragments); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); - __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_cosr_urlparse4_urlparse4_cgurl, __pyx_n_s_urljoin, 162, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 162, __pyx_L1_error) + __pyx_tuple__13 = PyTuple_Pack(3, __pyx_n_s_base, __pyx_n_s_url, __pyx_n_s_allow_fragments); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 183, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); + __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 183, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -3342,12 +4381,151 @@ static int __Pyx_InitGlobals(void) { return -1; } +static int __Pyx_modinit_global_init_code(void); /*proto*/ +static int __Pyx_modinit_variable_export_code(void); /*proto*/ +static int __Pyx_modinit_function_export_code(void); /*proto*/ +static int __Pyx_modinit_type_init_code(void); /*proto*/ +static int __Pyx_modinit_type_import_code(void); /*proto*/ +static int __Pyx_modinit_variable_import_code(void); /*proto*/ +static int __Pyx_modinit_function_import_code(void); /*proto*/ + +static int __Pyx_modinit_global_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0); + /*--- Global init code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0); + /*--- Variable export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_export_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0); + /*--- Function export code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_type_init_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0); + /*--- Type init code ---*/ + if (PyType_Ready(&__pyx_type_5cgurl___pyx_scope_struct____new__) < 0) __PYX_ERR(0, 116, __pyx_L1_error) + __pyx_type_5cgurl___pyx_scope_struct____new__.tp_print = 0; + if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5cgurl___pyx_scope_struct____new__.tp_dictoffset && __pyx_type_5cgurl___pyx_scope_struct____new__.tp_getattro == PyObject_GenericGetAttr)) { + __pyx_type_5cgurl___pyx_scope_struct____new__.tp_getattro = __Pyx_PyObject_GenericGetAttrNoDict; + } + __pyx_ptype_5cgurl___pyx_scope_struct____new__ = &__pyx_type_5cgurl___pyx_scope_struct____new__; + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_modinit_type_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0); + /*--- Type import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_variable_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0); + /*--- Variable import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + +static int __Pyx_modinit_function_import_code(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0); + /*--- Function import code ---*/ + __Pyx_RefNannyFinishContext(); + return 0; +} + + +#if PY_MAJOR_VERSION < 3 +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC void +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#else +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC PyObject * +#else +#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC +#endif +#endif +#ifndef CYTHON_SMALL_CODE +#if defined(__clang__) + #define CYTHON_SMALL_CODE +#elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4))) + #define CYTHON_SMALL_CODE __attribute__((optimize("Os"))) +#else + #define CYTHON_SMALL_CODE +#endif +#endif + + #if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC initcgurl(void); /*proto*/ -PyMODINIT_FUNC initcgurl(void) +__Pyx_PyMODINIT_FUNC initcgurl(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initcgurl(void) #else -PyMODINIT_FUNC PyInit_cgurl(void); /*proto*/ -PyMODINIT_FUNC PyInit_cgurl(void) +__Pyx_PyMODINIT_FUNC PyInit_cgurl(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC PyInit_cgurl(void) +#if CYTHON_PEP489_MULTI_PHASE_INIT +{ + return PyModuleDef_Init(&__pyx_moduledef); +} +static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { + PyObject *value = PyObject_GetAttrString(spec, from_name); + int result = 0; + if (likely(value)) { + result = PyDict_SetItemString(moddict, to_name, value); + Py_DECREF(value); + } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Clear(); + } else { + result = -1; + } + return result; +} +static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { + PyObject *module = NULL, *moddict, *modname; + if (__pyx_m) + return __Pyx_NewRef(__pyx_m); + modname = PyObject_GetAttrString(spec, "name"); + if (unlikely(!modname)) goto bad; + module = PyModule_NewObject(modname); + Py_DECREF(modname); + if (unlikely(!module)) goto bad; + moddict = PyModule_GetDict(module); + if (unlikely(!moddict)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; + if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; + return module; +bad: + Py_XDECREF(module); + return NULL; +} + + +static int __pyx_pymod_exec_cgurl(PyObject *__pyx_pyinit_module) +#endif #endif { PyObject *__pyx_t_1 = NULL; @@ -3355,16 +4533,21 @@ PyMODINIT_FUNC PyInit_cgurl(void) PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; __Pyx_RefNannyDeclarations - #if CYTHON_REFNANNY - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); - if (!__Pyx_RefNanny) { - PyErr_Clear(); - __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); - if (!__Pyx_RefNanny) - Py_FatalError("failed to import 'refnanny' module"); - } + #if CYTHON_PEP489_MULTI_PHASE_INIT + if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; + #elif PY_MAJOR_VERSION >= 3 + if (__pyx_m) return __Pyx_NewRef(__pyx_m); #endif - __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_cgurl(void)", 0); + #if CYTHON_REFNANNY +__Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); +if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); +} +#endif + __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cgurl(void)", 0); if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) @@ -3381,6 +4564,9 @@ PyMODINIT_FUNC PyInit_cgurl(void) #ifdef __Pyx_Generator_USED if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif + #ifdef __Pyx_AsyncGen_USED + if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) + #endif #ifdef __Pyx_StopAsyncIteration_USED if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif @@ -3392,15 +4578,21 @@ PyMODINIT_FUNC PyInit_cgurl(void) #endif #endif /*--- Module creation code ---*/ + #if CYTHON_PEP489_MULTI_PHASE_INIT + __pyx_m = __pyx_pyinit_module; + Py_INCREF(__pyx_m); + #else #if PY_MAJOR_VERSION < 3 __pyx_m = Py_InitModule4("cgurl", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) + #endif __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) Py_INCREF(__pyx_d); __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif @@ -3410,14 +4602,14 @@ PyMODINIT_FUNC PyInit_cgurl(void) #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif - if (__pyx_module_is_main_urlparse4__cgurl) { + if (__pyx_module_is_main_cgurl) { if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) } #if PY_MAJOR_VERSION >= 3 { PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "urlparse4.cgurl")) { - if (unlikely(PyDict_SetItemString(modules, "urlparse4.cgurl", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) + if (!PyDict_GetItemString(modules, "cgurl")) { + if (unlikely(PyDict_SetItemString(modules, "cgurl", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) } } #endif @@ -3425,128 +4617,180 @@ PyMODINIT_FUNC PyInit_cgurl(void) if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) /*--- Constants init code ---*/ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global init code ---*/ - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - if (PyType_Ready(&__pyx_type_9urlparse4_5cgurl___pyx_scope_struct____new__) < 0) __PYX_ERR(0, 111, __pyx_L1_error) - __pyx_type_9urlparse4_5cgurl___pyx_scope_struct____new__.tp_print = 0; - __pyx_ptype_9urlparse4_5cgurl___pyx_scope_struct____new__ = &__pyx_type_9urlparse4_5cgurl___pyx_scope_struct____new__; - /*--- Type import code ---*/ - /*--- Variable import code ---*/ - /*--- Function import code ---*/ + /*--- Global type/function init code ---*/ + (void)__Pyx_modinit_global_init_code(); + (void)__Pyx_modinit_variable_export_code(); + (void)__Pyx_modinit_function_export_code(); + if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error; + (void)__Pyx_modinit_type_import_code(); + (void)__Pyx_modinit_variable_import_code(); + (void)__Pyx_modinit_function_import_code(); /*--- Execution code ---*/ #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif - /* "urlparse4/cgurl.pyx":3 - * from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL - * from chromium_gurl cimport GURL - * import urlparse as stdlib_urlparse # <<<<<<<<<<<<<< - * cimport cython + /* "cgurl.pyx":4 + * from urlparse4.chromium_gurl cimport GURL + * + * import six # <<<<<<<<<<<<<< + * from six.moves.urllib.parse import urljoin as stdlib_urljoin + * from six.moves.urllib.parse import urlunsplit as stdlib_urlunsplit + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_six, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_six, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "cgurl.pyx":5 + * + * import six + * from six.moves.urllib.parse import urljoin as stdlib_urljoin # <<<<<<<<<<<<<< + * from six.moves.urllib.parse import urlunsplit as stdlib_urlunsplit + * + */ + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_n_s_urljoin); + __Pyx_GIVEREF(__pyx_n_s_urljoin); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_urljoin); + __pyx_t_2 = __Pyx_Import(__pyx_n_s_six_moves_urllib_parse, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_urljoin); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_stdlib_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "cgurl.pyx":6 + * import six + * from six.moves.urllib.parse import urljoin as stdlib_urljoin + * from six.moves.urllib.parse import urlunsplit as stdlib_urlunsplit # <<<<<<<<<<<<<< * + * cimport cython */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_urlparse, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_n_s_urlunsplit); + __Pyx_GIVEREF(__pyx_n_s_urlunsplit); + PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_urlunsplit); + __pyx_t_1 = __Pyx_Import(__pyx_n_s_six_moves_urllib_parse, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_stdlib_urlparse, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_urlunsplit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_stdlib_urlunsplit, __pyx_t_2) < 0) __PYX_ERR(0, 6, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "urlparse4/cgurl.pyx":107 + /* "cgurl.pyx":112 * * * class SplitResultNamedTuple(tuple): # <<<<<<<<<<<<<< * * __slots__ = () # prevent creation of instance dictionary */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)(&PyTuple_Type))); __Pyx_GIVEREF(((PyObject *)(&PyTuple_Type))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)(&PyTuple_Type))); - __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_SplitResultNamedTuple, __pyx_n_s_SplitResultNamedTuple, (PyObject *) NULL, __pyx_n_s_urlparse4_cgurl, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_SplitResultNamedTuple, __pyx_n_s_SplitResultNamedTuple, (PyObject *) NULL, __pyx_n_s_cgurl, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - /* "urlparse4/cgurl.pyx":109 + /* "cgurl.pyx":114 * class SplitResultNamedTuple(tuple): * * __slots__ = () # prevent creation of instance dictionary # <<<<<<<<<<<<<< * * def __new__(cls, bytes url): */ - if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_slots, __pyx_empty_tuple) < 0) __PYX_ERR(0, 109, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_slots, __pyx_empty_tuple) < 0) __PYX_ERR(0, 114, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":111 + /* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< * * cdef Parsed parsed */ - __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_SplitResultNamedTuple___new, NULL, __pyx_n_s_urlparse4_cgurl, __pyx_d, ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error) + __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5cgurl_21SplitResultNamedTuple_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_SplitResultNamedTuple___new, NULL, __pyx_n_s_cgurl, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_new, __pyx_t_4) < 0) __PYX_ERR(0, 111, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_new, __pyx_t_4) < 0) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "urlparse4/cgurl.pyx":155 - * )) + /* "cgurl.pyx":168 + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) * * def geturl(self): # <<<<<<<<<<<<<< - * return stdlib_urlparse.urlunsplit(self) + * return stdlib_urlunsplit(self) * */ - __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_9urlparse4_5cgurl_21SplitResultNamedTuple_3geturl, 0, __pyx_n_s_SplitResultNamedTuple_geturl, NULL, __pyx_n_s_urlparse4_cgurl, __pyx_d, ((PyObject *)__pyx_codeobj__7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 155, __pyx_L1_error) + __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5cgurl_21SplitResultNamedTuple_3geturl, 0, __pyx_n_s_SplitResultNamedTuple_geturl, NULL, __pyx_n_s_cgurl, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_geturl, __pyx_t_4) < 0) __PYX_ERR(0, 155, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_geturl, __pyx_t_4) < 0) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "urlparse4/cgurl.pyx":107 + /* "cgurl.pyx":112 * * * class SplitResultNamedTuple(tuple): # <<<<<<<<<<<<<< * * __slots__ = () # prevent creation of instance dictionary */ - __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_SplitResultNamedTuple, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error) + __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_SplitResultNamedTuple, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_SplitResultNamedTuple, __pyx_t_4) < 0) __PYX_ERR(0, 107, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SplitResultNamedTuple, __pyx_t_4) < 0) __PYX_ERR(0, 112, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "urlparse4/cgurl.pyx":159 + /* "cgurl.pyx":171 + * return stdlib_urlunsplit(self) * + * def unicode_handling(str): # <<<<<<<<<<<<<< + * cdef bytes bytes_str + * if isinstance(str, unicode): + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1unicode_handling, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_unicode_handling, __pyx_t_1) < 0) __PYX_ERR(0, 171, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "cgurl.pyx":179 + * return bytes_str * * def urlsplit(url): # <<<<<<<<<<<<<< + * url = unicode_handling(url) * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_9urlparse4_5cgurl_1urlsplit, NULL, __pyx_n_s_urlparse4_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 159, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "urlparse4/cgurl.pyx":162 + /* "cgurl.pyx":183 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< - * if allow_fragments and base: - * return GURL(base).Resolve(url).spec() + * def urljoin(base, url, allow_fragments=True): # <<<<<<<<<<<<<< + * base, url = unicode_handling(base), unicode_handling(url) + * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_9urlparse4_5cgurl_3urljoin, NULL, __pyx_n_s_urlparse4_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_5urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 162, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 183, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "urlparse4/cgurl.pyx":1 + /* "cgurl.pyx":1 * from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL # <<<<<<<<<<<<<< - * from chromium_gurl cimport GURL - * import urlparse as stdlib_urlparse + * from urlparse4.chromium_gurl cimport GURL + * */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -3569,18 +4813,20 @@ PyMODINIT_FUNC PyInit_cgurl(void) __Pyx_XDECREF(__pyx_t_4); if (__pyx_m) { if (__pyx_d) { - __Pyx_AddTraceback("init urlparse4.cgurl", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("init cgurl", 0, __pyx_lineno, __pyx_filename); } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init urlparse4.cgurl"); + PyErr_SetString(PyExc_ImportError, "init cgurl"); } __pyx_L0:; __Pyx_RefNannyFinishContext(); - #if PY_MAJOR_VERSION < 3 - return; - #else + #if CYTHON_PEP489_MULTI_PHASE_INIT + return (__pyx_m != NULL) ? 0 : -1; + #elif PY_MAJOR_VERSION >= 3 return __pyx_m; + #else + return; #endif } @@ -3602,6 +4848,20 @@ static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { } #endif +/* PyObjectGetAttrStr */ +#if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#endif + /* GetBuiltinName */ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); @@ -3617,7 +4877,7 @@ static PyObject *__Pyx_GetBuiltinName(PyObject *name) { } /* PyErrFetchRestore */ -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_FAST_THREAD_STATE static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; tmp_type = tstate->curexc_type; @@ -3756,11 +5016,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "raise: exception class must be a subclass of BaseException"); goto bad; } -#if PY_VERSION_HEX >= 0x03030000 if (cause) { -#else - if (cause && cause != Py_None) { -#endif PyObject *fixed_cause; if (cause == Py_None) { fixed_cause = NULL; @@ -3788,7 +5044,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject PyErr_Restore(tmp_type, tmp_value, tb); Py_XDECREF(tmp_tb); #else - PyThreadState *tstate = PyThreadState_GET(); + PyThreadState *tstate = __Pyx_PyThreadState_Current; PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { Py_INCREF(tb); @@ -3804,7 +5060,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject #endif /* RaiseArgTupleInvalid */ - static void __Pyx_RaiseArgtupleInvalid( +static void __Pyx_RaiseArgtupleInvalid( const char* func_name, int exact, Py_ssize_t num_min, @@ -3830,7 +5086,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* RaiseDoubleKeywords */ - static void __Pyx_RaiseDoubleKeywordsError( +static void __Pyx_RaiseDoubleKeywordsError( const char* func_name, PyObject* kw_name) { @@ -3844,7 +5100,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* ParseKeywords */ - static int __Pyx_ParseOptionalKeywords( +static int __Pyx_ParseOptionalKeywords( PyObject *kwds, PyObject **argnames[], PyObject *kwds2, @@ -3946,34 +5202,28 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } /* ArgTypeTest */ - static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); -} -static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, - const char *name, int exact) +static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) { if (unlikely(!type)) { PyErr_SetString(PyExc_SystemError, "Missing type object"); return 0; } - if (none_allowed && obj == Py_None) return 1; else if (exact) { - if (likely(Py_TYPE(obj) == type)) return 1; #if PY_MAJOR_VERSION == 2 - else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; #endif } else { - if (likely(PyObject_TypeCheck(obj, type))) return 1; + if (likely(__Pyx_TypeCheck(obj, type))) return 1; } - __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); return 0; } /* BytesEquals */ - static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { +static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else @@ -3991,7 +5241,16 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in } else if (length == 1) { return (equals == Py_EQ); } else { - int result = memcmp(ps1, ps2, (size_t)length); + int result; +#if CYTHON_USE_UNICODE_INTERNALS + Py_hash_t hash1, hash2; + hash1 = ((PyBytesObject*)s1)->ob_shash; + hash2 = ((PyBytesObject*)s2)->ob_shash; + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + return (equals == Py_NE); + } +#endif + result = memcmp(ps1, ps2, (size_t)length); return (equals == Py_EQ) ? (result == 0) : (result != 0); } } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { @@ -4011,7 +5270,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in } /* UnicodeEquals */ - static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { +static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); #else @@ -4051,6 +5310,21 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) { goto return_ne; } +#if CYTHON_USE_UNICODE_INTERNALS + { + Py_hash_t hash1, hash2; + #if CYTHON_PEP393_ENABLED + hash1 = ((PyASCIIObject*)s1)->hash; + hash2 = ((PyASCIIObject*)s2)->hash; + #else + hash1 = ((PyUnicodeObject*)s1)->hash; + hash2 = ((PyUnicodeObject*)s2)->hash; + #endif + if (hash1 != hash2 && hash1 != -1 && hash2 != -1) { + goto return_ne; + } + } +#endif kind = __Pyx_PyUnicode_KIND(s1); if (kind != __Pyx_PyUnicode_KIND(s2)) { goto return_ne; @@ -4095,7 +5369,7 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in } /* GetItemInt */ - static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { +static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { PyObject *r; if (!j) return NULL; r = PyObject_GetItem(o, j); @@ -4105,10 +5379,13 @@ static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, in static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_COMPILING_IN_CPYTHON - if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); - if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, i); +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyList_GET_SIZE(o); + } + if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } @@ -4120,10 +5397,13 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_COMPILING_IN_CPYTHON - if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, i); +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + Py_ssize_t wrapped_i = i; + if (wraparound & unlikely(i < 0)) { + wrapped_i += PyTuple_GET_SIZE(o); + } + if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); Py_INCREF(r); return r; } @@ -4135,7 +5415,7 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS if (is_list || PyList_CheckExact(o)) { Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { @@ -4176,12 +5456,155 @@ static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, } /* None */ - static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) { +static CYTHON_INLINE void __Pyx_RaiseClosureNameError(const char *varname) { PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname); } +/* PyCFunctionFastCall */ +#if CYTHON_FAST_PYCCALL +static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { + PyCFunctionObject *func = (PyCFunctionObject*)func_obj; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + int flags = PyCFunction_GET_FLAGS(func); + assert(PyCFunction_Check(func)); + assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); + assert(nargs >= 0); + assert(nargs == 0 || args != NULL); + /* _PyCFunction_FastCallDict() must not be called with an exception set, + because it may clear it (directly or indirectly) and so the + caller loses its exception */ + assert(!PyErr_Occurred()); + if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { + return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); + } else { + return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); + } +} +#endif + +/* PyFunctionFastCall */ +#if CYTHON_FAST_PYCALL +#include "frameobject.h" +static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, + PyObject *globals) { + PyFrameObject *f; + PyThreadState *tstate = __Pyx_PyThreadState_Current; + PyObject **fastlocals; + Py_ssize_t i; + PyObject *result; + assert(globals != NULL); + /* XXX Perhaps we should create a specialized + PyFrame_New() that doesn't take locals, but does + take builtins without sanity checking them. + */ + assert(tstate != NULL); + f = PyFrame_New(tstate, co, globals, NULL); + if (f == NULL) { + return NULL; + } + fastlocals = f->f_localsplus; + for (i = 0; i < na; i++) { + Py_INCREF(*args); + fastlocals[i] = *args++; + } + result = PyEval_EvalFrameEx(f,0); + ++tstate->recursion_depth; + Py_DECREF(f); + --tstate->recursion_depth; + return result; +} +#if 1 || PY_VERSION_HEX < 0x030600B1 +static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { + PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); + PyObject *globals = PyFunction_GET_GLOBALS(func); + PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *closure; +#if PY_MAJOR_VERSION >= 3 + PyObject *kwdefs; +#endif + PyObject *kwtuple, **k; + PyObject **d; + Py_ssize_t nd; + Py_ssize_t nk; + PyObject *result; + assert(kwargs == NULL || PyDict_Check(kwargs)); + nk = kwargs ? PyDict_Size(kwargs) : 0; + if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { + return NULL; + } + if ( +#if PY_MAJOR_VERSION >= 3 + co->co_kwonlyargcount == 0 && +#endif + likely(kwargs == NULL || nk == 0) && + co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { + if (argdefs == NULL && co->co_argcount == nargs) { + result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); + goto done; + } + else if (nargs == 0 && argdefs != NULL + && co->co_argcount == Py_SIZE(argdefs)) { + /* function called with no arguments, but all parameters have + a default value: use default values as arguments .*/ + args = &PyTuple_GET_ITEM(argdefs, 0); + result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); + goto done; + } + } + if (kwargs != NULL) { + Py_ssize_t pos, i; + kwtuple = PyTuple_New(2 * nk); + if (kwtuple == NULL) { + result = NULL; + goto done; + } + k = &PyTuple_GET_ITEM(kwtuple, 0); + pos = i = 0; + while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { + Py_INCREF(k[i]); + Py_INCREF(k[i+1]); + i += 2; + } + nk = i / 2; + } + else { + kwtuple = NULL; + k = NULL; + } + closure = PyFunction_GET_CLOSURE(func); +#if PY_MAJOR_VERSION >= 3 + kwdefs = PyFunction_GET_KW_DEFAULTS(func); +#endif + if (argdefs != NULL) { + d = &PyTuple_GET_ITEM(argdefs, 0); + nd = Py_SIZE(argdefs); + } + else { + d = NULL; + nd = 0; + } +#if PY_MAJOR_VERSION >= 3 + result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, kwdefs, closure); +#else + result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, + args, nargs, + k, (int)nk, + d, (int)nd, closure); +#endif + Py_XDECREF(kwtuple); +done: + Py_LeaveRecursiveCall(); + return result; +} +#endif +#endif + /* PyObjectCall */ - #if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *result; ternaryfunc call = func->ob_type->tp_call; @@ -4201,7 +5624,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg #endif /* PyObjectCallMethO */ - #if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { PyObject *self, *result; PyCFunction cfunc; @@ -4221,7 +5644,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject #endif /* PyObjectCallOneArg */ - #if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_COMPILING_IN_CPYTHON static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { PyObject *result; PyObject *args = PyTuple_New(1); @@ -4233,13 +5656,18 @@ static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { return result; } static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, &arg, 1); + } #endif + if (likely(PyCFunction_Check(func))) { if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { return __Pyx_PyObject_CallMethO(func, arg); +#if CYTHON_FAST_PYCCALL + } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { + return __Pyx_PyCFunction_FastCall(func, &arg, 1); +#endif } } return __Pyx__PyObject_CallOneArg(func, arg); @@ -4256,10 +5684,15 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec #endif /* PyObjectCallNoArg */ - #if CYTHON_COMPILING_IN_CPYTHON +#if CYTHON_COMPILING_IN_CPYTHON static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { +#if CYTHON_FAST_PYCALL + if (PyFunction_Check(func)) { + return __Pyx_PyFunction_FastCall(func, NULL, 0); + } +#endif #ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { + if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) { #else if (likely(PyCFunction_Check(func))) { #endif @@ -4272,7 +5705,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { #endif /* FetchCommonType */ - static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { + static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) { PyObject* fake_module; PyTypeObject* cached_type = NULL; fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI); @@ -4311,7 +5744,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { } /* CythonFunction */ - static PyObject * + #include +static PyObject * __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure) { if (unlikely(op->func_doc == NULL)) { @@ -4468,7 +5902,7 @@ __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) { PyObject *res = op->defaults_getter((PyObject *) op); if (unlikely(!res)) return -1; - #if CYTHON_COMPILING_IN_CPYTHON + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS op->defaults_tuple = PyTuple_GET_ITEM(res, 0); Py_INCREF(op->defaults_tuple); op->defaults_kwdict = PyTuple_GET_ITEM(res, 1); @@ -4593,7 +6027,7 @@ static PyGetSetDef __pyx_CyFunction_getsets[] = { {0, 0, 0, 0, 0} }; static PyMemberDef __pyx_CyFunction_members[] = { - {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0}, + {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0}, {0, 0, 0, 0, 0} }; static PyObject * @@ -4671,14 +6105,18 @@ __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) } return 0; } -static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) +static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m) { - PyObject_GC_UnTrack(m); if (__Pyx_CyFunction_weakreflist(m) != NULL) PyObject_ClearWeakRefs((PyObject *) m); __Pyx_CyFunction_clear(m); PyObject_GC_Del(m); } +static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) +{ + PyObject_GC_UnTrack(m); + __Pyx__CyFunction_dealloc(m); +} static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) { Py_VISIT(m->func_closure); @@ -4727,11 +6165,9 @@ __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op) PyString_AsString(op->func_qualname), (void *)op); #endif } -#if CYTHON_COMPILING_IN_PYPY -static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { +static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) { PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = f->m_ml->ml_meth; - PyObject *self = f->m_self; Py_ssize_t size; switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) { case METH_VARARGS: @@ -4755,10 +6191,16 @@ static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject if (likely(kw == NULL || PyDict_Size(kw) == 0)) { size = PyTuple_GET_SIZE(arg); if (likely(size == 1)) { - PyObject *result, *arg0 = PySequence_ITEM(arg, 0); - if (unlikely(!arg0)) return NULL; + PyObject *result, *arg0; + #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS + arg0 = PyTuple_GET_ITEM(arg, 0); + #else + arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL; + #endif result = (*meth)(self, arg0); + #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS) Py_DECREF(arg0); + #endif return result; } PyErr_Format(PyExc_TypeError, @@ -4777,11 +6219,32 @@ static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject f->m_ml->ml_name); return NULL; } -#else -static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { - return PyCFunction_Call(func, arg, kw); +static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { + return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw); +} +static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) { + PyObject *result; + __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func; + if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) { + Py_ssize_t argc; + PyObject *new_args; + PyObject *self; + argc = PyTuple_GET_SIZE(args); + new_args = PyTuple_GetSlice(args, 1, argc); + if (unlikely(!new_args)) + return NULL; + self = PyTuple_GetItem(args, 0); + if (unlikely(!self)) { + Py_DECREF(new_args); + return NULL; + } + result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw); + Py_DECREF(new_args); + } else { + result = __Pyx_CyFunction_Call(func, args, kw); + } + return result; } -#endif static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) "cython_function_or_method", @@ -4801,7 +6264,7 @@ static PyTypeObject __pyx_CyFunctionType_type = { 0, 0, 0, - __Pyx_CyFunction_Call, + __Pyx_CyFunction_CallAsMethod, 0, 0, 0, @@ -4843,11 +6306,8 @@ static PyTypeObject __pyx_CyFunctionType_type = { #endif }; static int __pyx_CyFunction_init(void) { -#if !CYTHON_COMPILING_IN_PYPY - __pyx_CyFunctionType_type.tp_call = PyCFunction_Call; -#endif __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type); - if (__pyx_CyFunctionType == NULL) { + if (unlikely(__pyx_CyFunctionType == NULL)) { return -1; } return 0; @@ -4855,7 +6315,7 @@ static int __pyx_CyFunction_init(void) { static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; m->defaults = PyObject_Malloc(size); - if (!m->defaults) + if (unlikely(!m->defaults)) return PyErr_NoMemory(); memset(m->defaults, 0, size); m->defaults_pyobjects = pyobjects; @@ -4877,14 +6337,37 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, Py Py_INCREF(dict); } +/* PyObjectSetAttrStr */ + #if CYTHON_USE_TYPE_SLOTS +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_setattro)) + return tp->tp_setattro(obj, attr_name, value); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_setattr)) + return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); +#endif + return PyObject_SetAttr(obj, attr_name, value); +} +#endif + /* GetModuleGlobalName */ - static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { PyObject *result; -#if CYTHON_COMPILING_IN_CPYTHON +#if !CYTHON_AVOID_BORROWED_REFS +#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 + result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash); + if (likely(result)) { + Py_INCREF(result); + } else if (unlikely(PyErr_Occurred())) { + result = NULL; + } else { +#else result = PyDict_GetItem(__pyx_d, name); if (likely(result)) { Py_INCREF(result); } else { +#endif #else result = PyObject_GetItem(__pyx_d, name); if (!result) { @@ -4895,14 +6378,81 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, Py return result; } +/* decode_c_bytes */ + static CYTHON_INLINE PyObject* __Pyx_decode_c_bytes( + const char* cstring, Py_ssize_t length, Py_ssize_t start, Py_ssize_t stop, + const char* encoding, const char* errors, + PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { + if (unlikely((start < 0) | (stop < 0))) { + if (start < 0) { + start += length; + if (start < 0) + start = 0; + } + if (stop < 0) + stop += length; + } + if (stop > length) + stop = length; + length = stop - start; + if (unlikely(length <= 0)) + return PyUnicode_FromUnicode(NULL, 0); + cstring += start; + if (decode_func) { + return decode_func(cstring, length, errors); + } else { + return PyUnicode_Decode(cstring, length, encoding, errors); + } +} + +/* PyObject_GenericGetAttrNoDict */ + #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000 +static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) { + PyErr_Format(PyExc_AttributeError, +#if PY_MAJOR_VERSION >= 3 + "'%.50s' object has no attribute '%U'", + tp->tp_name, attr_name); +#else + "'%.50s' object has no attribute '%.400s'", + tp->tp_name, PyString_AS_STRING(attr_name)); +#endif + return NULL; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) { + PyObject *descr; + PyTypeObject *tp = Py_TYPE(obj); + if (unlikely(!PyString_Check(attr_name))) { + return PyObject_GenericGetAttr(obj, attr_name); + } + assert(!tp->tp_dictoffset); + descr = _PyType_Lookup(tp, attr_name); + if (unlikely(!descr)) { + return __Pyx_RaiseGenericGetAttributeError(tp, attr_name); + } + Py_INCREF(descr); + #if PY_MAJOR_VERSION < 3 + if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))) + #endif + { + descrgetfunc f = Py_TYPE(descr)->tp_descr_get; + if (unlikely(f)) { + PyObject *res = f(descr, obj, (PyObject *)tp); + Py_DECREF(descr); + return res; + } + } + return descr; +} +#endif + /* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { PyObject *empty_list = 0; PyObject *module = 0; PyObject *global_dict = 0; PyObject *empty_dict = 0; PyObject *list; - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 PyObject *py_import; py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); if (!py_import) @@ -4926,17 +6476,8 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, Py #if PY_MAJOR_VERSION >= 3 if (level == -1) { if (strchr(__Pyx_MODULE_NAME, '.')) { - #if PY_VERSION_HEX < 0x03030000 - PyObject *py_level = PyInt_FromLong(1); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else module = PyImport_ImportModuleLevelObject( name, global_dict, empty_dict, list, 1); - #endif if (!module) { if (!PyErr_ExceptionMatches(PyExc_ImportError)) goto bad; @@ -4947,7 +6488,7 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, Py } #endif if (!module) { - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 PyObject *py_level = PyInt_FromLong(level); if (!py_level) goto bad; @@ -4961,7 +6502,7 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, Py } } bad: - #if PY_VERSION_HEX < 0x03030000 + #if PY_MAJOR_VERSION < 3 Py_XDECREF(py_import); #endif Py_XDECREF(empty_list); @@ -4969,8 +6510,22 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, Py return module; } +/* ImportFrom */ + static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) { + PyObject* value = __Pyx_PyObject_GetAttrStr(module, name); + if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) { + PyErr_Format(PyExc_ImportError, + #if PY_MAJOR_VERSION < 3 + "cannot import name %.230s", PyString_AS_STRING(name)); + #else + "cannot import name %S", name); + #endif + } + return value; +} + /* CalculateMetaclass */ - static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { + static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) { Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases); for (i=0; i < nbases; i++) { PyTypeObject *tmptype; @@ -5009,7 +6564,7 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, Py } /* Py3ClassCreate */ - static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, + static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) { PyObject *ns; if (metaclass) { @@ -5075,8 +6630,48 @@ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObj return result; } +/* CLineInTraceback */ + #ifndef CYTHON_CLINE_IN_TRACEBACK +static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { + PyObject *use_cline; + PyObject *ptype, *pvalue, *ptraceback; +#if CYTHON_COMPILING_IN_CPYTHON + PyObject **cython_runtime_dict; +#endif + if (unlikely(!__pyx_cython_runtime)) { + return c_line; + } + __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); +#if CYTHON_COMPILING_IN_CPYTHON + cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); + if (likely(cython_runtime_dict)) { + use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); + } else +#endif + { + PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); + if (use_cline_obj) { + use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; + Py_DECREF(use_cline_obj); + } else { + PyErr_Clear(); + use_cline = NULL; + } + } + if (!use_cline) { + c_line = 0; + PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); + } + else if (PyObject_Not(use_cline) != 0) { + c_line = 0; + } + __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback); + return c_line; +} +#endif + /* CodeObjectCache */ - static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { int start = 0, mid = 0, end = count - 1; if (end >= 0 && code_line > entries[end].code_line) { return count; @@ -5156,7 +6751,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { } /* AddTraceback */ - #include "compile.h" + #include "compile.h" #include "frameobject.h" #include "traceback.h" static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( @@ -5215,21 +6810,25 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, int py_line, const char *filename) { PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; - py_code = __pyx_find_code_object(c_line ? c_line : py_line); + PyThreadState *tstate = __Pyx_PyThreadState_Current; + if (c_line) { + c_line = __Pyx_CLineForTraceback(tstate, c_line); + } + py_code = __pyx_find_code_object(c_line ? -c_line : py_line); if (!py_code) { py_code = __Pyx_CreateCodeObjectForTraceback( funcname, c_line, py_line, filename); if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); } py_frame = PyFrame_New( - PyThreadState_GET(), /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __pyx_d, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ + tstate, /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ ); if (!py_frame) goto bad; - py_frame->f_lineno = py_line; + __Pyx_PyFrame_SetLineNumber(py_frame, py_line); PyTraceBack_Here(py_frame); bad: Py_XDECREF(py_code); @@ -5237,7 +6836,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; if (is_unsigned) { @@ -5245,14 +6844,18 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return PyInt_FromLong((long) value); } else if (sizeof(long) <= sizeof(unsigned long)) { return PyLong_FromUnsignedLong((unsigned long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); +#endif } } else { if (sizeof(long) <= sizeof(long)) { return PyInt_FromLong((long) value); +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { return PyLong_FromLongLong((PY_LONG_LONG) value); +#endif } } { @@ -5264,7 +6867,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPyVerify */ - #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ + #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0) #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\ __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1) @@ -5286,7 +6889,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { const long neg_one = (long) -1, const_zero = (long) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -5353,8 +6956,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, #endif if (sizeof(long) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif } } else { #if CYTHON_USE_PYLONG_INTERNALS @@ -5421,8 +7026,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, #endif if (sizeof(long) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif } } { @@ -5471,7 +7078,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { const int neg_one = (int) -1, const_zero = (int) 0; const int is_unsigned = neg_one > const_zero; #if PY_MAJOR_VERSION < 3 @@ -5538,8 +7145,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, #endif if (sizeof(int) <= sizeof(unsigned long)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) +#endif } } else { #if CYTHON_USE_PYLONG_INTERNALS @@ -5606,8 +7215,10 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, #endif if (sizeof(int) <= sizeof(long)) { __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x)) +#ifdef HAVE_LONG_LONG } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) +#endif } } { @@ -5655,8 +7266,80 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, return (int) -1; } +/* FastTypeChecks */ + #if CYTHON_COMPILING_IN_CPYTHON +static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { + while (a) { + a = a->tp_base; + if (a == b) + return 1; + } + return b == &PyBaseObject_Type; +} +static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) { + PyObject *mro; + if (a == b) return 1; + mro = a->tp_mro; + if (likely(mro)) { + Py_ssize_t i, n; + n = PyTuple_GET_SIZE(mro); + for (i = 0; i < n; i++) { + if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b) + return 1; + } + return 0; + } + return __Pyx_InBases(a, b); +} +#if PY_MAJOR_VERSION == 2 +static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { + PyObject *exception, *value, *tb; + int res; + __Pyx_PyThreadState_declare + __Pyx_PyThreadState_assign + __Pyx_ErrFetch(&exception, &value, &tb); + res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + if (!res) { + res = PyObject_IsSubclass(err, exc_type2); + if (unlikely(res == -1)) { + PyErr_WriteUnraisable(err); + res = 0; + } + } + __Pyx_ErrRestore(exception, value, tb); + return res; +} +#else +static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { + int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; + if (!res) { + res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); + } + return res; +} +#endif +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { + if (likely(err == exc_type)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); + } + return PyErr_GivenExceptionMatches(err, exc_type); +} +static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { + if (likely(err == exc_type1 || err == exc_type2)) return 1; + if (likely(PyExceptionClass_Check(err))) { + return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); + } + return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); +} +#endif + /* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { + static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); @@ -5672,7 +7355,7 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, } /* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { while (t->p) { #if PY_MAJOR_VERSION < 3 if (t->is_unicode) { @@ -5697,6 +7380,8 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, #endif if (!*t->p) return -1; + if (PyObject_Hash(*t->p) == -1) + return -1; ++t; } return 0; @@ -5705,50 +7390,57 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line, static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); } -static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { +static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) { Py_ssize_t ignore; return __Pyx_PyObject_AsStringAndSize(o, &ignore); } -static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { -#if CYTHON_COMPILING_IN_CPYTHON && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { -#if PY_VERSION_HEX < 0x03030000 - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +#if !CYTHON_PEP393_ENABLED +static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; } } + } #endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +} #else - if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { + if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - if (PyUnicode_IS_ASCII(o)) { - *length = PyUnicode_GET_LENGTH(o); - return PyUnicode_AsUTF8(o); - } else { - PyUnicode_AsASCIIString(o); - return NULL; - } + if (likely(PyUnicode_IS_ASCII(o))) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } #else - return PyUnicode_AsUTF8AndSize(o, length); + return PyUnicode_AsUTF8AndSize(o, length); #endif +} +#endif +#endif +static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && #endif + PyUnicode_Check(o)) { + return __Pyx_PyUnicode_AsStringAndSize(o, length); } else #endif #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) @@ -5772,43 +7464,67 @@ static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { if (is_true | (x == Py_False) | (x == Py_None)) return is_true; else return PyObject_IsTrue(x); } +static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { +#if PY_MAJOR_VERSION >= 3 + if (PyLong_Check(result)) { + if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, + "__int__ returned non-int (type %.200s). " + "The ability to return an instance of a strict subclass of int " + "is deprecated, and may be removed in a future version of Python.", + Py_TYPE(result)->tp_name)) { + Py_DECREF(result); + return NULL; + } + return result; + } +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + type_name, type_name, Py_TYPE(result)->tp_name); + Py_DECREF(result); + return NULL; +} static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { +#if CYTHON_USE_TYPE_SLOTS PyNumberMethods *m; +#endif const char *name = NULL; PyObject *res = NULL; #if PY_MAJOR_VERSION < 3 - if (PyInt_Check(x) || PyLong_Check(x)) + if (likely(PyInt_Check(x) || PyLong_Check(x))) #else - if (PyLong_Check(x)) + if (likely(PyLong_Check(x))) #endif return __Pyx_NewRef(x); +#if CYTHON_USE_TYPE_SLOTS m = Py_TYPE(x)->tp_as_number; -#if PY_MAJOR_VERSION < 3 + #if PY_MAJOR_VERSION < 3 if (m && m->nb_int) { name = "int"; - res = PyNumber_Int(x); + res = m->nb_int(x); } else if (m && m->nb_long) { name = "long"; - res = PyNumber_Long(x); + res = m->nb_long(x); } -#else - if (m && m->nb_int) { + #else + if (likely(m && m->nb_int)) { name = "int"; - res = PyNumber_Long(x); + res = m->nb_int(x); + } + #endif +#else + if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { + res = PyNumber_Int(x); } #endif - if (res) { + if (likely(res)) { #if PY_MAJOR_VERSION < 3 - if (!PyInt_Check(res) && !PyLong_Check(res)) { + if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { #else - if (!PyLong_Check(res)) { + if (unlikely(!PyLong_CheckExact(res))) { #endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - name, name, Py_TYPE(res)->tp_name); - Py_DECREF(res); - return NULL; + return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); } } else if (!PyErr_Occurred()) { @@ -5879,6 +7595,9 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { Py_DECREF(x); return ival; } +static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) { + return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False); +} static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { return PyInt_FromSize_t(ival); } diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index bb89c08..d26b3c5 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -1,8 +1,13 @@ from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL -from chromium_gurl cimport GURL -import urlparse as stdlib_urlparse +from urlparse4.chromium_gurl cimport GURL + +import six +from six.moves.urllib.parse import urljoin as stdlib_urljoin +from six.moves.urllib.parse import urlunsplit as stdlib_urlunsplit + cimport cython + cdef bytes slice_component(bytes pyurl, Component comp): if comp.len <= 0: return b"" @@ -144,23 +149,41 @@ class SplitResultNamedTuple(tuple): cls.__getattr__ = _get_attr - return tuple.__new__(cls, ( - slice_component(url, parsed.scheme).lower(), - build_netloc(url, parsed), - slice_component(url, parsed.path), - slice_component(url, parsed.query), - slice_component(url, parsed.ref) - )) + scheme, netloc, path, query, ref = (slice_component(url, parsed.scheme).lower(), + build_netloc(url, parsed), + slice_component(url, parsed.path), + slice_component(url, parsed.query), + slice_component(url, parsed.ref)) + if six.PY2: + return tuple.__new__(cls, ( + scheme.decode('utf-8'), + netloc.decode('utf-8'), + path.decode('utf-8'), + query.decode('utf-8'), + ref.decode('utf-8') + )) + else: + return tuple.__new__(cls, (scheme, netloc, path, query, ref)) def geturl(self): - return stdlib_urlparse.urlunsplit(self) + return stdlib_urlunsplit(self) +def unicode_handling(str): + cdef bytes bytes_str + if isinstance(str, unicode): + bytes_str = (str).encode('utf8') + else: + bytes_str = str + return bytes_str def urlsplit(url): + url = unicode_handling(url) return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) -def urljoin(bytes base, bytes url, allow_fragments=True): +def urljoin(base, url, allow_fragments=True): + base, url = unicode_handling(base), unicode_handling(url) + if allow_fragments and base: return GURL(base).Resolve(url).spec() else: - return stdlib_urlparse.urljoin(base, url, allow_fragments=allow_fragments) + return stdlib_urljoin(base, url, allow_fragments=allow_fragments)