From 0cad122008e67bc190d84189571d7c09aa056249 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Wed, 6 Jun 2018 17:37:12 -0500 Subject: [PATCH 01/38] import urlparse in py3 --- urlparse4/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/urlparse4/__init__.py b/urlparse4/__init__.py index cb167ba..e873b8e 100644 --- a/urlparse4/__init__.py +++ b/urlparse4/__init__.py @@ -1,6 +1,7 @@ # https://github.com/python/cpython/blob/2.7/Lib/urlparse.py -from urlparse import * +import six +from six.moves.urllib.parse import urlparse, urlsplit, urljoin _original_urlsplit = urlsplit _original_urljoin = urljoin From 71a2a89e20044caf3729875af706b3205503df12 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Wed, 6 Jun 2018 18:09:11 -0500 Subject: [PATCH 02/38] py3 sp in setup.py --- setup.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index ffb8a42..e3b738e 100644 --- a/setup.py +++ b/setup.py @@ -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/gurl.cpp not found and Cython failed to run to recreate it. Please install/upgrade Cython and try again.") raise else: ext_modules = [extension] @@ -83,6 +83,5 @@ "Topic :: Software Development :: Libraries" ], long_description=long_description, - ext_modules=ext_modules, - include_package_data=True + ext_modules=ext_modules ) From 248dd757dd94c7f410de63489a48e11444ceaae2 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 09:16:10 -0500 Subject: [PATCH 03/38] add sp for py3 in cgurl --- urlparse4/__init__.py | 4 ++++ urlparse4/cgurl.pyx | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/urlparse4/__init__.py b/urlparse4/__init__.py index e873b8e..65298c3 100644 --- a/urlparse4/__init__.py +++ b/urlparse4/__init__.py @@ -1,9 +1,13 @@ # https://github.com/python/cpython/blob/2.7/Lib/urlparse.py import six +import pyximport + from six.moves.urllib.parse import urlparse, urlsplit, urljoin + _original_urlsplit = urlsplit _original_urljoin = urljoin +pyximport.install() from cgurl import urlsplit, urljoin diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index bb89c08..f3729c4 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -1,6 +1,8 @@ from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL from chromium_gurl cimport GURL -import urlparse as stdlib_urlparse +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): @@ -153,7 +155,7 @@ class SplitResultNamedTuple(tuple): )) def geturl(self): - return stdlib_urlparse.urlunsplit(self) + return stdlib_urlunsplit(self) def urlsplit(url): @@ -163,4 +165,4 @@ def urljoin(bytes base, bytes url, allow_fragments=True): 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) From 54dc5821e8f43bb3708a8e8919f08aedac66f56d Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 09:39:57 -0500 Subject: [PATCH 04/38] change to relative import --- urlparse4/__init__.py | 2 +- urlparse4/cgurl.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/urlparse4/__init__.py b/urlparse4/__init__.py index 65298c3..bb93ea8 100644 --- a/urlparse4/__init__.py +++ b/urlparse4/__init__.py @@ -10,4 +10,4 @@ _original_urljoin = urljoin pyximport.install() -from cgurl import urlsplit, urljoin +from urlparse4.cgurl import urlsplit, urljoin diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index f3729c4..3b7d8aa 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -1,4 +1,4 @@ -from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL +from urlparse4.urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL from chromium_gurl cimport GURL import six from six.moves.urllib.parse import urljoin as stdlib_urljoin From 6c915a924f682d83bf6cc418c5ac68bca894fe19 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 09:58:13 -0500 Subject: [PATCH 05/38] change the name of the functions to sp py3 --- urlparse4/__init__.py | 2 +- urlparse4/cgurl.pyx | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/urlparse4/__init__.py b/urlparse4/__init__.py index bb93ea8..ca89b0a 100644 --- a/urlparse4/__init__.py +++ b/urlparse4/__init__.py @@ -10,4 +10,4 @@ _original_urljoin = urljoin pyximport.install() -from urlparse4.cgurl import urlsplit, urljoin +from urlparse4.cgurl import url_split, url_join diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index 3b7d8aa..837049a 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -1,6 +1,5 @@ from urlparse4.urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL from 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 @@ -158,10 +157,10 @@ class SplitResultNamedTuple(tuple): return stdlib_urlunsplit(self) -def urlsplit(url): +def url_split(url): return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) -def urljoin(bytes base, bytes url, allow_fragments=True): +def url_join(bytes base, bytes url, allow_fragments=True): if allow_fragments and base: return GURL(base).Resolve(url).spec() else: From a2f09b0fd4f76e097bdeabc9b12768ddf8e649ef Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 10:08:30 -0500 Subject: [PATCH 06/38] correct print command --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e3b738e..ac2d9c5 100644 --- a/setup.py +++ b/setup.py @@ -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] From 9e086f6113db3b28f2a2f07435f4136a1bae5df8 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 10:13:58 -0500 Subject: [PATCH 07/38] fix the build error --- setup.py | 2 +- urlparse4/cgurl.cpp | 2629 ++++++++++++++++++++++++++++++------------- urlparse4/cgurl.pyx | 4 +- 3 files changed, 1873 insertions(+), 762 deletions(-) diff --git a/setup.py b/setup.py index ac2d9c5..afaa32e 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", diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index c9a452c..b311b86 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":112 * __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,46 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr /* GetModuleGlobalName.proto */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); +/* 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 +1212,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,20 +1244,21 @@ 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_cls[] = "cls"; @@ -891,6 +1273,7 @@ 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__"; @@ -908,19 +1291,21 @@ 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_url_join[] = "url_join"; static const char __pyx_k_username[] = "username"; static const char __pyx_k_metaclass[] = "__metaclass__"; +static const char __pyx_k_url_split[] = "url_split"; 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_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_SplitResultNamedTuple; @@ -930,8 +1315,9 @@ 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_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_doc; static PyObject *__pyx_kp_b_file; static PyObject *__pyx_n_s_fragment; @@ -956,22 +1342,24 @@ static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_n_s_query; static PyObject *__pyx_n_s_scheme; static PyObject *__pyx_n_s_self; +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_test; static PyObject *__pyx_n_s_url; +static PyObject *__pyx_n_s_url_join; +static PyObject *__pyx_n_s_url_split; static PyObject *__pyx_n_s_urljoin; -static PyObject *__pyx_n_s_urlparse; -static PyObject *__pyx_n_s_urlparse4_cgurl; -static PyObject *__pyx_n_s_urlsplit; +static PyObject *__pyx_kp_s_urlparse4_cgurl_pyx; 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_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_url_split(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url); /* proto */ +static PyObject *__pyx_pf_5cgurl_2url_join(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; @@ -983,8 +1371,9 @@ static PyObject *__pyx_codeobj__5; static PyObject *__pyx_codeobj__7; static PyObject *__pyx_codeobj__9; static PyObject *__pyx_codeobj__11; +/* Late includes */ -/* "urlparse4/cgurl.pyx":6 +/* "cgurl.pyx":7 * cimport cython * * cdef bytes slice_component(bytes pyurl, Component comp): # <<<<<<<<<<<<<< @@ -992,14 +1381,14 @@ static PyObject *__pyx_codeobj__11; * 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":8 * * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1009,7 +1398,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":9 * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1021,7 +1410,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":8 * * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1030,7 +1419,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyu */ } - /* "urlparse4/cgurl.pyx":10 + /* "cgurl.pyx":11 * return b"" * * return pyurl[comp.begin:comp.begin + comp.len] # <<<<<<<<<<<<<< @@ -1040,15 +1429,15 @@ 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, 11, __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, 11, __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 + /* "cgurl.pyx":7 * cimport cython * * cdef bytes slice_component(bytes pyurl, Component comp): # <<<<<<<<<<<<<< @@ -1059,7 +1448,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 +1456,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_slice_component(PyObject *__pyx_v_pyu return __pyx_r; } -/* "urlparse4/cgurl.pyx":13 +/* "cgurl.pyx":14 * * * cdef bytes cslice_component(char * url, Component comp): # <<<<<<<<<<<<<< @@ -1075,14 +1464,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":15 * * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1092,7 +1481,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":16 * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1104,7 +1493,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":15 * * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1113,7 +1502,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":18 + /* "cgurl.pyx":19 * * # TODO: check if std::string brings any speedups * return url[comp.begin:comp.begin + comp.len] # <<<<<<<<<<<<<< @@ -1121,13 +1510,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, 19, __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":14 * * * cdef bytes cslice_component(char * url, Component comp): # <<<<<<<<<<<<<< @@ -1138,7 +1527,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 +1535,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_cslice_component(char *__pyx_v_url, s return __pyx_r; } -/* "urlparse4/cgurl.pyx":21 +/* "cgurl.pyx":22 * * * cdef bytes build_netloc(bytes url, Parsed parsed): # <<<<<<<<<<<<<< @@ -1154,7 +1543,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 +1551,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":24 * cdef bytes build_netloc(bytes url, Parsed parsed): * * if parsed.host.len <= 0: # <<<<<<<<<<<<<< @@ -1172,7 +1561,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":25 * * if parsed.host.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1184,7 +1573,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":24 * cdef bytes build_netloc(bytes url, Parsed parsed): * * if parsed.host.len <= 0: # <<<<<<<<<<<<<< @@ -1193,7 +1582,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":27 + /* "cgurl.pyx":28 * * # Nothing at all * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1217,7 +1606,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":29 * # 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 +1616,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, 29, __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, 29, __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":28 * * # Nothing at all * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1244,7 +1633,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":31 + /* "cgurl.pyx":32 * * # Only port * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1268,7 +1657,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":33 * # 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 +1667,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, 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) + 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, 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":31 + /* "cgurl.pyx":32 * * # Only port * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1295,7 +1684,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":35 + /* "cgurl.pyx":36 * * # Only username * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1319,7 +1708,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":37 * # 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 +1718,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, 37, __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, 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":35 + /* "cgurl.pyx":36 * * # Only username * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1346,7 +1735,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":39 + /* "cgurl.pyx":40 * * # Username + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1370,7 +1759,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":41 * # 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 +1769,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, 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) + 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, 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":39 + /* "cgurl.pyx":40 * * # Username + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1397,7 +1786,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":43 + /* "cgurl.pyx":44 * * # Username + port * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1421,7 +1810,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":45 * # 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 +1820,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, 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.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, 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":43 + /* "cgurl.pyx":44 * * # Username + port * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1448,7 +1837,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":47 + /* "cgurl.pyx":48 * * # Username + port + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1470,9 +1859,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":49 * # 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 +1871,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, 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) + 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, 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":47 + /* "cgurl.pyx":48 * * # Username + port + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1499,7 +1888,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s */ } - /* "urlparse4/cgurl.pyx":51 + /* "cgurl.pyx":52 * * else: * raise ValueError # <<<<<<<<<<<<<< @@ -1508,10 +1897,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, 52, __pyx_L1_error) } - /* "urlparse4/cgurl.pyx":21 + /* "cgurl.pyx":22 * * * cdef bytes build_netloc(bytes url, Parsed parsed): # <<<<<<<<<<<<<< @@ -1522,7 +1911,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 +1919,7 @@ static PyObject *__pyx_f_9urlparse4_5cgurl_build_netloc(PyObject *__pyx_v_url, s return __pyx_r; } -/* "urlparse4/cgurl.pyx":111 +/* "cgurl.pyx":112 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -1539,9 +1928,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 +1944,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, 112, __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, 112, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -1584,14 +1976,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, 112, __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, 112, __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 +1994,7 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_21SplitResultNamedTuple_1__new__(PyO return __pyx_r; } -/* "urlparse4/cgurl.pyx":120 +/* "cgurl.pyx":121 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< @@ -1611,9 +2003,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 +2019,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, 121, __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, 121, __pyx_L3_error) } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -1656,22 +2051,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, 121, __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 +2075,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":122 * * 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, 122, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":122 + /* "cgurl.pyx":123 * def _get_attr(self, prop): * if prop == "scheme": * return self[0] # <<<<<<<<<<<<<< @@ -1701,13 +2096,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, 123, __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":122 * * def _get_attr(self, prop): * if prop == "scheme": # <<<<<<<<<<<<<< @@ -1716,17 +2111,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":123 + /* "cgurl.pyx":124 * 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, 124, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":124 + /* "cgurl.pyx":125 * return self[0] * elif prop == "netloc": * return self[1] # <<<<<<<<<<<<<< @@ -1734,13 +2129,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, 125, __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":124 * if prop == "scheme": * return self[0] * elif prop == "netloc": # <<<<<<<<<<<<<< @@ -1749,17 +2144,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":125 + /* "cgurl.pyx":126 * 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, 126, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":126 + /* "cgurl.pyx":127 * return self[1] * elif prop == "path": * return self[2] # <<<<<<<<<<<<<< @@ -1767,13 +2162,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, 127, __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":126 * elif prop == "netloc": * return self[1] * elif prop == "path": # <<<<<<<<<<<<<< @@ -1782,17 +2177,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":127 + /* "cgurl.pyx":128 * 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, 128, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":128 + /* "cgurl.pyx":129 * return self[2] * elif prop == "query": * return self[3] # <<<<<<<<<<<<<< @@ -1800,13 +2195,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, 129, __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":128 * elif prop == "path": * return self[2] * elif prop == "query": # <<<<<<<<<<<<<< @@ -1815,17 +2210,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":129 + /* "cgurl.pyx":130 * 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, 130, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":130 + /* "cgurl.pyx":131 * return self[3] * elif prop == "fragment": * return self[4] # <<<<<<<<<<<<<< @@ -1833,13 +2228,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, 131, __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":130 * elif prop == "query": * return self[3] * elif prop == "fragment": # <<<<<<<<<<<<<< @@ -1848,17 +2243,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":131 + /* "cgurl.pyx":132 * 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, 132, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":132 + /* "cgurl.pyx":133 * return self[4] * elif prop == "port": * if parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1868,38 +2263,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":134 * 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, 134, __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, 134, __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, 134, __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":135 * 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, 135, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":135 + /* "cgurl.pyx":136 * port = int(slice_component(url, parsed.port)) * if port <= 65535: * return port # <<<<<<<<<<<<<< @@ -1911,7 +2306,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":135 * if parsed.port.len > 0: * port = int(slice_component(url, parsed.port)) * if port <= 65535: # <<<<<<<<<<<<<< @@ -1920,7 +2315,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":132 + /* "cgurl.pyx":133 * return self[4] * elif prop == "port": * if parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1929,7 +2324,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":131 + /* "cgurl.pyx":132 * elif prop == "fragment": * return self[4] * elif prop == "port": # <<<<<<<<<<<<<< @@ -1939,17 +2334,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge goto __pyx_L3; } - /* "urlparse4/cgurl.pyx":137 + /* "cgurl.pyx":138 * 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, 138, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":138 + /* "cgurl.pyx":139 * * elif prop == "username": * return slice_component(url, parsed.username) or None # <<<<<<<<<<<<<< @@ -1957,13 +2352,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, 139, __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, 139, __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, 139, __pyx_L1_error) if (!__pyx_t_1) { __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else { @@ -1979,7 +2374,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":137 + /* "cgurl.pyx":138 * return port * * elif prop == "username": # <<<<<<<<<<<<<< @@ -1988,17 +2383,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":139 + /* "cgurl.pyx":140 * 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, 140, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":140 + /* "cgurl.pyx":141 * return slice_component(url, parsed.username) or None * elif prop == "password": * return slice_component(url, parsed.password) or None # <<<<<<<<<<<<<< @@ -2006,13 +2401,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, 141, __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, 141, __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, 141, __pyx_L1_error) if (!__pyx_t_1) { __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { @@ -2028,7 +2423,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":139 + /* "cgurl.pyx":140 * elif prop == "username": * return slice_component(url, parsed.username) or None * elif prop == "password": # <<<<<<<<<<<<<< @@ -2037,17 +2432,17 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge */ } - /* "urlparse4/cgurl.pyx":141 + /* "cgurl.pyx":142 * 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, 142, __pyx_L1_error) if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":142 + /* "cgurl.pyx":143 * return slice_component(url, parsed.password) or None * elif prop == "hostname": * return slice_component(url, parsed.host).lower() # <<<<<<<<<<<<<< @@ -2055,17 +2450,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, 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.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, 143, __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, 143, __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 +2470,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, 143, __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, 143, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -2086,7 +2481,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge __pyx_t_2 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":141 + /* "cgurl.pyx":142 * elif prop == "password": * return slice_component(url, parsed.password) or None * elif prop == "hostname": # <<<<<<<<<<<<<< @@ -2096,7 +2491,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge } __pyx_L3:; - /* "urlparse4/cgurl.pyx":120 + /* "cgurl.pyx":121 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< @@ -2111,7 +2506,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 +2515,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_7__new____ge return __pyx_r; } -/* "urlparse4/cgurl.pyx":111 +/* "cgurl.pyx":112 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -2128,8 +2523,8 @@ 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_r = NULL; __Pyx_RefNannyDeclarations @@ -2146,18 +2541,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, 112, __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":116 * cdef Parsed parsed * * if url[0:5] == b"file:": # <<<<<<<<<<<<<< @@ -2166,34 +2564,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, 116, __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, 116, __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, 116, __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":117 * * 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, 117, __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, 117, __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, 117, __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, 117, __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":116 * cdef Parsed parsed * * if url[0:5] == b"file:": # <<<<<<<<<<<<<< @@ -2203,7 +2605,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH goto __pyx_L3; } - /* "urlparse4/cgurl.pyx":118 + /* "cgurl.pyx":119 * ParseFileURL(url, len(url), &parsed) * else: * ParseStandardURL(url, len(url), &parsed) # <<<<<<<<<<<<<< @@ -2211,41 +2613,45 @@ 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, 119, __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, 119, __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, 119, __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, 119, __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":121 * 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, 121, __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":146 * * * cls.__getattr__ = _get_attr # <<<<<<<<<<<<<< * * return tuple.__new__(cls, ( */ - 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, 146, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":147 + /* "cgurl.pyx":148 * cls.__getattr__ = _get_attr * * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< @@ -2253,10 +2659,10 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH * build_netloc(url, parsed), */ __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_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 148, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); - /* "urlparse4/cgurl.pyx":148 + /* "cgurl.pyx":149 * * return tuple.__new__(cls, ( * slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< @@ -2265,14 +2671,14 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH */ __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_t_10 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 149, __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_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_lower); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 149, __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))) { + if (CYTHON_UNPACK_METHODS && 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); @@ -2282,15 +2688,15 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH } } 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_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 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_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error) } __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "urlparse4/cgurl.pyx":149 + /* "cgurl.pyx":150 * return tuple.__new__(cls, ( * slice_component(url, parsed.scheme).lower(), * build_netloc(url, parsed), # <<<<<<<<<<<<<< @@ -2299,11 +2705,11 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH */ __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_t_10 = __pyx_f_5cgurl_build_netloc(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 150, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "urlparse4/cgurl.pyx":150 + /* "cgurl.pyx":151 * slice_component(url, parsed.scheme).lower(), * build_netloc(url, parsed), * slice_component(url, parsed.path), # <<<<<<<<<<<<<< @@ -2312,11 +2718,11 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH */ __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_t_11 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 151, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "urlparse4/cgurl.pyx":151 + /* "cgurl.pyx":152 * build_netloc(url, parsed), * slice_component(url, parsed.path), * slice_component(url, parsed.query), # <<<<<<<<<<<<<< @@ -2325,11 +2731,11 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH */ __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_t_12 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "urlparse4/cgurl.pyx":152 + /* "cgurl.pyx":153 * slice_component(url, parsed.path), * slice_component(url, parsed.query), * slice_component(url, parsed.ref) # <<<<<<<<<<<<<< @@ -2338,18 +2744,18 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH */ __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_t_13 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 153, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "urlparse4/cgurl.pyx":148 + /* "cgurl.pyx":149 * * 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_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 149, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); @@ -2367,37 +2773,57 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH __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_14 = 0; + if (CYTHON_UNPACK_METHODS && 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; + __pyx_t_14 = 1; } } - __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; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_cls, __pyx_t_9}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { + PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_cls, __pyx_t_9}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } else + #endif + { + __pyx_t_12 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 148, __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_9); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_14, __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, 148, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; } - __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":112 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -2415,7 +2841,7 @@ 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); @@ -2425,29 +2851,29 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple___new__(CYTH return __pyx_r; } -/* "urlparse4/cgurl.pyx":155 +/* "cgurl.pyx":156 * )) * * 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 +2882,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":157 * * def geturl(self): - * return stdlib_urlparse.urlunsplit(self) # <<<<<<<<<<<<<< + * return stdlib_urlunsplit(self) # <<<<<<<<<<<<<< * * */ __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, 157, __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, 157, __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, 157, __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, 157, __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, 157, __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, 157, __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":156 * )) * * def geturl(self): # <<<<<<<<<<<<<< - * return stdlib_urlparse.urlunsplit(self) + * return stdlib_urlunsplit(self) * */ @@ -2512,7 +2953,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,57 +2961,57 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_21SplitResultNamedTuple_2geturl(CYTH return __pyx_r; } -/* "urlparse4/cgurl.pyx":159 +/* "cgurl.pyx":160 * * - * def urlsplit(url): # <<<<<<<<<<<<<< + * def url_split(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_1url_split(PyObject *__pyx_self, PyObject *__pyx_v_url); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_1url_split = {"url_split", (PyCFunction)__pyx_pw_5cgurl_1url_split, METH_O, 0}; +static PyObject *__pyx_pw_5cgurl_1url_split(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_RefNannySetupContext("url_split (wrapper)", 0); + __pyx_r = __pyx_pf_5cgurl_url_split(__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_url_split(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_RefNannySetupContext("url_split", 0); - /* "urlparse4/cgurl.pyx":160 + /* "cgurl.pyx":161 * - * def urlsplit(url): + * def url_split(url): * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) # <<<<<<<<<<<<<< * - * def urljoin(bytes base, bytes url, allow_fragments=True): + * def url_join(bytes base, bytes 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, 161, __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_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_new); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __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, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = NULL; __pyx_t_5 = 0; - if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + if (CYTHON_UNPACK_METHODS && 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); @@ -2580,29 +3021,49 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__p __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; + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_url}; + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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_3)) { + PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_url}; + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 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, 161, __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, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } - __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; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":159 + /* "cgurl.pyx":160 * * - * def urlsplit(url): # <<<<<<<<<<<<<< + * def url_split(url): # <<<<<<<<<<<<<< * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * */ @@ -2614,7 +3075,7 @@ 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.url_split", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2622,24 +3083,24 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__p return __pyx_r; } -/* "urlparse4/cgurl.pyx":162 +/* "cgurl.pyx":163 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< + * def url_join(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ /* 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_3url_join(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_3url_join = {"url_join", (PyCFunction)__pyx_pw_5cgurl_3url_join, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5cgurl_3url_join(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; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("urljoin (wrapper)", 0); + __Pyx_RefNannySetupContext("url_join (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_base,&__pyx_n_s_url,&__pyx_n_s_allow_fragments,0}; PyObject* values[3] = {0,0,0}; @@ -2649,33 +3110,39 @@ 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("url_join", 0, 2, 3, 1); __PYX_ERR(0, 163, __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, "url_join") < 0)) __PYX_ERR(0, 163, __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; @@ -2688,15 +3155,15 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_3urljoin(PyObject *__pyx_self, PyObj } 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("url_join", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("urlparse4.cgurl.urljoin", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.url_join", __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); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyBytes_Type), 1, "base", 1))) __PYX_ERR(0, 163, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_r = __pyx_pf_5cgurl_2url_join(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); /* function exit code */ goto __pyx_L0; @@ -2707,7 +3174,7 @@ static PyObject *__pyx_pw_9urlparse4_5cgurl_3urljoin(PyObject *__pyx_self, PyObj 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_2url_join(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; @@ -2718,88 +3185,85 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__p PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("urljoin", 0); + __Pyx_RefNannySetupContext("url_join", 0); - /* "urlparse4/cgurl.pyx":163 + /* "cgurl.pyx":164 * - * def urljoin(bytes base, bytes url, allow_fragments=True): + * def url_join(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) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_allow_fragments); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 164, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L4_bool_binop_done; } - __pyx_t_2 = (__pyx_v_base != Py_None) && (PyBytes_GET_SIZE(__pyx_v_base) != 0); + __pyx_t_2 = (__pyx_v_base != Py_None)&&(PyBytes_GET_SIZE(__pyx_v_base) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "urlparse4/cgurl.pyx":164 - * def urljoin(bytes base, bytes url, allow_fragments=True): + /* "cgurl.pyx":165 + * def url_join(bytes base, bytes url, allow_fragments=True): * 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_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_v_base); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __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, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "urlparse4/cgurl.pyx":163 + /* "cgurl.pyx":164 * - * def urljoin(bytes base, bytes url, allow_fragments=True): + * def url_join(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":167 * 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_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 167, __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_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 167, __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_INCREF(__pyx_v_base); __Pyx_GIVEREF(__pyx_v_base); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_base); + PyTuple_SET_ITEM(__pyx_t_6, 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) + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_url); + __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 167, __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) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_allow_fragments, __pyx_v_allow_fragments) < 0) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 167, __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_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_r = __pyx_t_8; __pyx_t_8 = 0; goto __pyx_L0; } - /* "urlparse4/cgurl.pyx":162 + /* "cgurl.pyx":163 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< + * def url_join(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ @@ -2810,7 +3274,7 @@ static PyObject *__pyx_pf_9urlparse4_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__p __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.url_join", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -2823,30 +3287,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 +3323,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 +3354,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 +3401,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 +3448,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 +3495,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 +3569,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 +3585,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 +3638,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 +3658,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 */ @@ -3219,8 +3698,9 @@ 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_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_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}, @@ -3245,20 +3725,22 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 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_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_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_url, __pyx_k_url, sizeof(__pyx_k_url), 0, 0, 1, 1}, + {&__pyx_n_s_url_join, __pyx_k_url_join, sizeof(__pyx_k_url_join), 0, 0, 1, 1}, + {&__pyx_n_s_url_split, __pyx_k_url_split, sizeof(__pyx_k_url_split), 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_n_s_urlsplit, __pyx_k_urlsplit, sizeof(__pyx_k_urlsplit), 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_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}, {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, 52, __pyx_L1_error) return 0; __pyx_L1_error:; return -1; @@ -3268,65 +3750,65 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "urlparse4/cgurl.pyx":120 + /* "cgurl.pyx":121 * 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, 121, __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, 121, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 121, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":111 + /* "cgurl.pyx":112 * __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_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, 112, __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_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_new, 112, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 112, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":155 + /* "cgurl.pyx":156 * )) * * 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_tuple__6 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 156, __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_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_geturl, 156, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 156, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":159 + /* "cgurl.pyx":160 * * - * def urlsplit(url): # <<<<<<<<<<<<<< + * def url_split(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_tuple__8 = PyTuple_Pack(1, __pyx_n_s_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 160, __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_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_url_split, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 160, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":162 + /* "cgurl.pyx":163 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< + * def url_join(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __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_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, 163, __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_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_url_join, 163, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -3342,12 +3824,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, 112, __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 -PyMODINIT_FUNC initcgurl(void); /*proto*/ -PyMODINIT_FUNC initcgurl(void) +#ifdef CYTHON_NO_PYINIT_EXPORT +#define __Pyx_PyMODINIT_FUNC void #else -PyMODINIT_FUNC PyInit_cgurl(void); /*proto*/ -PyMODINIT_FUNC PyInit_cgurl(void) +#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 +__Pyx_PyMODINIT_FUNC initcgurl(void) CYTHON_SMALL_CODE; /*proto*/ +__Pyx_PyMODINIT_FUNC initcgurl(void) +#else +__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 +3976,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 +4007,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 +4021,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 +4045,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 +4060,156 @@ 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 + /* "cgurl.pyx":3 * 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 + * 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 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __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, 3, __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, 3, __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, 3, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "cgurl.pyx":4 + * from urlparse4.chromium_gurl cimport GURL + * 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, 4, __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, 4, __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, 4, __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, 4, __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":108 * * * 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, 108, __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, 108, __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, 108, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - /* "urlparse4/cgurl.pyx":109 + /* "cgurl.pyx":110 * 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, 110, __pyx_L1_error) - /* "urlparse4/cgurl.pyx":111 + /* "cgurl.pyx":112 * __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__5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __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, 112, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "urlparse4/cgurl.pyx":155 + /* "cgurl.pyx":156 * )) * * 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__7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __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, 156, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "urlparse4/cgurl.pyx":107 + /* "cgurl.pyx":108 * * * 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, 108, __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, 108, __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":160 * * - * def urlsplit(url): # <<<<<<<<<<<<<< + * def url_split(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_1url_split, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __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_url_split, __pyx_t_1) < 0) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "urlparse4/cgurl.pyx":162 + /* "cgurl.pyx":163 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< + * def url_join(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __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_3url_join, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __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_url_join, __pyx_t_1) < 0) __PYX_ERR(0, 163, __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 + * from six.moves.urllib.parse import urljoin as stdlib_urljoin */ - __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 +4232,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 +4267,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 +4296,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 +4435,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 +4463,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 +4479,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 +4505,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 +4519,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 +4621,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 +4660,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 +4689,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 +4729,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 +4788,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 +4798,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 +4816,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 +4834,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 +4875,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 +5043,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 +5063,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 +5075,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 +5103,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 +5124,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 +5163,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 +5321,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 +5446,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 +5524,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 +5584,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 +5610,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 +5638,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 +5683,7 @@ static PyTypeObject __pyx_CyFunctionType_type = { 0, 0, 0, - __Pyx_CyFunction_Call, + __Pyx_CyFunction_CallAsMethod, 0, 0, 0, @@ -4843,11 +5725,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 +5734,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 +5756,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 +5797,54 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, Py return result; } +/* 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 +5868,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 +5880,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 +5894,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 +5902,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 +5956,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 +6022,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 +6143,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 +6202,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 +6228,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 +6236,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 +6259,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 +6281,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 +6348,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 +6418,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 +6470,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 +6537,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 +6607,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 +6658,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 +6747,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 +6772,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 +6782,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 +6856,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 +6987,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 837049a..8c7109a 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -1,5 +1,5 @@ -from urlparse4.urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL -from chromium_gurl cimport GURL +from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL +from urlparse4.chromium_gurl cimport GURL from six.moves.urllib.parse import urljoin as stdlib_urljoin from six.moves.urllib.parse import urlunsplit as stdlib_urlunsplit cimport cython From 9c8a185323bcdd2a78a09ac2d08b5a64dc965a01 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 11:29:20 -0500 Subject: [PATCH 08/38] fix the import error --- urlparse4/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/urlparse4/__init__.py b/urlparse4/__init__.py index ca89b0a..851850d 100644 --- a/urlparse4/__init__.py +++ b/urlparse4/__init__.py @@ -1,7 +1,6 @@ # https://github.com/python/cpython/blob/2.7/Lib/urlparse.py import six -import pyximport from six.moves.urllib.parse import urlparse, urlsplit, urljoin @@ -9,5 +8,4 @@ _original_urlsplit = urlsplit _original_urljoin = urljoin -pyximport.install() -from urlparse4.cgurl import url_split, url_join +from cgurl import url_split, url_join From b40fbc74e0df3cb2ff0612da6ef5985903a3842d Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 11:52:09 -0500 Subject: [PATCH 09/38] put include_package_data back --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index afaa32e..69dfde3 100644 --- a/setup.py +++ b/setup.py @@ -83,5 +83,6 @@ "Topic :: Software Development :: Libraries" ], long_description=long_description, - ext_modules=ext_modules + ext_modules=ext_modules, + include_package_data=True ) From 888a3bfe8dba7a4eb7a33e3725f712d5068c0bc8 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 12:09:29 -0500 Subject: [PATCH 10/38] change the function names back --- urlparse4/__init__.py | 2 +- urlparse4/cgurl.pyx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/urlparse4/__init__.py b/urlparse4/__init__.py index 851850d..1e39e03 100644 --- a/urlparse4/__init__.py +++ b/urlparse4/__init__.py @@ -8,4 +8,4 @@ _original_urlsplit = urlsplit _original_urljoin = urljoin -from cgurl import url_split, url_join +from cgurl import urlsplit, urljoin diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index 8c7109a..eaeeafe 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -157,10 +157,10 @@ class SplitResultNamedTuple(tuple): return stdlib_urlunsplit(self) -def url_split(url): +def urlsplit(url): return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) -def url_join(bytes base, bytes url, allow_fragments=True): +def urljoin(bytes base, bytes url, allow_fragments=True): if allow_fragments and base: return GURL(base).Resolve(url).spec() else: From 746d27184eaa2a46d6507fd78dfe24e174d7e329 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 12:09:37 -0500 Subject: [PATCH 11/38] rebuild cython --- urlparse4/cgurl.cpp | 91 ++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index b311b86..3d9fe12 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -1291,10 +1291,9 @@ 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_url_join[] = "url_join"; +static const char __pyx_k_urlsplit[] = "urlsplit"; static const char __pyx_k_username[] = "username"; static const char __pyx_k_metaclass[] = "__metaclass__"; -static const char __pyx_k_url_split[] = "url_split"; static const char __pyx_k_ValueError[] = "ValueError"; static const char __pyx_k_urlunsplit[] = "urlunsplit"; static const char __pyx_k_stdlib_urljoin[] = "stdlib_urljoin"; @@ -1348,17 +1347,16 @@ static PyObject *__pyx_n_s_stdlib_urljoin; static PyObject *__pyx_n_s_stdlib_urlunsplit; static PyObject *__pyx_n_s_test; static PyObject *__pyx_n_s_url; -static PyObject *__pyx_n_s_url_join; -static PyObject *__pyx_n_s_url_split; static PyObject *__pyx_n_s_urljoin; 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_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_url_split(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url); /* proto */ -static PyObject *__pyx_pf_5cgurl_2url_join(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_base, PyObject *__pyx_v_url, PyObject *__pyx_v_allow_fragments); /* proto */ +static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url); /* proto */ +static PyObject *__pyx_pf_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_5cgurl___pyx_scope_struct____new__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_int_65535; static PyObject *__pyx_tuple__2; @@ -2964,26 +2962,26 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P /* "cgurl.pyx":160 * * - * def url_split(url): # <<<<<<<<<<<<<< + * def urlsplit(url): # <<<<<<<<<<<<<< * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * */ /* Python wrapper */ -static PyObject *__pyx_pw_5cgurl_1url_split(PyObject *__pyx_self, PyObject *__pyx_v_url); /*proto*/ -static PyMethodDef __pyx_mdef_5cgurl_1url_split = {"url_split", (PyCFunction)__pyx_pw_5cgurl_1url_split, METH_O, 0}; -static PyObject *__pyx_pw_5cgurl_1url_split(PyObject *__pyx_self, PyObject *__pyx_v_url) { +static PyObject *__pyx_pw_5cgurl_1urlsplit(PyObject *__pyx_self, PyObject *__pyx_v_url); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_1urlsplit = {"urlsplit", (PyCFunction)__pyx_pw_5cgurl_1urlsplit, METH_O, 0}; +static PyObject *__pyx_pw_5cgurl_1urlsplit(PyObject *__pyx_self, PyObject *__pyx_v_url) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("url_split (wrapper)", 0); - __pyx_r = __pyx_pf_5cgurl_url_split(__pyx_self, ((PyObject *)__pyx_v_url)); + __Pyx_RefNannySetupContext("urlsplit (wrapper)", 0); + __pyx_r = __pyx_pf_5cgurl_urlsplit(__pyx_self, ((PyObject *)__pyx_v_url)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_5cgurl_url_split(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) { +static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -2992,14 +2990,14 @@ static PyObject *__pyx_pf_5cgurl_url_split(CYTHON_UNUSED PyObject *__pyx_self, P PyObject *__pyx_t_4 = NULL; int __pyx_t_5; PyObject *__pyx_t_6 = NULL; - __Pyx_RefNannySetupContext("url_split", 0); + __Pyx_RefNannySetupContext("urlsplit", 0); /* "cgurl.pyx":161 * - * def url_split(url): + * def urlsplit(url): * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) # <<<<<<<<<<<<<< * - * def url_join(bytes base, bytes url, allow_fragments=True): + * def urljoin(bytes base, bytes 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, 161, __pyx_L1_error) @@ -3063,7 +3061,7 @@ static PyObject *__pyx_pf_5cgurl_url_split(CYTHON_UNUSED PyObject *__pyx_self, P /* "cgurl.pyx":160 * * - * def url_split(url): # <<<<<<<<<<<<<< + * def urlsplit(url): # <<<<<<<<<<<<<< * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * */ @@ -3075,7 +3073,7 @@ static PyObject *__pyx_pf_5cgurl_url_split(CYTHON_UNUSED PyObject *__pyx_self, P __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("cgurl.url_split", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.urlsplit", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3086,21 +3084,21 @@ static PyObject *__pyx_pf_5cgurl_url_split(CYTHON_UNUSED PyObject *__pyx_self, P /* "cgurl.pyx":163 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def url_join(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< + * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ /* Python wrapper */ -static PyObject *__pyx_pw_5cgurl_3url_join(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5cgurl_3url_join = {"url_join", (PyCFunction)__pyx_pw_5cgurl_3url_join, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_5cgurl_3url_join(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_5cgurl_3urljoin = {"urljoin", (PyCFunction)__pyx_pw_5cgurl_3urljoin, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_5cgurl_3urljoin(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; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("url_join (wrapper)", 0); + __Pyx_RefNannySetupContext("urljoin (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_base,&__pyx_n_s_url,&__pyx_n_s_allow_fragments,0}; PyObject* values[3] = {0,0,0}; @@ -3127,7 +3125,7 @@ static PyObject *__pyx_pw_5cgurl_3url_join(PyObject *__pyx_self, PyObject *__pyx case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_url)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("url_join", 0, 2, 3, 1); __PYX_ERR(0, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, 1); __PYX_ERR(0, 163, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -3137,7 +3135,7 @@ static PyObject *__pyx_pw_5cgurl_3url_join(PyObject *__pyx_self, PyObject *__pyx } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "url_join") < 0)) __PYX_ERR(0, 163, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 163, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3155,15 +3153,15 @@ static PyObject *__pyx_pw_5cgurl_3url_join(PyObject *__pyx_self, PyObject *__pyx } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("url_join", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error) __pyx_L3_error:; - __Pyx_AddTraceback("cgurl.url_join", __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, 163, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 163, __pyx_L1_error) - __pyx_r = __pyx_pf_5cgurl_2url_join(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); + __pyx_r = __pyx_pf_5cgurl_2urljoin(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); /* function exit code */ goto __pyx_L0; @@ -3174,7 +3172,7 @@ static PyObject *__pyx_pw_5cgurl_3url_join(PyObject *__pyx_self, PyObject *__pyx return __pyx_r; } -static PyObject *__pyx_pf_5cgurl_2url_join(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_base, PyObject *__pyx_v_url, PyObject *__pyx_v_allow_fragments) { +static PyObject *__pyx_pf_5cgurl_2urljoin(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; @@ -3185,11 +3183,11 @@ static PyObject *__pyx_pf_5cgurl_2url_join(CYTHON_UNUSED PyObject *__pyx_self, P PyObject *__pyx_t_6 = NULL; PyObject *__pyx_t_7 = NULL; PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("url_join", 0); + __Pyx_RefNannySetupContext("urljoin", 0); /* "cgurl.pyx":164 * - * def url_join(bytes base, bytes url, allow_fragments=True): + * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: # <<<<<<<<<<<<<< * return GURL(base).Resolve(url).spec() * else: @@ -3206,7 +3204,7 @@ static PyObject *__pyx_pf_5cgurl_2url_join(CYTHON_UNUSED PyObject *__pyx_self, P if (__pyx_t_1) { /* "cgurl.pyx":165 - * def url_join(bytes base, bytes url, allow_fragments=True): + * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: * return GURL(base).Resolve(url).spec() # <<<<<<<<<<<<<< * else: @@ -3223,7 +3221,7 @@ static PyObject *__pyx_pf_5cgurl_2url_join(CYTHON_UNUSED PyObject *__pyx_self, P /* "cgurl.pyx":164 * - * def url_join(bytes base, bytes url, allow_fragments=True): + * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: # <<<<<<<<<<<<<< * return GURL(base).Resolve(url).spec() * else: @@ -3263,7 +3261,7 @@ static PyObject *__pyx_pf_5cgurl_2url_join(CYTHON_UNUSED PyObject *__pyx_self, P /* "cgurl.pyx":163 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def url_join(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< + * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ @@ -3274,7 +3272,7 @@ static PyObject *__pyx_pf_5cgurl_2url_join(CYTHON_UNUSED PyObject *__pyx_self, P __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("cgurl.url_join", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("cgurl.urljoin", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); @@ -3731,10 +3729,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_stdlib_urlunsplit, __pyx_k_stdlib_urlunsplit, sizeof(__pyx_k_stdlib_urlunsplit), 0, 0, 1, 1}, {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, {&__pyx_n_s_url, __pyx_k_url, sizeof(__pyx_k_url), 0, 0, 1, 1}, - {&__pyx_n_s_url_join, __pyx_k_url_join, sizeof(__pyx_k_url_join), 0, 0, 1, 1}, - {&__pyx_n_s_url_split, __pyx_k_url_split, sizeof(__pyx_k_url_split), 0, 0, 1, 1}, {&__pyx_n_s_urljoin, __pyx_k_urljoin, sizeof(__pyx_k_urljoin), 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}, {0, 0, 0, 0, 0, 0, 0} @@ -3789,26 +3786,26 @@ static int __Pyx_InitCachedConstants(void) { /* "cgurl.pyx":160 * * - * def url_split(url): # <<<<<<<<<<<<<< + * def urlsplit(url): # <<<<<<<<<<<<<< * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * */ __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_url_split, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 160, __pyx_L1_error) /* "cgurl.pyx":163 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def url_join(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< + * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ __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, 163, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); - __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_url_join, 163, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 163, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -4183,25 +4180,25 @@ if (!__Pyx_RefNanny) { /* "cgurl.pyx":160 * * - * def url_split(url): # <<<<<<<<<<<<<< + * def urlsplit(url): # <<<<<<<<<<<<<< * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1url_split, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_url_split, __pyx_t_1) < 0) __PYX_ERR(0, 160, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "cgurl.pyx":163 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) * - * def url_join(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< + * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3url_join, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_url_join, __pyx_t_1) < 0) __PYX_ERR(0, 163, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 163, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "cgurl.pyx":1 From 74d7493d38d18eb51d573b4487982f29a2eb97d5 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 14:51:15 -0500 Subject: [PATCH 12/38] testing unicode sp --- urlparse4/cgurl.pyx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index eaeeafe..72c7def 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -158,7 +158,12 @@ class SplitResultNamedTuple(tuple): def urlsplit(url): - return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + cdef bytes b_url + if isinstance(url, unicode): + b_url = (url).encode('utf8') + else: + b_url = url + return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) def urljoin(bytes base, bytes url, allow_fragments=True): if allow_fragments and base: From 1c389d99632b360b06e169387a460debd03948f8 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 14:51:22 -0500 Subject: [PATCH 13/38] rebuild cython --- urlparse4/cgurl.cpp | 247 +++++++++++++++++++++++++++----------------- 1 file changed, 155 insertions(+), 92 deletions(-) diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index 3d9fe12..ddcaca3 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -1273,6 +1273,7 @@ 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_b_url[] = "b_url"; static const char __pyx_k_cgurl[] = "cgurl"; static const char __pyx_k_lower[] = "lower"; static const char __pyx_k_query[] = "query"; @@ -1313,6 +1314,7 @@ static PyObject *__pyx_n_s_SplitResultNamedTuple___new___lo; 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_b_url; static PyObject *__pyx_n_s_base; static PyObject *__pyx_n_s_cgurl; static PyObject *__pyx_n_s_cline_in_traceback; @@ -2963,8 +2965,8 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P * * * def urlsplit(url): # <<<<<<<<<<<<<< - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * + * cdef bytes b_url + * if isinstance(url, unicode): */ /* Python wrapper */ @@ -2982,107 +2984,167 @@ static PyObject *__pyx_pw_5cgurl_1urlsplit(PyObject *__pyx_self, PyObject *__pyx } static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) { + PyObject *__pyx_v_b_url = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; + int __pyx_t_1; + int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; + PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urlsplit", 0); - /* "cgurl.pyx":161 - * + /* "cgurl.pyx":162 + * def urlsplit(url): + * cdef bytes b_url + * if isinstance(url, unicode): # <<<<<<<<<<<<<< + * b_url = (url).encode('utf8') + * else: + */ + __pyx_t_1 = PyUnicode_Check(__pyx_v_url); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "cgurl.pyx":163 + * cdef bytes b_url + * if isinstance(url, unicode): + * b_url = (url).encode('utf8') # <<<<<<<<<<<<<< + * else: + * b_url = url + */ + if (unlikely(__pyx_v_url == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); + __PYX_ERR(0, 163, __pyx_L1_error) + } + __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_url)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __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_b_url = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + + /* "cgurl.pyx":162 * def urlsplit(url): - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) # <<<<<<<<<<<<<< + * cdef bytes b_url + * if isinstance(url, unicode): # <<<<<<<<<<<<<< + * b_url = (url).encode('utf8') + * else: + */ + goto __pyx_L3; + } + + /* "cgurl.pyx":165 + * b_url = (url).encode('utf8') + * else: + * b_url = url # <<<<<<<<<<<<<< + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) + * + */ + /*else*/ { + if (!(likely(PyBytes_CheckExact(__pyx_v_url))||((__pyx_v_url) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_url)->tp_name), 0))) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_4 = __pyx_v_url; + __Pyx_INCREF(__pyx_t_4); + __pyx_v_b_url = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + } + __pyx_L3:; + + /* "cgurl.pyx":166 + * else: + * b_url = url + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) # <<<<<<<<<<<<<< * * def urljoin(bytes base, bytes 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, 161, __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, 161, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __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, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && 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); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = NULL; + __pyx_t_7 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_5 = 1; + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_url}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_url}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { - __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 161, __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, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3); + __Pyx_INCREF(__pyx_v_b_url); + __Pyx_GIVEREF(__pyx_v_b_url); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_b_url); + __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; goto __pyx_L0; /* "cgurl.pyx":160 * * * def urlsplit(url): # <<<<<<<<<<<<<< - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * + * cdef bytes b_url + * if isinstance(url, unicode): */ /* 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_8); __Pyx_AddTraceback("cgurl.urlsplit", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_b_url); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "cgurl.pyx":163 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) +/* "cgurl.pyx":168 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: @@ -3125,7 +3187,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ case 1: 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, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, 1); __PYX_ERR(0, 168, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -3135,7 +3197,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 163, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 168, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3153,14 +3215,14 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 168, __pyx_L3_error) __pyx_L3_error:; __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, 163, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 163, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyBytes_Type), 1, "base", 1))) __PYX_ERR(0, 168, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 168, __pyx_L1_error) __pyx_r = __pyx_pf_5cgurl_2urljoin(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); /* function exit code */ @@ -3185,14 +3247,14 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urljoin", 0); - /* "cgurl.pyx":164 + /* "cgurl.pyx":169 * * 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, 164, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_allow_fragments); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 169, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; @@ -3203,7 +3265,7 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":165 + /* "cgurl.pyx":170 * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: * return GURL(base).Resolve(url).spec() # <<<<<<<<<<<<<< @@ -3211,15 +3273,15 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py * 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, 165, __pyx_L1_error) - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __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, 165, __pyx_L1_error) + __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_v_base); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 170, __pyx_L1_error) + __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 170, __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, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "cgurl.pyx":164 + /* "cgurl.pyx":169 * * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: # <<<<<<<<<<<<<< @@ -3228,16 +3290,16 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py */ } - /* "cgurl.pyx":167 + /* "cgurl.pyx":172 * return GURL(base).Resolve(url).spec() * else: * return stdlib_urljoin(base, url, allow_fragments=allow_fragments) # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_base); __Pyx_GIVEREF(__pyx_v_base); @@ -3245,10 +3307,10 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __Pyx_INCREF(__pyx_v_url); __Pyx_GIVEREF(__pyx_v_url); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_url); - __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 172, __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, 167, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 167, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_allow_fragments, __pyx_v_allow_fragments) < 0) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -3258,8 +3320,8 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py goto __pyx_L0; } - /* "cgurl.pyx":163 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + /* "cgurl.pyx":168 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: @@ -3695,6 +3757,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_SplitResultNamedTuple_geturl, __pyx_k_SplitResultNamedTuple_geturl, sizeof(__pyx_k_SplitResultNamedTuple_geturl), 0, 0, 1, 1}, {&__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_b_url, __pyx_k_b_url, sizeof(__pyx_k_b_url), 0, 0, 1, 1}, {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 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}, @@ -3787,25 +3850,25 @@ static int __Pyx_InitCachedConstants(void) { * * * def urlsplit(url): # <<<<<<<<<<<<<< - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * + * cdef bytes b_url + * if isinstance(url, unicode): */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_tuple__8 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_b_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 160, __pyx_L1_error) - /* "cgurl.pyx":163 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + /* "cgurl.pyx":168 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __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, 163, __pyx_L1_error) + __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, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); - __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 163, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 168, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -4181,24 +4244,24 @@ if (!__Pyx_RefNanny) { * * * def urlsplit(url): # <<<<<<<<<<<<<< - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * + * cdef bytes b_url + * if isinstance(url, unicode): */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "cgurl.pyx":163 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + /* "cgurl.pyx":168 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 163, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "cgurl.pyx":1 From f4e21ad8f6a0046960b99ac55e3de905cb82d4e1 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 15:36:06 -0500 Subject: [PATCH 14/38] indentation --- urlparse4/cgurl.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index 72c7def..3b7ba84 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -1,9 +1,13 @@ from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL 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"" From fa7ba5956e832d381d2052c7cfe35e717e7253c0 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 15:41:38 -0500 Subject: [PATCH 15/38] convert result to unicode on python2 --- urlparse4/cgurl.pyx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index 3b7ba84..79a413f 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -149,13 +149,22 @@ 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) - )) + if six.PY2: + return tuple.__new__(cls, ( + unicode(slice_component(url, parsed.scheme).lower()), + unicode(build_netloc(url, parsed)), + unicode(slice_component(url, parsed.path)), + unicode(slice_component(url, parsed.query)), + unicode(slice_component(url, parsed.ref)) + )) + else: + 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) + )) def geturl(self): return stdlib_urlunsplit(self) From 7509bf48285b9f17a385b6165ba48886a76a1b52 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 15:41:48 -0500 Subject: [PATCH 16/38] compile cython on py3 --- urlparse4/cgurl.cpp | 1055 ++++++++++++++++++++++++++----------------- 1 file changed, 648 insertions(+), 407 deletions(-) diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index ddcaca3..3958e5d 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -850,7 +850,7 @@ static const char *__pyx_f[] = { /*--- Type declarations ---*/ struct __pyx_obj_5cgurl___pyx_scope_struct____new__; -/* "cgurl.pyx":112 +/* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -1144,6 +1144,15 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr /* GetModuleGlobalName.proto */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); +/* PyObject_Unicode.proto */ +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyObject_Unicode(obj)\ + (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj)) +#else +#define __Pyx_PyObject_Unicode(obj)\ + (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Unicode(obj)) +#endif + /* 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); @@ -1261,9 +1270,11 @@ int __pyx_module_is_main_cgurl = 0; /* 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_six[] = "six"; static const char __pyx_k_url[] = "url"; static const char __pyx_k_base[] = "base"; static const char __pyx_k_file[] = "file:"; @@ -1308,6 +1319,7 @@ static const char __pyx_k_SplitResultNamedTuple___new[] = "SplitResultNamedTuple static const char __pyx_k_SplitResultNamedTuple_geturl[] = "SplitResultNamedTuple.geturl"; 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; @@ -1343,6 +1355,7 @@ static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_n_s_query; 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_urljoin; @@ -1373,8 +1386,8 @@ static PyObject *__pyx_codeobj__9; static PyObject *__pyx_codeobj__11; /* Late includes */ -/* "cgurl.pyx":7 - * cimport cython +/* "cgurl.pyx":11 + * * * cdef bytes slice_component(bytes pyurl, Component comp): # <<<<<<<<<<<<<< * if comp.len <= 0: @@ -1388,7 +1401,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("slice_component", 0); - /* "cgurl.pyx":8 + /* "cgurl.pyx":12 * * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1398,7 +1411,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct __pyx_t_1 = ((__pyx_v_comp.len <= 0) != 0); if (__pyx_t_1) { - /* "cgurl.pyx":9 + /* "cgurl.pyx":13 * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1410,7 +1423,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct __pyx_r = __pyx_kp_b_; goto __pyx_L0; - /* "cgurl.pyx":8 + /* "cgurl.pyx":12 * * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1419,7 +1432,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct */ } - /* "cgurl.pyx":11 + /* "cgurl.pyx":15 * return b"" * * return pyurl[comp.begin:comp.begin + comp.len] # <<<<<<<<<<<<<< @@ -1429,16 +1442,16 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_pyurl == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 11, __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, 11, __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; - /* "cgurl.pyx":7 - * cimport cython + /* "cgurl.pyx":11 + * * * cdef bytes slice_component(bytes pyurl, Component comp): # <<<<<<<<<<<<<< * if comp.len <= 0: @@ -1456,7 +1469,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct return __pyx_r; } -/* "cgurl.pyx":14 +/* "cgurl.pyx":18 * * * cdef bytes cslice_component(char * url, Component comp): # <<<<<<<<<<<<<< @@ -1471,7 +1484,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("cslice_component", 0); - /* "cgurl.pyx":15 + /* "cgurl.pyx":19 * * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1481,7 +1494,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: __pyx_t_1 = ((__pyx_v_comp.len <= 0) != 0); if (__pyx_t_1) { - /* "cgurl.pyx":16 + /* "cgurl.pyx":20 * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1493,7 +1506,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: __pyx_r = __pyx_kp_b_; goto __pyx_L0; - /* "cgurl.pyx":15 + /* "cgurl.pyx":19 * * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1502,7 +1515,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":19 + /* "cgurl.pyx":23 * * # TODO: check if std::string brings any speedups * return url[comp.begin:comp.begin + comp.len] # <<<<<<<<<<<<<< @@ -1510,13 +1523,13 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: * */ __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, 19, __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; - /* "cgurl.pyx":14 + /* "cgurl.pyx":18 * * * cdef bytes cslice_component(char * url, Component comp): # <<<<<<<<<<<<<< @@ -1535,7 +1548,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: return __pyx_r; } -/* "cgurl.pyx":22 +/* "cgurl.pyx":26 * * * cdef bytes build_netloc(bytes url, Parsed parsed): # <<<<<<<<<<<<<< @@ -1551,7 +1564,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("build_netloc", 0); - /* "cgurl.pyx":24 + /* "cgurl.pyx":28 * cdef bytes build_netloc(bytes url, Parsed parsed): * * if parsed.host.len <= 0: # <<<<<<<<<<<<<< @@ -1561,7 +1574,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_t_1 = ((__pyx_v_parsed.host.len <= 0) != 0); if (__pyx_t_1) { - /* "cgurl.pyx":25 + /* "cgurl.pyx":29 * * if parsed.host.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1573,7 +1586,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_r = __pyx_kp_b_; goto __pyx_L0; - /* "cgurl.pyx":24 + /* "cgurl.pyx":28 * cdef bytes build_netloc(bytes url, Parsed parsed): * * if parsed.host.len <= 0: # <<<<<<<<<<<<<< @@ -1582,7 +1595,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":28 + /* "cgurl.pyx":32 * * # Nothing at all * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1606,7 +1619,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":29 + /* "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] # <<<<<<<<<<<<<< @@ -1616,15 +1629,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 29, __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, 29, __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; - /* "cgurl.pyx":28 + /* "cgurl.pyx":32 * * # Nothing at all * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1633,7 +1646,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":32 + /* "cgurl.pyx":36 * * # Only port * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1657,7 +1670,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L7_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":33 + /* "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] # <<<<<<<<<<<<<< @@ -1667,15 +1680,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 33, __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, 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) + 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; - /* "cgurl.pyx":32 + /* "cgurl.pyx":36 * * # Only port * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1684,7 +1697,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":36 + /* "cgurl.pyx":40 * * # Only username * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1708,7 +1721,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L10_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":37 + /* "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] # <<<<<<<<<<<<<< @@ -1718,15 +1731,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 37, __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, 37, __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; - /* "cgurl.pyx":36 + /* "cgurl.pyx":40 * * # Only username * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1735,7 +1748,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":40 + /* "cgurl.pyx":44 * * # Username + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1759,7 +1772,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L13_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":41 + /* "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] # <<<<<<<<<<<<<< @@ -1769,15 +1782,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 41, __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, 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) + 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; - /* "cgurl.pyx":40 + /* "cgurl.pyx":44 * * # Username + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1786,7 +1799,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":44 + /* "cgurl.pyx":48 * * # Username + port * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1810,7 +1823,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L16_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":45 + /* "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] # <<<<<<<<<<<<<< @@ -1820,15 +1833,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 45, __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, 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.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; - /* "cgurl.pyx":44 + /* "cgurl.pyx":48 * * # Username + port * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1837,7 +1850,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":48 + /* "cgurl.pyx":52 * * # Username + port + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1861,7 +1874,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L19_bool_binop_done:; if (likely(__pyx_t_1)) { - /* "cgurl.pyx":49 + /* "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] # <<<<<<<<<<<<<< @@ -1871,15 +1884,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 49, __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, 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) + 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; - /* "cgurl.pyx":48 + /* "cgurl.pyx":52 * * # Username + port + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1888,7 +1901,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":52 + /* "cgurl.pyx":56 * * else: * raise ValueError # <<<<<<<<<<<<<< @@ -1897,10 +1910,10 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ /*else*/ { __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0); - __PYX_ERR(0, 52, __pyx_L1_error) + __PYX_ERR(0, 56, __pyx_L1_error) } - /* "cgurl.pyx":22 + /* "cgurl.pyx":26 * * * cdef bytes build_netloc(bytes url, Parsed parsed): # <<<<<<<<<<<<<< @@ -1919,7 +1932,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: return __pyx_r; } -/* "cgurl.pyx":112 +/* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -1959,11 +1972,11 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__py case 1: 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, 112, __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, 112, __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; @@ -1976,13 +1989,13 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__new__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 112, __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("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, 112, __pyx_L1_error) + 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 */ @@ -1994,7 +2007,7 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__py return __pyx_r; } -/* "cgurl.pyx":121 +/* "cgurl.pyx":125 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< @@ -2034,11 +2047,11 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr(PyO case 1: 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, 121, __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, 121, __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; @@ -2051,7 +2064,7 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr(PyO } 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, 121, __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("cgurl.SplitResultNamedTuple.__new__._get_attr", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -2078,17 +2091,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_outer_scope = (struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; - /* "cgurl.pyx":122 + /* "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, 122, __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) { - /* "cgurl.pyx":123 + /* "cgurl.pyx":127 * def _get_attr(self, prop): * if prop == "scheme": * return self[0] # <<<<<<<<<<<<<< @@ -2096,13 +2109,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 123, __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; - /* "cgurl.pyx":122 + /* "cgurl.pyx":126 * * def _get_attr(self, prop): * if prop == "scheme": # <<<<<<<<<<<<<< @@ -2111,17 +2124,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":124 + /* "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, 124, __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) { - /* "cgurl.pyx":125 + /* "cgurl.pyx":129 * return self[0] * elif prop == "netloc": * return self[1] # <<<<<<<<<<<<<< @@ -2129,13 +2142,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 125, __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; - /* "cgurl.pyx":124 + /* "cgurl.pyx":128 * if prop == "scheme": * return self[0] * elif prop == "netloc": # <<<<<<<<<<<<<< @@ -2144,17 +2157,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":126 + /* "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, 126, __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) { - /* "cgurl.pyx":127 + /* "cgurl.pyx":131 * return self[1] * elif prop == "path": * return self[2] # <<<<<<<<<<<<<< @@ -2162,13 +2175,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 127, __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; - /* "cgurl.pyx":126 + /* "cgurl.pyx":130 * elif prop == "netloc": * return self[1] * elif prop == "path": # <<<<<<<<<<<<<< @@ -2177,17 +2190,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":128 + /* "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, 128, __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) { - /* "cgurl.pyx":129 + /* "cgurl.pyx":133 * return self[2] * elif prop == "query": * return self[3] # <<<<<<<<<<<<<< @@ -2195,13 +2208,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 129, __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; - /* "cgurl.pyx":128 + /* "cgurl.pyx":132 * elif prop == "path": * return self[2] * elif prop == "query": # <<<<<<<<<<<<<< @@ -2210,17 +2223,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":130 + /* "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, 130, __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) { - /* "cgurl.pyx":131 + /* "cgurl.pyx":135 * return self[3] * elif prop == "fragment": * return self[4] # <<<<<<<<<<<<<< @@ -2228,13 +2241,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 131, __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; - /* "cgurl.pyx":130 + /* "cgurl.pyx":134 * elif prop == "query": * return self[3] * elif prop == "fragment": # <<<<<<<<<<<<<< @@ -2243,17 +2256,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":132 + /* "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, 132, __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) { - /* "cgurl.pyx":133 + /* "cgurl.pyx":137 * return self[4] * elif prop == "port": * if parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -2263,38 +2276,38 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_parsed.port.len > 0) != 0); if (__pyx_t_1) { - /* "cgurl.pyx":134 + /* "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, 134, __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_5cgurl_slice_component(((PyObject*)__pyx_t_2), __pyx_cur_scope->__pyx_v_parsed.port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __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, 134, __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; - /* "cgurl.pyx":135 + /* "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, 135, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 135, __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) { - /* "cgurl.pyx":136 + /* "cgurl.pyx":140 * port = int(slice_component(url, parsed.port)) * if port <= 65535: * return port # <<<<<<<<<<<<<< @@ -2306,7 +2319,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_r = __pyx_v_port; goto __pyx_L0; - /* "cgurl.pyx":135 + /* "cgurl.pyx":139 * if parsed.port.len > 0: * port = int(slice_component(url, parsed.port)) * if port <= 65535: # <<<<<<<<<<<<<< @@ -2315,7 +2328,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":133 + /* "cgurl.pyx":137 * return self[4] * elif prop == "port": * if parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -2324,7 +2337,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":132 + /* "cgurl.pyx":136 * elif prop == "fragment": * return self[4] * elif prop == "port": # <<<<<<<<<<<<<< @@ -2334,17 +2347,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb goto __pyx_L3; } - /* "cgurl.pyx":138 + /* "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, 138, __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) { - /* "cgurl.pyx":139 + /* "cgurl.pyx":143 * * elif prop == "username": * return slice_component(url, parsed.username) or None # <<<<<<<<<<<<<< @@ -2352,13 +2365,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 139, __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_5cgurl_slice_component(((PyObject*)__pyx_t_3), __pyx_cur_scope->__pyx_v_parsed.username); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __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, 139, __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 { @@ -2374,7 +2387,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_t_2 = 0; goto __pyx_L0; - /* "cgurl.pyx":138 + /* "cgurl.pyx":142 * return port * * elif prop == "username": # <<<<<<<<<<<<<< @@ -2383,17 +2396,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":140 + /* "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, 140, __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) { - /* "cgurl.pyx":141 + /* "cgurl.pyx":145 * return slice_component(url, parsed.username) or None * elif prop == "password": * return slice_component(url, parsed.password) or None # <<<<<<<<<<<<<< @@ -2401,13 +2414,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 141, __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_5cgurl_slice_component(((PyObject*)__pyx_t_4), __pyx_cur_scope->__pyx_v_parsed.password); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __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, 141, __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 { @@ -2423,7 +2436,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_t_2 = 0; goto __pyx_L0; - /* "cgurl.pyx":140 + /* "cgurl.pyx":144 * elif prop == "username": * return slice_component(url, parsed.username) or None * elif prop == "password": # <<<<<<<<<<<<<< @@ -2432,17 +2445,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":142 + /* "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, 142, __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) { - /* "cgurl.pyx":143 + /* "cgurl.pyx":147 * return slice_component(url, parsed.password) or None * elif prop == "hostname": * return slice_component(url, parsed.host).lower() # <<<<<<<<<<<<<< @@ -2450,13 +2463,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * */ __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 143, __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_5cgurl_slice_component(((PyObject*)__pyx_t_3), __pyx_cur_scope->__pyx_v_parsed.host); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __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, 143, __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; @@ -2470,10 +2483,10 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb } } if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __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, 143, __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; @@ -2481,7 +2494,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_t_2 = 0; goto __pyx_L0; - /* "cgurl.pyx":142 + /* "cgurl.pyx":146 * elif prop == "password": * return slice_component(url, parsed.password) or None * elif prop == "hostname": # <<<<<<<<<<<<<< @@ -2491,7 +2504,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb } __pyx_L3:; - /* "cgurl.pyx":121 + /* "cgurl.pyx":125 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< @@ -2515,7 +2528,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb return __pyx_r; } -/* "cgurl.pyx":112 +/* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -2547,7 +2560,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *)Py_None); __Pyx_INCREF(Py_None); - __PYX_ERR(0, 112, __pyx_L1_error) + __PYX_ERR(0, 116, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } @@ -2555,7 +2568,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P __Pyx_INCREF(__pyx_cur_scope->__pyx_v_url); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_url); - /* "cgurl.pyx":116 + /* "cgurl.pyx":120 * cdef Parsed parsed * * if url[0:5] == b"file:": # <<<<<<<<<<<<<< @@ -2564,16 +2577,16 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P */ if (unlikely(__pyx_cur_scope->__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 116, __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, 116, __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, 116, __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) { - /* "cgurl.pyx":117 + /* "cgurl.pyx":121 * * if url[0:5] == b"file:": * ParseFileURL(url, len(url), &parsed) # <<<<<<<<<<<<<< @@ -2582,20 +2595,20 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P */ if (unlikely(__pyx_cur_scope->__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 117, __pyx_L1_error) + __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, 117, __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, 117, __pyx_L1_error) + __PYX_ERR(0, 121, __pyx_L1_error) } - __pyx_t_5 = PyBytes_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 117, __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)); - /* "cgurl.pyx":116 + /* "cgurl.pyx":120 * cdef Parsed parsed * * if url[0:5] == b"file:": # <<<<<<<<<<<<<< @@ -2605,7 +2618,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P goto __pyx_L3; } - /* "cgurl.pyx":119 + /* "cgurl.pyx":123 * ParseFileURL(url, len(url), &parsed) * else: * ParseStandardURL(url, len(url), &parsed) # <<<<<<<<<<<<<< @@ -2615,215 +2628,429 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P /*else*/ { if (unlikely(__pyx_cur_scope->__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 119, __pyx_L1_error) + __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, 119, __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, 119, __pyx_L1_error) + __PYX_ERR(0, 123, __pyx_L1_error) } - __pyx_t_5 = PyBytes_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 119, __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:; - /* "cgurl.pyx":121 + /* "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_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, 121, __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; - /* "cgurl.pyx":146 + /* "cgurl.pyx":150 * * * cls.__getattr__ = _get_attr # <<<<<<<<<<<<<< * - * return tuple.__new__(cls, ( + * if six.PY2: */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_cls, __pyx_n_s_getattr, __pyx_v__get_attr) < 0) __PYX_ERR(0, 146, __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) - /* "cgurl.pyx":148 + /* "cgurl.pyx":152 * cls.__getattr__ = _get_attr * - * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< - * slice_component(url, parsed.scheme).lower(), - * build_netloc(url, parsed), + * if six.PY2: # <<<<<<<<<<<<<< + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), */ - __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, 148, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PY2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (__pyx_t_3) { - /* "cgurl.pyx":149 - * - * 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_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 149, __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, 149, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = NULL; - if (CYTHON_UNPACK_METHODS && 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_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); + /* "cgurl.pyx":153 + * + * if six.PY2: + * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< + * unicode(slice_component(url, parsed.scheme).lower()), + * unicode(build_netloc(url, parsed)), + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + + /* "cgurl.pyx":154 + * if six.PY2: + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), # <<<<<<<<<<<<<< + * unicode(build_netloc(url, parsed)), + * unicode(slice_component(url, parsed.path)), + */ + __pyx_t_9 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_9); + __pyx_t_10 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 154, __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, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + if (CYTHON_UNPACK_METHODS && 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_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, 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, 149, __pyx_L1_error) + if (__pyx_t_10) { + __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else { + __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 154, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_Unicode(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + + /* "cgurl.pyx":155 + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), + * unicode(build_netloc(url, parsed)), # <<<<<<<<<<<<<< + * unicode(slice_component(url, parsed.path)), + * unicode(slice_component(url, parsed.query)), + */ + __pyx_t_8 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_8); + __pyx_t_10 = __pyx_f_5cgurl_build_netloc(((PyObject*)__pyx_t_8), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 155, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_PyObject_Unicode(__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 155, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else { - __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "cgurl.pyx":150 - * 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_5cgurl_build_netloc(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "cgurl.pyx":151 - * 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_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + /* "cgurl.pyx":156 + * unicode(slice_component(url, parsed.scheme).lower()), + * unicode(build_netloc(url, parsed)), + * unicode(slice_component(url, parsed.path)), # <<<<<<<<<<<<<< + * unicode(slice_component(url, parsed.query)), + * unicode(slice_component(url, parsed.ref)) + */ + __pyx_t_10 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_10); + __pyx_t_11 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_10), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_Unicode(__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + + /* "cgurl.pyx":157 + * unicode(build_netloc(url, parsed)), + * unicode(slice_component(url, parsed.path)), + * unicode(slice_component(url, parsed.query)), # <<<<<<<<<<<<<< + * unicode(slice_component(url, parsed.ref)) + * )) + */ + __pyx_t_11 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_11); + __pyx_t_12 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_11), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyObject_Unicode(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - /* "cgurl.pyx":152 - * 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_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "cgurl.pyx":153 - * 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_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "cgurl.pyx":149 - * - * 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, 149, __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_t_8 = 0; - __pyx_t_10 = 0; - __pyx_t_11 = 0; - __pyx_t_12 = 0; - __pyx_t_13 = 0; - __pyx_t_13 = NULL; - __pyx_t_14 = 0; - if (CYTHON_UNPACK_METHODS && 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_14 = 1; + /* "cgurl.pyx":158 + * unicode(slice_component(url, parsed.path)), + * unicode(slice_component(url, parsed.query)), + * unicode(slice_component(url, parsed.ref)) # <<<<<<<<<<<<<< + * )) + * else: + */ + __pyx_t_12 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_12); + __pyx_t_13 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_12), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyObject_Unicode(__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":154 + * if six.PY2: + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), # <<<<<<<<<<<<<< + * unicode(build_netloc(url, parsed)), + * unicode(slice_component(url, parsed.path)), + */ + __pyx_t_13 = PyTuple_New(5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_t_12); + __pyx_t_9 = 0; + __pyx_t_8 = 0; + __pyx_t_10 = 0; + __pyx_t_11 = 0; + __pyx_t_12 = 0; + __pyx_t_12 = NULL; + __pyx_t_14 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_14 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_cls, __pyx_t_13}; + __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_cls, __pyx_t_13}; + __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_12) { + __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __pyx_t_12 = NULL; + } + __Pyx_INCREF(__pyx_v_cls); + __Pyx_GIVEREF(__pyx_v_cls); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_14, __pyx_v_cls); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_14, __pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; + + /* "cgurl.pyx":152 + * cls.__getattr__ = _get_attr + * + * if six.PY2: # <<<<<<<<<<<<<< + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), + */ } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_cls, __pyx_t_9}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_cls, __pyx_t_9}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":161 + * )) + * else: + * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< + * slice_component(url, parsed.scheme).lower(), + * build_netloc(url, parsed), + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_12 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 148, __pyx_L1_error) + + /* "cgurl.pyx":162 + * else: + * return tuple.__new__(cls, ( + * slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< + * build_netloc(url, parsed), + * slice_component(url, parsed.path), + */ + __pyx_t_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_12 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 162, __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_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_lower); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_13, function); + } } - __Pyx_INCREF(__pyx_v_cls); - __Pyx_GIVEREF(__pyx_v_cls); - PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_14, __pyx_v_cls); + if (__pyx_t_12) { + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } else { + __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 162, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":163 + * 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_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_12 = __pyx_f_5cgurl_build_netloc(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":164 + * 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_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_10 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 164, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":165 + * build_netloc(url, parsed), + * slice_component(url, parsed.path), + * slice_component(url, parsed.query), # <<<<<<<<<<<<<< + * slice_component(url, parsed.ref) + * )) + */ + __pyx_t_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_8 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 165, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":166 + * slice_component(url, parsed.path), + * slice_component(url, parsed.query), + * slice_component(url, parsed.ref) # <<<<<<<<<<<<<< + * )) + * + */ + __pyx_t_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_9 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":162 + * else: + * return tuple.__new__(cls, ( + * slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< + * build_netloc(url, parsed), + * slice_component(url, parsed.path), + */ + __pyx_t_13 = PyTuple_New(5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_14, __pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_t_9); + __pyx_t_11 = 0; + __pyx_t_12 = 0; + __pyx_t_10 = 0; + __pyx_t_8 = 0; __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, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_9 = NULL; + __pyx_t_14 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_14 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_cls, __pyx_t_13}; + __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_cls, __pyx_t_13}; + __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_9) { + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_INCREF(__pyx_v_cls); + __Pyx_GIVEREF(__pyx_v_cls); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_14, __pyx_v_cls); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_14, __pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - /* "cgurl.pyx":112 + /* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -2851,8 +3078,8 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P return __pyx_r; } -/* "cgurl.pyx":156 - * )) +/* "cgurl.pyx":169 + * )) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) @@ -2882,7 +3109,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("geturl", 0); - /* "cgurl.pyx":157 + /* "cgurl.pyx":170 * * def geturl(self): * return stdlib_urlunsplit(self) # <<<<<<<<<<<<<< @@ -2890,7 +3117,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urlunsplit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urlunsplit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -2903,13 +3130,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P } } if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __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_self}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -2917,19 +3144,19 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P #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, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __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, 157, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 170, __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, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } @@ -2939,8 +3166,8 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P __pyx_t_1 = 0; goto __pyx_L0; - /* "cgurl.pyx":156 - * )) + /* "cgurl.pyx":169 + * )) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) @@ -2961,7 +3188,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P return __pyx_r; } -/* "cgurl.pyx":160 +/* "cgurl.pyx":173 * * * def urlsplit(url): # <<<<<<<<<<<<<< @@ -2997,7 +3224,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urlsplit", 0); - /* "cgurl.pyx":162 + /* "cgurl.pyx":175 * def urlsplit(url): * cdef bytes b_url * if isinstance(url, unicode): # <<<<<<<<<<<<<< @@ -3008,7 +3235,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "cgurl.pyx":163 + /* "cgurl.pyx":176 * cdef bytes b_url * if isinstance(url, unicode): * b_url = (url).encode('utf8') # <<<<<<<<<<<<<< @@ -3017,9 +3244,9 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py */ if (unlikely(__pyx_v_url == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); - __PYX_ERR(0, 163, __pyx_L1_error) + __PYX_ERR(0, 176, __pyx_L1_error) } - __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_url)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_url)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); @@ -3027,7 +3254,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_v_b_url = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cgurl.pyx":162 + /* "cgurl.pyx":175 * def urlsplit(url): * cdef bytes b_url * if isinstance(url, unicode): # <<<<<<<<<<<<<< @@ -3037,7 +3264,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py goto __pyx_L3; } - /* "cgurl.pyx":165 + /* "cgurl.pyx":178 * b_url = (url).encode('utf8') * else: * b_url = url # <<<<<<<<<<<<<< @@ -3045,7 +3272,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py * */ /*else*/ { - if (!(likely(PyBytes_CheckExact(__pyx_v_url))||((__pyx_v_url) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_url)->tp_name), 0))) __PYX_ERR(0, 165, __pyx_L1_error) + if (!(likely(PyBytes_CheckExact(__pyx_v_url))||((__pyx_v_url) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_url)->tp_name), 0))) __PYX_ERR(0, 178, __pyx_L1_error) __pyx_t_4 = __pyx_v_url; __Pyx_INCREF(__pyx_t_4); __pyx_v_b_url = ((PyObject*)__pyx_t_4); @@ -3053,7 +3280,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py } __pyx_L3:; - /* "cgurl.pyx":166 + /* "cgurl.pyx":179 * else: * b_url = url * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) # <<<<<<<<<<<<<< @@ -3061,12 +3288,12 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py * def urljoin(bytes base, bytes url, allow_fragments=True): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_7 = 0; @@ -3083,7 +3310,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -3092,14 +3319,14 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; @@ -3110,7 +3337,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __Pyx_GIVEREF(__pyx_v_b_url); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_b_url); __pyx_t_3 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } @@ -3119,7 +3346,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_t_4 = 0; goto __pyx_L0; - /* "cgurl.pyx":160 + /* "cgurl.pyx":173 * * * def urlsplit(url): # <<<<<<<<<<<<<< @@ -3143,7 +3370,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py return __pyx_r; } -/* "cgurl.pyx":168 +/* "cgurl.pyx":181 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< @@ -3187,7 +3414,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ case 1: 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, 168, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, 1); __PYX_ERR(0, 181, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -3197,7 +3424,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 168, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 181, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3215,14 +3442,14 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 168, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 181, __pyx_L3_error) __pyx_L3_error:; __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, 168, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 168, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyBytes_Type), 1, "base", 1))) __PYX_ERR(0, 181, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 181, __pyx_L1_error) __pyx_r = __pyx_pf_5cgurl_2urljoin(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); /* function exit code */ @@ -3247,14 +3474,14 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urljoin", 0); - /* "cgurl.pyx":169 + /* "cgurl.pyx":182 * * 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, 169, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_allow_fragments); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 182, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; @@ -3265,7 +3492,7 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":170 + /* "cgurl.pyx":183 * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: * return GURL(base).Resolve(url).spec() # <<<<<<<<<<<<<< @@ -3273,15 +3500,15 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py * 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, 170, __pyx_L1_error) - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 170, __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, 170, __pyx_L1_error) + __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_v_base); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L1_error) + __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __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, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "cgurl.pyx":169 + /* "cgurl.pyx":182 * * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: # <<<<<<<<<<<<<< @@ -3290,16 +3517,16 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py */ } - /* "cgurl.pyx":172 + /* "cgurl.pyx":185 * return GURL(base).Resolve(url).spec() * else: * return stdlib_urljoin(base, url, allow_fragments=allow_fragments) # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_base); __Pyx_GIVEREF(__pyx_v_base); @@ -3307,10 +3534,10 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __Pyx_INCREF(__pyx_v_url); __Pyx_GIVEREF(__pyx_v_url); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_url); - __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __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, 172, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 172, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_allow_fragments, __pyx_v_allow_fragments) < 0) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -3320,7 +3547,7 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py goto __pyx_L0; } - /* "cgurl.pyx":168 + /* "cgurl.pyx":181 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< @@ -3751,6 +3978,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}, @@ -3786,6 +4014,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 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_urljoin, __pyx_k_stdlib_urljoin, sizeof(__pyx_k_stdlib_urljoin), 0, 0, 1, 1}, @@ -3800,7 +4029,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {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, 52, __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; @@ -3810,65 +4039,65 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "cgurl.pyx":121 + /* "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, 121, __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, 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, 121, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 121, __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) - /* "cgurl.pyx":112 + /* "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, 112, __pyx_L1_error) + __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, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); - __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_new, 112, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 112, __pyx_L1_error) + __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_new, 116, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 116, __pyx_L1_error) - /* "cgurl.pyx":156 - * )) + /* "cgurl.pyx":169 + * )) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) * */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); - __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_geturl, 156, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_geturl, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 169, __pyx_L1_error) - /* "cgurl.pyx":160 + /* "cgurl.pyx":173 * * * def urlsplit(url): # <<<<<<<<<<<<<< * cdef bytes b_url * if isinstance(url, unicode): */ - __pyx_tuple__8 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_b_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_tuple__8 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_b_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 173, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 173, __pyx_L1_error) - /* "cgurl.pyx":168 + /* "cgurl.pyx":181 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __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, 168, __pyx_L1_error) + __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, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); - __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 168, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 168, __pyx_L1_error) + __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -3920,7 +4149,7 @@ 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, 112, __pyx_L1_error) + 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; @@ -4133,141 +4362,153 @@ if (!__Pyx_RefNanny) { if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif - /* "cgurl.pyx":3 - * from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL + /* "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 - * cimport cython + * */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) + __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, 3, __pyx_L1_error) + __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, 3, __pyx_L1_error) + __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, 3, __pyx_L1_error) + 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":4 - * from urlparse4.chromium_gurl cimport GURL + /* "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 * + * cimport cython */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __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, 4, __pyx_L1_error) + __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); __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, 4, __pyx_L1_error) + __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, 4, __pyx_L1_error) + 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; - /* "cgurl.pyx":108 + /* "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, 108, __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, 108, __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_cgurl, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __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); - /* "cgurl.pyx":110 + /* "cgurl.pyx":114 * class SplitResultNamedTuple(tuple): * * __slots__ = () # prevent creation of instance dictionary # <<<<<<<<<<<<<< * * def __new__(cls, bytes url): */ - if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_slots, __pyx_empty_tuple) < 0) __PYX_ERR(0, 110, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_slots, __pyx_empty_tuple) < 0) __PYX_ERR(0, 114, __pyx_L1_error) - /* "cgurl.pyx":112 + /* "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_5cgurl_21SplitResultNamedTuple_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_SplitResultNamedTuple___new, NULL, __pyx_n_s_cgurl, __pyx_d, ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __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__5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_new, __pyx_t_4) < 0) __PYX_ERR(0, 112, __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; - /* "cgurl.pyx":156 - * )) + /* "cgurl.pyx":169 + * )) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) * */ - __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__7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __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__7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_geturl, __pyx_t_4) < 0) __PYX_ERR(0, 156, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_geturl, __pyx_t_4) < 0) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "cgurl.pyx":108 + /* "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, 108, __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, 108, __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; - /* "cgurl.pyx":160 + /* "cgurl.pyx":173 * * * def urlsplit(url): # <<<<<<<<<<<<<< * cdef bytes b_url * if isinstance(url, unicode): */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 160, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "cgurl.pyx":168 + /* "cgurl.pyx":181 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 168, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "cgurl.pyx":1 * from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL # <<<<<<<<<<<<<< * from urlparse4.chromium_gurl cimport GURL - * from six.moves.urllib.parse import urljoin as stdlib_urljoin + * */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); From 0712b1104801629a8bedd79a80757ada95aaf860 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 16:19:44 -0500 Subject: [PATCH 17/38] fix the urllib import --- urlparse4/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/urlparse4/__init__.py b/urlparse4/__init__.py index 1e39e03..dc1c441 100644 --- a/urlparse4/__init__.py +++ b/urlparse4/__init__.py @@ -2,7 +2,10 @@ import six -from six.moves.urllib.parse import urlparse, urlsplit, urljoin +if six.PY2: + from urlparse import * +else: + from urllib.parse import * _original_urlsplit = urlsplit From 92dfbcc3c68a33d8a578d2c51e45658fab28c26f Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 14:51:15 -0500 Subject: [PATCH 18/38] testing unicode sp --- urlparse4/cgurl.pyx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index eaeeafe..72c7def 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -158,7 +158,12 @@ class SplitResultNamedTuple(tuple): def urlsplit(url): - return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + cdef bytes b_url + if isinstance(url, unicode): + b_url = (url).encode('utf8') + else: + b_url = url + return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) def urljoin(bytes base, bytes url, allow_fragments=True): if allow_fragments and base: From 1819f7866d23d15b10c0a7cf9b3fd7080d202b2e Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 14:51:22 -0500 Subject: [PATCH 19/38] rebuild cython --- urlparse4/cgurl.cpp | 247 +++++++++++++++++++++++++++----------------- 1 file changed, 155 insertions(+), 92 deletions(-) diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index 3d9fe12..ddcaca3 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -1273,6 +1273,7 @@ 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_b_url[] = "b_url"; static const char __pyx_k_cgurl[] = "cgurl"; static const char __pyx_k_lower[] = "lower"; static const char __pyx_k_query[] = "query"; @@ -1313,6 +1314,7 @@ static PyObject *__pyx_n_s_SplitResultNamedTuple___new___lo; 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_b_url; static PyObject *__pyx_n_s_base; static PyObject *__pyx_n_s_cgurl; static PyObject *__pyx_n_s_cline_in_traceback; @@ -2963,8 +2965,8 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P * * * def urlsplit(url): # <<<<<<<<<<<<<< - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * + * cdef bytes b_url + * if isinstance(url, unicode): */ /* Python wrapper */ @@ -2982,107 +2984,167 @@ static PyObject *__pyx_pw_5cgurl_1urlsplit(PyObject *__pyx_self, PyObject *__pyx } static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) { + PyObject *__pyx_v_b_url = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; + int __pyx_t_1; + int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; + PyObject *__pyx_t_5 = NULL; PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urlsplit", 0); - /* "cgurl.pyx":161 - * + /* "cgurl.pyx":162 + * def urlsplit(url): + * cdef bytes b_url + * if isinstance(url, unicode): # <<<<<<<<<<<<<< + * b_url = (url).encode('utf8') + * else: + */ + __pyx_t_1 = PyUnicode_Check(__pyx_v_url); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "cgurl.pyx":163 + * cdef bytes b_url + * if isinstance(url, unicode): + * b_url = (url).encode('utf8') # <<<<<<<<<<<<<< + * else: + * b_url = url + */ + if (unlikely(__pyx_v_url == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); + __PYX_ERR(0, 163, __pyx_L1_error) + } + __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_url)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __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_b_url = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + + /* "cgurl.pyx":162 * def urlsplit(url): - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) # <<<<<<<<<<<<<< + * cdef bytes b_url + * if isinstance(url, unicode): # <<<<<<<<<<<<<< + * b_url = (url).encode('utf8') + * else: + */ + goto __pyx_L3; + } + + /* "cgurl.pyx":165 + * b_url = (url).encode('utf8') + * else: + * b_url = url # <<<<<<<<<<<<<< + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) + * + */ + /*else*/ { + if (!(likely(PyBytes_CheckExact(__pyx_v_url))||((__pyx_v_url) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_url)->tp_name), 0))) __PYX_ERR(0, 165, __pyx_L1_error) + __pyx_t_4 = __pyx_v_url; + __Pyx_INCREF(__pyx_t_4); + __pyx_v_b_url = ((PyObject*)__pyx_t_4); + __pyx_t_4 = 0; + } + __pyx_L3:; + + /* "cgurl.pyx":166 + * else: + * b_url = url + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) # <<<<<<<<<<<<<< * * def urljoin(bytes base, bytes 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, 161, __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, 161, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __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, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && 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); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = NULL; + __pyx_t_7 = 0; + if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_5 = 1; + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_url}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_2, __pyx_v_url}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { + PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { - __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 161, __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, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_6) { + __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3); + __Pyx_INCREF(__pyx_v_b_url); + __Pyx_GIVEREF(__pyx_v_b_url); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_b_url); + __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; goto __pyx_L0; /* "cgurl.pyx":160 * * * def urlsplit(url): # <<<<<<<<<<<<<< - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * + * cdef bytes b_url + * if isinstance(url, unicode): */ /* 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_8); __Pyx_AddTraceback("cgurl.urlsplit", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_b_url); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "cgurl.pyx":163 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) +/* "cgurl.pyx":168 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: @@ -3125,7 +3187,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ case 1: 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, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, 1); __PYX_ERR(0, 168, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -3135,7 +3197,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 163, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 168, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3153,14 +3215,14 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 163, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 168, __pyx_L3_error) __pyx_L3_error:; __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, 163, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 163, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyBytes_Type), 1, "base", 1))) __PYX_ERR(0, 168, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 168, __pyx_L1_error) __pyx_r = __pyx_pf_5cgurl_2urljoin(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); /* function exit code */ @@ -3185,14 +3247,14 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urljoin", 0); - /* "cgurl.pyx":164 + /* "cgurl.pyx":169 * * 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, 164, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_allow_fragments); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 169, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; @@ -3203,7 +3265,7 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":165 + /* "cgurl.pyx":170 * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: * return GURL(base).Resolve(url).spec() # <<<<<<<<<<<<<< @@ -3211,15 +3273,15 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py * 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, 165, __pyx_L1_error) - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __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, 165, __pyx_L1_error) + __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_v_base); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 170, __pyx_L1_error) + __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 170, __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, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "cgurl.pyx":164 + /* "cgurl.pyx":169 * * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: # <<<<<<<<<<<<<< @@ -3228,16 +3290,16 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py */ } - /* "cgurl.pyx":167 + /* "cgurl.pyx":172 * return GURL(base).Resolve(url).spec() * else: * return stdlib_urljoin(base, url, allow_fragments=allow_fragments) # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_base); __Pyx_GIVEREF(__pyx_v_base); @@ -3245,10 +3307,10 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __Pyx_INCREF(__pyx_v_url); __Pyx_GIVEREF(__pyx_v_url); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_url); - __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 167, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 172, __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, 167, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 167, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_allow_fragments, __pyx_v_allow_fragments) < 0) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -3258,8 +3320,8 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py goto __pyx_L0; } - /* "cgurl.pyx":163 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + /* "cgurl.pyx":168 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: @@ -3695,6 +3757,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_SplitResultNamedTuple_geturl, __pyx_k_SplitResultNamedTuple_geturl, sizeof(__pyx_k_SplitResultNamedTuple_geturl), 0, 0, 1, 1}, {&__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_b_url, __pyx_k_b_url, sizeof(__pyx_k_b_url), 0, 0, 1, 1}, {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 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}, @@ -3787,25 +3850,25 @@ static int __Pyx_InitCachedConstants(void) { * * * def urlsplit(url): # <<<<<<<<<<<<<< - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * + * cdef bytes b_url + * if isinstance(url, unicode): */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_tuple__8 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_b_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 160, __pyx_L1_error) - /* "cgurl.pyx":163 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + /* "cgurl.pyx":168 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __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, 163, __pyx_L1_error) + __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, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); - __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 163, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 168, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -4181,24 +4244,24 @@ if (!__Pyx_RefNanny) { * * * def urlsplit(url): # <<<<<<<<<<<<<< - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) - * + * cdef bytes b_url + * if isinstance(url, unicode): */ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 160, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "cgurl.pyx":163 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + /* "cgurl.pyx":168 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 163, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 168, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "cgurl.pyx":1 From 7fb618a81d96cdbce81fee0e8593db6617220a6c Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 15:36:06 -0500 Subject: [PATCH 20/38] indentation --- urlparse4/cgurl.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index 72c7def..3b7ba84 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -1,9 +1,13 @@ from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL 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"" From 452a430da16d13b1180f84fad3669dc2ee725196 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 15:41:38 -0500 Subject: [PATCH 21/38] convert result to unicode on python2 --- urlparse4/cgurl.pyx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index 3b7ba84..79a413f 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -149,13 +149,22 @@ 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) - )) + if six.PY2: + return tuple.__new__(cls, ( + unicode(slice_component(url, parsed.scheme).lower()), + unicode(build_netloc(url, parsed)), + unicode(slice_component(url, parsed.path)), + unicode(slice_component(url, parsed.query)), + unicode(slice_component(url, parsed.ref)) + )) + else: + 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) + )) def geturl(self): return stdlib_urlunsplit(self) From feebe43d0f6a7a889a804c5f5b44f323e648a323 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Thu, 7 Jun 2018 15:41:48 -0500 Subject: [PATCH 22/38] compile cython on py3 --- urlparse4/cgurl.cpp | 1055 ++++++++++++++++++++++++++----------------- 1 file changed, 648 insertions(+), 407 deletions(-) diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index ddcaca3..3958e5d 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -850,7 +850,7 @@ static const char *__pyx_f[] = { /*--- Type declarations ---*/ struct __pyx_obj_5cgurl___pyx_scope_struct____new__; -/* "cgurl.pyx":112 +/* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -1144,6 +1144,15 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr /* GetModuleGlobalName.proto */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); +/* PyObject_Unicode.proto */ +#if PY_MAJOR_VERSION >= 3 +#define __Pyx_PyObject_Unicode(obj)\ + (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj)) +#else +#define __Pyx_PyObject_Unicode(obj)\ + (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Unicode(obj)) +#endif + /* 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); @@ -1261,9 +1270,11 @@ int __pyx_module_is_main_cgurl = 0; /* 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_six[] = "six"; static const char __pyx_k_url[] = "url"; static const char __pyx_k_base[] = "base"; static const char __pyx_k_file[] = "file:"; @@ -1308,6 +1319,7 @@ static const char __pyx_k_SplitResultNamedTuple___new[] = "SplitResultNamedTuple static const char __pyx_k_SplitResultNamedTuple_geturl[] = "SplitResultNamedTuple.geturl"; 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; @@ -1343,6 +1355,7 @@ static PyObject *__pyx_n_s_qualname; static PyObject *__pyx_n_s_query; 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_urljoin; @@ -1373,8 +1386,8 @@ static PyObject *__pyx_codeobj__9; static PyObject *__pyx_codeobj__11; /* Late includes */ -/* "cgurl.pyx":7 - * cimport cython +/* "cgurl.pyx":11 + * * * cdef bytes slice_component(bytes pyurl, Component comp): # <<<<<<<<<<<<<< * if comp.len <= 0: @@ -1388,7 +1401,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("slice_component", 0); - /* "cgurl.pyx":8 + /* "cgurl.pyx":12 * * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1398,7 +1411,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct __pyx_t_1 = ((__pyx_v_comp.len <= 0) != 0); if (__pyx_t_1) { - /* "cgurl.pyx":9 + /* "cgurl.pyx":13 * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1410,7 +1423,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct __pyx_r = __pyx_kp_b_; goto __pyx_L0; - /* "cgurl.pyx":8 + /* "cgurl.pyx":12 * * cdef bytes slice_component(bytes pyurl, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1419,7 +1432,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct */ } - /* "cgurl.pyx":11 + /* "cgurl.pyx":15 * return b"" * * return pyurl[comp.begin:comp.begin + comp.len] # <<<<<<<<<<<<<< @@ -1429,16 +1442,16 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_pyurl == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 11, __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, 11, __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; - /* "cgurl.pyx":7 - * cimport cython + /* "cgurl.pyx":11 + * * * cdef bytes slice_component(bytes pyurl, Component comp): # <<<<<<<<<<<<<< * if comp.len <= 0: @@ -1456,7 +1469,7 @@ static PyObject *__pyx_f_5cgurl_slice_component(PyObject *__pyx_v_pyurl, struct return __pyx_r; } -/* "cgurl.pyx":14 +/* "cgurl.pyx":18 * * * cdef bytes cslice_component(char * url, Component comp): # <<<<<<<<<<<<<< @@ -1471,7 +1484,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: PyObject *__pyx_t_2 = NULL; __Pyx_RefNannySetupContext("cslice_component", 0); - /* "cgurl.pyx":15 + /* "cgurl.pyx":19 * * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1481,7 +1494,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: __pyx_t_1 = ((__pyx_v_comp.len <= 0) != 0); if (__pyx_t_1) { - /* "cgurl.pyx":16 + /* "cgurl.pyx":20 * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1493,7 +1506,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: __pyx_r = __pyx_kp_b_; goto __pyx_L0; - /* "cgurl.pyx":15 + /* "cgurl.pyx":19 * * cdef bytes cslice_component(char * url, Component comp): * if comp.len <= 0: # <<<<<<<<<<<<<< @@ -1502,7 +1515,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":19 + /* "cgurl.pyx":23 * * # TODO: check if std::string brings any speedups * return url[comp.begin:comp.begin + comp.len] # <<<<<<<<<<<<<< @@ -1510,13 +1523,13 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: * */ __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, 19, __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; - /* "cgurl.pyx":14 + /* "cgurl.pyx":18 * * * cdef bytes cslice_component(char * url, Component comp): # <<<<<<<<<<<<<< @@ -1535,7 +1548,7 @@ static PyObject *__pyx_f_5cgurl_cslice_component(char *__pyx_v_url, struct url:: return __pyx_r; } -/* "cgurl.pyx":22 +/* "cgurl.pyx":26 * * * cdef bytes build_netloc(bytes url, Parsed parsed): # <<<<<<<<<<<<<< @@ -1551,7 +1564,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: PyObject *__pyx_t_3 = NULL; __Pyx_RefNannySetupContext("build_netloc", 0); - /* "cgurl.pyx":24 + /* "cgurl.pyx":28 * cdef bytes build_netloc(bytes url, Parsed parsed): * * if parsed.host.len <= 0: # <<<<<<<<<<<<<< @@ -1561,7 +1574,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_t_1 = ((__pyx_v_parsed.host.len <= 0) != 0); if (__pyx_t_1) { - /* "cgurl.pyx":25 + /* "cgurl.pyx":29 * * if parsed.host.len <= 0: * return b"" # <<<<<<<<<<<<<< @@ -1573,7 +1586,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_r = __pyx_kp_b_; goto __pyx_L0; - /* "cgurl.pyx":24 + /* "cgurl.pyx":28 * cdef bytes build_netloc(bytes url, Parsed parsed): * * if parsed.host.len <= 0: # <<<<<<<<<<<<<< @@ -1582,7 +1595,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":28 + /* "cgurl.pyx":32 * * # Nothing at all * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1606,7 +1619,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":29 + /* "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] # <<<<<<<<<<<<<< @@ -1616,15 +1629,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 29, __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, 29, __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; - /* "cgurl.pyx":28 + /* "cgurl.pyx":32 * * # Nothing at all * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1633,7 +1646,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":32 + /* "cgurl.pyx":36 * * # Only port * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1657,7 +1670,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L7_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":33 + /* "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] # <<<<<<<<<<<<<< @@ -1667,15 +1680,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 33, __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, 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) + 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; - /* "cgurl.pyx":32 + /* "cgurl.pyx":36 * * # Only port * elif parsed.username.len <= 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1684,7 +1697,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":36 + /* "cgurl.pyx":40 * * # Only username * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1708,7 +1721,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L10_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":37 + /* "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] # <<<<<<<<<<<<<< @@ -1718,15 +1731,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 37, __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, 37, __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; - /* "cgurl.pyx":36 + /* "cgurl.pyx":40 * * # Only username * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1735,7 +1748,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":40 + /* "cgurl.pyx":44 * * # Username + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1759,7 +1772,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L13_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":41 + /* "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] # <<<<<<<<<<<<<< @@ -1769,15 +1782,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 41, __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, 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) + 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; - /* "cgurl.pyx":40 + /* "cgurl.pyx":44 * * # Username + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len <= 0: # <<<<<<<<<<<<<< @@ -1786,7 +1799,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":44 + /* "cgurl.pyx":48 * * # Username + port * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1810,7 +1823,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L16_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":45 + /* "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] # <<<<<<<<<<<<<< @@ -1820,15 +1833,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 45, __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, 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.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; - /* "cgurl.pyx":44 + /* "cgurl.pyx":48 * * # Username + port * elif parsed.username.len > 0 and parsed.password.len <= 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1837,7 +1850,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":48 + /* "cgurl.pyx":52 * * # Username + port + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1861,7 +1874,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __pyx_L19_bool_binop_done:; if (likely(__pyx_t_1)) { - /* "cgurl.pyx":49 + /* "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] # <<<<<<<<<<<<<< @@ -1871,15 +1884,15 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: __Pyx_XDECREF(__pyx_r); if (unlikely(__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 49, __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, 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) + 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; - /* "cgurl.pyx":48 + /* "cgurl.pyx":52 * * # Username + port + password * elif parsed.username.len > 0 and parsed.password.len > 0 and parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -1888,7 +1901,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ } - /* "cgurl.pyx":52 + /* "cgurl.pyx":56 * * else: * raise ValueError # <<<<<<<<<<<<<< @@ -1897,10 +1910,10 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: */ /*else*/ { __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0); - __PYX_ERR(0, 52, __pyx_L1_error) + __PYX_ERR(0, 56, __pyx_L1_error) } - /* "cgurl.pyx":22 + /* "cgurl.pyx":26 * * * cdef bytes build_netloc(bytes url, Parsed parsed): # <<<<<<<<<<<<<< @@ -1919,7 +1932,7 @@ static PyObject *__pyx_f_5cgurl_build_netloc(PyObject *__pyx_v_url, struct url:: return __pyx_r; } -/* "cgurl.pyx":112 +/* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -1959,11 +1972,11 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__py case 1: 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, 112, __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, 112, __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; @@ -1976,13 +1989,13 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__new__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 112, __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("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, 112, __pyx_L1_error) + 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 */ @@ -1994,7 +2007,7 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_1__new__(PyObject *__py return __pyx_r; } -/* "cgurl.pyx":121 +/* "cgurl.pyx":125 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< @@ -2034,11 +2047,11 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr(PyO case 1: 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, 121, __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, 121, __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; @@ -2051,7 +2064,7 @@ static PyObject *__pyx_pw_5cgurl_21SplitResultNamedTuple_7__new___1_get_attr(PyO } 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, 121, __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("cgurl.SplitResultNamedTuple.__new__._get_attr", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -2078,17 +2091,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_outer_scope = (struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *) __Pyx_CyFunction_GetClosure(__pyx_self); __pyx_cur_scope = __pyx_outer_scope; - /* "cgurl.pyx":122 + /* "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, 122, __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) { - /* "cgurl.pyx":123 + /* "cgurl.pyx":127 * def _get_attr(self, prop): * if prop == "scheme": * return self[0] # <<<<<<<<<<<<<< @@ -2096,13 +2109,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 123, __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; - /* "cgurl.pyx":122 + /* "cgurl.pyx":126 * * def _get_attr(self, prop): * if prop == "scheme": # <<<<<<<<<<<<<< @@ -2111,17 +2124,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":124 + /* "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, 124, __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) { - /* "cgurl.pyx":125 + /* "cgurl.pyx":129 * return self[0] * elif prop == "netloc": * return self[1] # <<<<<<<<<<<<<< @@ -2129,13 +2142,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 125, __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; - /* "cgurl.pyx":124 + /* "cgurl.pyx":128 * if prop == "scheme": * return self[0] * elif prop == "netloc": # <<<<<<<<<<<<<< @@ -2144,17 +2157,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":126 + /* "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, 126, __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) { - /* "cgurl.pyx":127 + /* "cgurl.pyx":131 * return self[1] * elif prop == "path": * return self[2] # <<<<<<<<<<<<<< @@ -2162,13 +2175,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 127, __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; - /* "cgurl.pyx":126 + /* "cgurl.pyx":130 * elif prop == "netloc": * return self[1] * elif prop == "path": # <<<<<<<<<<<<<< @@ -2177,17 +2190,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":128 + /* "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, 128, __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) { - /* "cgurl.pyx":129 + /* "cgurl.pyx":133 * return self[2] * elif prop == "query": * return self[3] # <<<<<<<<<<<<<< @@ -2195,13 +2208,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 129, __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; - /* "cgurl.pyx":128 + /* "cgurl.pyx":132 * elif prop == "path": * return self[2] * elif prop == "query": # <<<<<<<<<<<<<< @@ -2210,17 +2223,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":130 + /* "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, 130, __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) { - /* "cgurl.pyx":131 + /* "cgurl.pyx":135 * return self[3] * elif prop == "fragment": * return self[4] # <<<<<<<<<<<<<< @@ -2228,13 +2241,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 131, __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; - /* "cgurl.pyx":130 + /* "cgurl.pyx":134 * elif prop == "query": * return self[3] * elif prop == "fragment": # <<<<<<<<<<<<<< @@ -2243,17 +2256,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":132 + /* "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, 132, __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) { - /* "cgurl.pyx":133 + /* "cgurl.pyx":137 * return self[4] * elif prop == "port": * if parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -2263,38 +2276,38 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_t_1 = ((__pyx_cur_scope->__pyx_v_parsed.port.len > 0) != 0); if (__pyx_t_1) { - /* "cgurl.pyx":134 + /* "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, 134, __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_5cgurl_slice_component(((PyObject*)__pyx_t_2), __pyx_cur_scope->__pyx_v_parsed.port); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __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, 134, __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; - /* "cgurl.pyx":135 + /* "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, 135, __pyx_L1_error) - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 135, __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) { - /* "cgurl.pyx":136 + /* "cgurl.pyx":140 * port = int(slice_component(url, parsed.port)) * if port <= 65535: * return port # <<<<<<<<<<<<<< @@ -2306,7 +2319,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_r = __pyx_v_port; goto __pyx_L0; - /* "cgurl.pyx":135 + /* "cgurl.pyx":139 * if parsed.port.len > 0: * port = int(slice_component(url, parsed.port)) * if port <= 65535: # <<<<<<<<<<<<<< @@ -2315,7 +2328,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":133 + /* "cgurl.pyx":137 * return self[4] * elif prop == "port": * if parsed.port.len > 0: # <<<<<<<<<<<<<< @@ -2324,7 +2337,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":132 + /* "cgurl.pyx":136 * elif prop == "fragment": * return self[4] * elif prop == "port": # <<<<<<<<<<<<<< @@ -2334,17 +2347,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb goto __pyx_L3; } - /* "cgurl.pyx":138 + /* "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, 138, __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) { - /* "cgurl.pyx":139 + /* "cgurl.pyx":143 * * elif prop == "username": * return slice_component(url, parsed.username) or None # <<<<<<<<<<<<<< @@ -2352,13 +2365,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 139, __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_5cgurl_slice_component(((PyObject*)__pyx_t_3), __pyx_cur_scope->__pyx_v_parsed.username); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 139, __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, 139, __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 { @@ -2374,7 +2387,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_t_2 = 0; goto __pyx_L0; - /* "cgurl.pyx":138 + /* "cgurl.pyx":142 * return port * * elif prop == "username": # <<<<<<<<<<<<<< @@ -2383,17 +2396,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":140 + /* "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, 140, __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) { - /* "cgurl.pyx":141 + /* "cgurl.pyx":145 * return slice_component(url, parsed.username) or None * elif prop == "password": * return slice_component(url, parsed.password) or None # <<<<<<<<<<<<<< @@ -2401,13 +2414,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * 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, 141, __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_5cgurl_slice_component(((PyObject*)__pyx_t_4), __pyx_cur_scope->__pyx_v_parsed.password); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __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, 141, __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 { @@ -2423,7 +2436,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_t_2 = 0; goto __pyx_L0; - /* "cgurl.pyx":140 + /* "cgurl.pyx":144 * elif prop == "username": * return slice_component(url, parsed.username) or None * elif prop == "password": # <<<<<<<<<<<<<< @@ -2432,17 +2445,17 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb */ } - /* "cgurl.pyx":142 + /* "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, 142, __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) { - /* "cgurl.pyx":143 + /* "cgurl.pyx":147 * return slice_component(url, parsed.password) or None * elif prop == "hostname": * return slice_component(url, parsed.host).lower() # <<<<<<<<<<<<<< @@ -2450,13 +2463,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb * */ __Pyx_XDECREF(__pyx_r); - if (unlikely(!__pyx_cur_scope->__pyx_v_url)) { __Pyx_RaiseClosureNameError("url"); __PYX_ERR(0, 143, __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_5cgurl_slice_component(((PyObject*)__pyx_t_3), __pyx_cur_scope->__pyx_v_parsed.host); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __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, 143, __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; @@ -2470,10 +2483,10 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb } } if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 143, __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, 143, __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; @@ -2481,7 +2494,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb __pyx_t_2 = 0; goto __pyx_L0; - /* "cgurl.pyx":142 + /* "cgurl.pyx":146 * elif prop == "password": * return slice_component(url, parsed.password) or None * elif prop == "hostname": # <<<<<<<<<<<<<< @@ -2491,7 +2504,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb } __pyx_L3:; - /* "cgurl.pyx":121 + /* "cgurl.pyx":125 * ParseStandardURL(url, len(url), &parsed) * * def _get_attr(self, prop): # <<<<<<<<<<<<<< @@ -2515,7 +2528,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb return __pyx_r; } -/* "cgurl.pyx":112 +/* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -2547,7 +2560,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_5cgurl___pyx_scope_struct____new__ *)Py_None); __Pyx_INCREF(Py_None); - __PYX_ERR(0, 112, __pyx_L1_error) + __PYX_ERR(0, 116, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } @@ -2555,7 +2568,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P __Pyx_INCREF(__pyx_cur_scope->__pyx_v_url); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_url); - /* "cgurl.pyx":116 + /* "cgurl.pyx":120 * cdef Parsed parsed * * if url[0:5] == b"file:": # <<<<<<<<<<<<<< @@ -2564,16 +2577,16 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P */ if (unlikely(__pyx_cur_scope->__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 116, __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, 116, __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, 116, __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) { - /* "cgurl.pyx":117 + /* "cgurl.pyx":121 * * if url[0:5] == b"file:": * ParseFileURL(url, len(url), &parsed) # <<<<<<<<<<<<<< @@ -2582,20 +2595,20 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P */ if (unlikely(__pyx_cur_scope->__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 117, __pyx_L1_error) + __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, 117, __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, 117, __pyx_L1_error) + __PYX_ERR(0, 121, __pyx_L1_error) } - __pyx_t_5 = PyBytes_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 117, __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)); - /* "cgurl.pyx":116 + /* "cgurl.pyx":120 * cdef Parsed parsed * * if url[0:5] == b"file:": # <<<<<<<<<<<<<< @@ -2605,7 +2618,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P goto __pyx_L3; } - /* "cgurl.pyx":119 + /* "cgurl.pyx":123 * ParseFileURL(url, len(url), &parsed) * else: * ParseStandardURL(url, len(url), &parsed) # <<<<<<<<<<<<<< @@ -2615,215 +2628,429 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P /*else*/ { if (unlikely(__pyx_cur_scope->__pyx_v_url == Py_None)) { PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 119, __pyx_L1_error) + __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, 119, __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, 119, __pyx_L1_error) + __PYX_ERR(0, 123, __pyx_L1_error) } - __pyx_t_5 = PyBytes_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 119, __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:; - /* "cgurl.pyx":121 + /* "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_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, 121, __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; - /* "cgurl.pyx":146 + /* "cgurl.pyx":150 * * * cls.__getattr__ = _get_attr # <<<<<<<<<<<<<< * - * return tuple.__new__(cls, ( + * if six.PY2: */ - if (__Pyx_PyObject_SetAttrStr(__pyx_v_cls, __pyx_n_s_getattr, __pyx_v__get_attr) < 0) __PYX_ERR(0, 146, __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) - /* "cgurl.pyx":148 + /* "cgurl.pyx":152 * cls.__getattr__ = _get_attr * - * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< - * slice_component(url, parsed.scheme).lower(), - * build_netloc(url, parsed), + * if six.PY2: # <<<<<<<<<<<<<< + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), */ - __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, 148, __pyx_L1_error) + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PY2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 152, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (__pyx_t_3) { - /* "cgurl.pyx":149 - * - * 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_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 149, __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, 149, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = NULL; - if (CYTHON_UNPACK_METHODS && 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_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); + /* "cgurl.pyx":153 + * + * if six.PY2: + * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< + * unicode(slice_component(url, parsed.scheme).lower()), + * unicode(build_netloc(url, parsed)), + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + + /* "cgurl.pyx":154 + * if six.PY2: + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), # <<<<<<<<<<<<<< + * unicode(build_netloc(url, parsed)), + * unicode(slice_component(url, parsed.path)), + */ + __pyx_t_9 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_9); + __pyx_t_10 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 154, __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, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + if (CYTHON_UNPACK_METHODS && 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_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, 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, 149, __pyx_L1_error) + if (__pyx_t_10) { + __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } else { + __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 154, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_Unicode(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + + /* "cgurl.pyx":155 + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), + * unicode(build_netloc(url, parsed)), # <<<<<<<<<<<<<< + * unicode(slice_component(url, parsed.path)), + * unicode(slice_component(url, parsed.query)), + */ + __pyx_t_8 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_8); + __pyx_t_10 = __pyx_f_5cgurl_build_netloc(((PyObject*)__pyx_t_8), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 155, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_PyObject_Unicode(__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 155, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else { - __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "cgurl.pyx":150 - * 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_5cgurl_build_netloc(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 150, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "cgurl.pyx":151 - * 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_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + /* "cgurl.pyx":156 + * unicode(slice_component(url, parsed.scheme).lower()), + * unicode(build_netloc(url, parsed)), + * unicode(slice_component(url, parsed.path)), # <<<<<<<<<<<<<< + * unicode(slice_component(url, parsed.query)), + * unicode(slice_component(url, parsed.ref)) + */ + __pyx_t_10 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_10); + __pyx_t_11 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_10), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_Unicode(__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 156, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + + /* "cgurl.pyx":157 + * unicode(build_netloc(url, parsed)), + * unicode(slice_component(url, parsed.path)), + * unicode(slice_component(url, parsed.query)), # <<<<<<<<<<<<<< + * unicode(slice_component(url, parsed.ref)) + * )) + */ + __pyx_t_11 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_11); + __pyx_t_12 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_11), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyObject_Unicode(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 157, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - /* "cgurl.pyx":152 - * 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_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "cgurl.pyx":153 - * 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_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - - /* "cgurl.pyx":149 - * - * 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, 149, __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_t_8 = 0; - __pyx_t_10 = 0; - __pyx_t_11 = 0; - __pyx_t_12 = 0; - __pyx_t_13 = 0; - __pyx_t_13 = NULL; - __pyx_t_14 = 0; - if (CYTHON_UNPACK_METHODS && 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_14 = 1; + /* "cgurl.pyx":158 + * unicode(slice_component(url, parsed.path)), + * unicode(slice_component(url, parsed.query)), + * unicode(slice_component(url, parsed.ref)) # <<<<<<<<<<<<<< + * )) + * else: + */ + __pyx_t_12 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_12); + __pyx_t_13 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_12), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyObject_Unicode(__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 158, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":154 + * if six.PY2: + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), # <<<<<<<<<<<<<< + * unicode(build_netloc(url, parsed)), + * unicode(slice_component(url, parsed.path)), + */ + __pyx_t_13 = PyTuple_New(5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 154, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_t_12); + __pyx_t_9 = 0; + __pyx_t_8 = 0; + __pyx_t_10 = 0; + __pyx_t_11 = 0; + __pyx_t_12 = 0; + __pyx_t_12 = NULL; + __pyx_t_14 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_14 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_cls, __pyx_t_13}; + __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_cls, __pyx_t_13}; + __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + { + __pyx_t_11 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_12) { + __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12); __pyx_t_12 = NULL; + } + __Pyx_INCREF(__pyx_v_cls); + __Pyx_GIVEREF(__pyx_v_cls); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_14, __pyx_v_cls); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_14, __pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; + + /* "cgurl.pyx":152 + * cls.__getattr__ = _get_attr + * + * if six.PY2: # <<<<<<<<<<<<<< + * return tuple.__new__(cls, ( + * unicode(slice_component(url, parsed.scheme).lower()), + */ } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_cls, __pyx_t_9}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_13, __pyx_v_cls, __pyx_t_9}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":161 + * )) + * else: + * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< + * slice_component(url, parsed.scheme).lower(), + * build_netloc(url, parsed), + */ + /*else*/ { + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_12 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 148, __pyx_L1_error) + + /* "cgurl.pyx":162 + * else: + * return tuple.__new__(cls, ( + * slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< + * build_netloc(url, parsed), + * slice_component(url, parsed.path), + */ + __pyx_t_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_12 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 162, __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_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_lower); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = NULL; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_13, function); + } } - __Pyx_INCREF(__pyx_v_cls); - __Pyx_GIVEREF(__pyx_v_cls); - PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_14, __pyx_v_cls); + if (__pyx_t_12) { + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } else { + __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 162, __pyx_L1_error) + } + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":163 + * 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_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_12 = __pyx_f_5cgurl_build_netloc(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 163, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":164 + * 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_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_10 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 164, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":165 + * build_netloc(url, parsed), + * slice_component(url, parsed.path), + * slice_component(url, parsed.query), # <<<<<<<<<<<<<< + * slice_component(url, parsed.ref) + * )) + */ + __pyx_t_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_8 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 165, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":166 + * slice_component(url, parsed.path), + * slice_component(url, parsed.query), + * slice_component(url, parsed.ref) # <<<<<<<<<<<<<< + * )) + * + */ + __pyx_t_13 = __pyx_cur_scope->__pyx_v_url; + __Pyx_INCREF(__pyx_t_13); + __pyx_t_9 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 166, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + + /* "cgurl.pyx":162 + * else: + * return tuple.__new__(cls, ( + * slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< + * build_netloc(url, parsed), + * slice_component(url, parsed.path), + */ + __pyx_t_13 = PyTuple_New(5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 162, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_14, __pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_t_9); + __pyx_t_11 = 0; + __pyx_t_12 = 0; + __pyx_t_10 = 0; + __pyx_t_8 = 0; __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, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_9 = NULL; + __pyx_t_14 = 0; + if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_14 = 1; + } + } + #if CYTHON_FAST_PYCALL + if (PyFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_cls, __pyx_t_13}; + __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + #if CYTHON_FAST_PYCCALL + if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { + PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_cls, __pyx_t_13}; + __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + } else + #endif + { + __pyx_t_8 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_9) { + __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_INCREF(__pyx_v_cls); + __Pyx_GIVEREF(__pyx_v_cls); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_14, __pyx_v_cls); + __Pyx_GIVEREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_14, __pyx_t_13); + __pyx_t_13 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - /* "cgurl.pyx":112 + /* "cgurl.pyx":116 * __slots__ = () # prevent creation of instance dictionary * * def __new__(cls, bytes url): # <<<<<<<<<<<<<< @@ -2851,8 +3078,8 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P return __pyx_r; } -/* "cgurl.pyx":156 - * )) +/* "cgurl.pyx":169 + * )) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) @@ -2882,7 +3109,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("geturl", 0); - /* "cgurl.pyx":157 + /* "cgurl.pyx":170 * * def geturl(self): * return stdlib_urlunsplit(self) # <<<<<<<<<<<<<< @@ -2890,7 +3117,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urlunsplit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urlunsplit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -2903,13 +3130,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P } } if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __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_self}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_1); } else @@ -2917,19 +3144,19 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P #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, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __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, 157, __pyx_L1_error) + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 170, __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, 157, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } @@ -2939,8 +3166,8 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P __pyx_t_1 = 0; goto __pyx_L0; - /* "cgurl.pyx":156 - * )) + /* "cgurl.pyx":169 + * )) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) @@ -2961,7 +3188,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P return __pyx_r; } -/* "cgurl.pyx":160 +/* "cgurl.pyx":173 * * * def urlsplit(url): # <<<<<<<<<<<<<< @@ -2997,7 +3224,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urlsplit", 0); - /* "cgurl.pyx":162 + /* "cgurl.pyx":175 * def urlsplit(url): * cdef bytes b_url * if isinstance(url, unicode): # <<<<<<<<<<<<<< @@ -3008,7 +3235,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "cgurl.pyx":163 + /* "cgurl.pyx":176 * cdef bytes b_url * if isinstance(url, unicode): * b_url = (url).encode('utf8') # <<<<<<<<<<<<<< @@ -3017,9 +3244,9 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py */ if (unlikely(__pyx_v_url == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); - __PYX_ERR(0, 163, __pyx_L1_error) + __PYX_ERR(0, 176, __pyx_L1_error) } - __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_url)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error) + __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_url)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); @@ -3027,7 +3254,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_v_b_url = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cgurl.pyx":162 + /* "cgurl.pyx":175 * def urlsplit(url): * cdef bytes b_url * if isinstance(url, unicode): # <<<<<<<<<<<<<< @@ -3037,7 +3264,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py goto __pyx_L3; } - /* "cgurl.pyx":165 + /* "cgurl.pyx":178 * b_url = (url).encode('utf8') * else: * b_url = url # <<<<<<<<<<<<<< @@ -3045,7 +3272,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py * */ /*else*/ { - if (!(likely(PyBytes_CheckExact(__pyx_v_url))||((__pyx_v_url) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_url)->tp_name), 0))) __PYX_ERR(0, 165, __pyx_L1_error) + if (!(likely(PyBytes_CheckExact(__pyx_v_url))||((__pyx_v_url) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_url)->tp_name), 0))) __PYX_ERR(0, 178, __pyx_L1_error) __pyx_t_4 = __pyx_v_url; __Pyx_INCREF(__pyx_t_4); __pyx_v_b_url = ((PyObject*)__pyx_t_4); @@ -3053,7 +3280,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py } __pyx_L3:; - /* "cgurl.pyx":166 + /* "cgurl.pyx":179 * else: * b_url = url * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) # <<<<<<<<<<<<<< @@ -3061,12 +3288,12 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py * def urljoin(bytes base, bytes url, allow_fragments=True): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_7 = 0; @@ -3083,7 +3310,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -3092,14 +3319,14 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; @@ -3110,7 +3337,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __Pyx_GIVEREF(__pyx_v_b_url); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_b_url); __pyx_t_3 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } @@ -3119,7 +3346,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_t_4 = 0; goto __pyx_L0; - /* "cgurl.pyx":160 + /* "cgurl.pyx":173 * * * def urlsplit(url): # <<<<<<<<<<<<<< @@ -3143,7 +3370,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py return __pyx_r; } -/* "cgurl.pyx":168 +/* "cgurl.pyx":181 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< @@ -3187,7 +3414,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ case 1: 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, 168, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, 1); __PYX_ERR(0, 181, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -3197,7 +3424,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 168, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 181, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3215,14 +3442,14 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 168, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 181, __pyx_L3_error) __pyx_L3_error:; __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, 168, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 168, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyBytes_Type), 1, "base", 1))) __PYX_ERR(0, 181, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 181, __pyx_L1_error) __pyx_r = __pyx_pf_5cgurl_2urljoin(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); /* function exit code */ @@ -3247,14 +3474,14 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urljoin", 0); - /* "cgurl.pyx":169 + /* "cgurl.pyx":182 * * 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, 169, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_allow_fragments); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 182, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; @@ -3265,7 +3492,7 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":170 + /* "cgurl.pyx":183 * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: * return GURL(base).Resolve(url).spec() # <<<<<<<<<<<<<< @@ -3273,15 +3500,15 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py * 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, 170, __pyx_L1_error) - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 170, __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, 170, __pyx_L1_error) + __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_v_base); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L1_error) + __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __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, 183, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "cgurl.pyx":169 + /* "cgurl.pyx":182 * * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: # <<<<<<<<<<<<<< @@ -3290,16 +3517,16 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py */ } - /* "cgurl.pyx":172 + /* "cgurl.pyx":185 * return GURL(base).Resolve(url).spec() * else: * return stdlib_urljoin(base, url, allow_fragments=allow_fragments) # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_base); __Pyx_GIVEREF(__pyx_v_base); @@ -3307,10 +3534,10 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __Pyx_INCREF(__pyx_v_url); __Pyx_GIVEREF(__pyx_v_url); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_url); - __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 172, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __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, 172, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 172, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_allow_fragments, __pyx_v_allow_fragments) < 0) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 185, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -3320,7 +3547,7 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py goto __pyx_L0; } - /* "cgurl.pyx":168 + /* "cgurl.pyx":181 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< @@ -3751,6 +3978,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}, @@ -3786,6 +4014,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 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_urljoin, __pyx_k_stdlib_urljoin, sizeof(__pyx_k_stdlib_urljoin), 0, 0, 1, 1}, @@ -3800,7 +4029,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {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, 52, __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; @@ -3810,65 +4039,65 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "cgurl.pyx":121 + /* "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, 121, __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, 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, 121, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(0, 121, __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) - /* "cgurl.pyx":112 + /* "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, 112, __pyx_L1_error) + __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, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); - __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_new, 112, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 112, __pyx_L1_error) + __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_new, 116, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 116, __pyx_L1_error) - /* "cgurl.pyx":156 - * )) + /* "cgurl.pyx":169 + * )) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) * */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); - __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_geturl, 156, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 156, __pyx_L1_error) + __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_geturl, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 169, __pyx_L1_error) - /* "cgurl.pyx":160 + /* "cgurl.pyx":173 * * * def urlsplit(url): # <<<<<<<<<<<<<< * cdef bytes b_url * if isinstance(url, unicode): */ - __pyx_tuple__8 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_b_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_tuple__8 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_b_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__8); __Pyx_GIVEREF(__pyx_tuple__8); - __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 160, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 173, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 173, __pyx_L1_error) - /* "cgurl.pyx":168 + /* "cgurl.pyx":181 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __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, 168, __pyx_L1_error) + __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, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__10); __Pyx_GIVEREF(__pyx_tuple__10); - __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 168, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 168, __pyx_L1_error) + __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -3920,7 +4149,7 @@ 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, 112, __pyx_L1_error) + 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; @@ -4133,141 +4362,153 @@ if (!__Pyx_RefNanny) { if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) #endif - /* "cgurl.pyx":3 - * from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL + /* "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 - * cimport cython + * */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error) + __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, 3, __pyx_L1_error) + __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, 3, __pyx_L1_error) + __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, 3, __pyx_L1_error) + 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":4 - * from urlparse4.chromium_gurl cimport GURL + /* "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 * + * cimport cython */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4, __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, 4, __pyx_L1_error) + __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); __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, 4, __pyx_L1_error) + __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, 4, __pyx_L1_error) + 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; - /* "cgurl.pyx":108 + /* "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, 108, __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, 108, __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_cgurl, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 108, __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); - /* "cgurl.pyx":110 + /* "cgurl.pyx":114 * class SplitResultNamedTuple(tuple): * * __slots__ = () # prevent creation of instance dictionary # <<<<<<<<<<<<<< * * def __new__(cls, bytes url): */ - if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_slots, __pyx_empty_tuple) < 0) __PYX_ERR(0, 110, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_slots, __pyx_empty_tuple) < 0) __PYX_ERR(0, 114, __pyx_L1_error) - /* "cgurl.pyx":112 + /* "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_5cgurl_21SplitResultNamedTuple_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_SplitResultNamedTuple___new, NULL, __pyx_n_s_cgurl, __pyx_d, ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 112, __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__5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_new, __pyx_t_4) < 0) __PYX_ERR(0, 112, __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; - /* "cgurl.pyx":156 - * )) + /* "cgurl.pyx":169 + * )) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) * */ - __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__7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __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__7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_geturl, __pyx_t_4) < 0) __PYX_ERR(0, 156, __pyx_L1_error) + if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_geturl, __pyx_t_4) < 0) __PYX_ERR(0, 169, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "cgurl.pyx":108 + /* "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, 108, __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, 108, __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; - /* "cgurl.pyx":160 + /* "cgurl.pyx":173 * * * def urlsplit(url): # <<<<<<<<<<<<<< * cdef bytes b_url * if isinstance(url, unicode): */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 160, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "cgurl.pyx":168 + /* "cgurl.pyx":181 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 168, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "cgurl.pyx":1 * from urlparse4.mozilla_url_parse cimport Component, Parsed, ParseStandardURL, ParseFileURL # <<<<<<<<<<<<<< * from urlparse4.chromium_gurl cimport GURL - * from six.moves.urllib.parse import urljoin as stdlib_urljoin + * */ __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); From 65d927dd5e05bc2d7bf1c924fcdba6ef714fe8e8 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Fri, 8 Jun 2018 12:10:57 -0500 Subject: [PATCH 23/38] decode in cython --- urlparse4/cgurl.pyx | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index 79a413f..d0e11ac 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -149,22 +149,21 @@ class SplitResultNamedTuple(tuple): cls.__getattr__ = _get_attr + 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, ( - unicode(slice_component(url, parsed.scheme).lower()), - unicode(build_netloc(url, parsed)), - unicode(slice_component(url, parsed.path)), - unicode(slice_component(url, parsed.query)), - unicode(slice_component(url, parsed.ref)) + 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, ( - 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) - )) + return tuple.__new__(cls, (scheme, netloc, path, query, ref)) def geturl(self): return stdlib_urlunsplit(self) From 13eb988af8ed453e2914e3c810b274848028615b Mon Sep 17 00:00:00 2001 From: nctl144 Date: Fri, 8 Jun 2018 12:11:07 -0500 Subject: [PATCH 24/38] compile cython --- urlparse4/cgurl.cpp | 824 +++++++++++++++++++++++--------------------- 1 file changed, 439 insertions(+), 385 deletions(-) diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index 3958e5d..cd2eb0b 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -1144,14 +1144,35 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr /* GetModuleGlobalName.proto */ static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); -/* PyObject_Unicode.proto */ -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyObject_Unicode(obj)\ - (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj)) -#else -#define __Pyx_PyObject_Unicode(obj)\ - (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Unicode(obj)) -#endif +/* 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 @@ -1274,6 +1295,7 @@ 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_url[] = "url"; static const char __pyx_k_base[] = "base"; @@ -1289,6 +1311,8 @@ 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__"; @@ -1331,6 +1355,7 @@ static PyObject *__pyx_n_s_base; static PyObject *__pyx_n_s_cgurl; static PyObject *__pyx_n_s_cline_in_traceback; static PyObject *__pyx_n_s_cls; +static PyObject *__pyx_n_s_decode; static PyObject *__pyx_n_s_doc; static PyObject *__pyx_kp_b_file; static PyObject *__pyx_n_s_fragment; @@ -1353,6 +1378,7 @@ 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; @@ -1367,6 +1393,7 @@ 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_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 */ @@ -1376,14 +1403,15 @@ static PyObject *__pyx_tp_new_5cgurl___pyx_scope_struct____new__(PyTypeObject *t 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_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; /* Late includes */ /* "cgurl.pyx":11 @@ -2539,6 +2567,11 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_7__new____get_attr(PyOb 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; @@ -2660,393 +2693,368 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P * * cls.__getattr__ = _get_attr # <<<<<<<<<<<<<< * - * if six.PY2: + * 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, 150, __pyx_L1_error) /* "cgurl.pyx":152 * cls.__getattr__ = _get_attr * - * if six.PY2: # <<<<<<<<<<<<<< - * return tuple.__new__(cls, ( - * unicode(slice_component(url, parsed.scheme).lower()), + * scheme, netloc, path, query, ref = (slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< + * build_netloc(url, parsed), + * slice_component(url, parsed.path), */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_six); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 152, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_PY2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __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); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 152, __pyx_L1_error) + __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_7, function); + } + } + 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_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; - if (__pyx_t_3) { - /* "cgurl.pyx":153 + /* "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_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_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_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; + + /* "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, ( # <<<<<<<<<<<<<< - * unicode(slice_component(url, parsed.scheme).lower()), - * unicode(build_netloc(url, parsed)), + * scheme.decode('utf-8'), + * netloc.decode('utf-8'), */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); + __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":154 + /* "cgurl.pyx":159 * if six.PY2: * return tuple.__new__(cls, ( - * unicode(slice_component(url, parsed.scheme).lower()), # <<<<<<<<<<<<<< - * unicode(build_netloc(url, parsed)), - * unicode(slice_component(url, parsed.path)), - */ - __pyx_t_9 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_9); - __pyx_t_10 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_9), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 154, __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, 154, __pyx_L1_error) + * 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_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = NULL; - if (CYTHON_UNPACK_METHODS && 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_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, 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, 154, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else { - __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 154, __pyx_L1_error) - } + __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; - __pyx_t_9 = __Pyx_PyObject_Unicode(__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 154, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - /* "cgurl.pyx":155 + /* "cgurl.pyx":160 * return tuple.__new__(cls, ( - * unicode(slice_component(url, parsed.scheme).lower()), - * unicode(build_netloc(url, parsed)), # <<<<<<<<<<<<<< - * unicode(slice_component(url, parsed.path)), - * unicode(slice_component(url, parsed.query)), - */ - __pyx_t_8 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_8); - __pyx_t_10 = __pyx_f_5cgurl_build_netloc(((PyObject*)__pyx_t_8), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 155, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_Unicode(__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 155, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - - /* "cgurl.pyx":156 - * unicode(slice_component(url, parsed.scheme).lower()), - * unicode(build_netloc(url, parsed)), - * unicode(slice_component(url, parsed.path)), # <<<<<<<<<<<<<< - * unicode(slice_component(url, parsed.query)), - * unicode(slice_component(url, parsed.ref)) - */ - __pyx_t_10 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_10); - __pyx_t_11 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_10), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = __Pyx_PyObject_Unicode(__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 156, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + * 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":157 - * unicode(build_netloc(url, parsed)), - * unicode(slice_component(url, parsed.path)), - * unicode(slice_component(url, parsed.query)), # <<<<<<<<<<<<<< - * unicode(slice_component(url, parsed.ref)) + /* "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') * )) */ - __pyx_t_11 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_11); - __pyx_t_12 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_11), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 157, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyObject_Unicode(__pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 157, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + 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":158 - * unicode(slice_component(url, parsed.path)), - * unicode(slice_component(url, parsed.query)), - * unicode(slice_component(url, parsed.ref)) # <<<<<<<<<<<<<< + /* "cgurl.pyx":163 + * path.decode('utf-8'), + * query.decode('utf-8'), + * ref.decode('utf-8') # <<<<<<<<<<<<<< * )) * else: */ - __pyx_t_12 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_12); - __pyx_t_13 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_12), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 158, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = __Pyx_PyObject_Unicode(__pyx_t_13); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 158, __pyx_L1_error) + 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); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - /* "cgurl.pyx":154 + /* "cgurl.pyx":159 * if six.PY2: * return tuple.__new__(cls, ( - * unicode(slice_component(url, parsed.scheme).lower()), # <<<<<<<<<<<<<< - * unicode(build_netloc(url, parsed)), - * unicode(slice_component(url, parsed.path)), + * 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, 154, __pyx_L1_error) + __pyx_t_13 = PyTuple_New(5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_13); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_9); + __Pyx_INCREF(((PyObject*)__pyx_t_8)); __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_11); + 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_t_9 = 0; - __pyx_t_8 = 0; - __pyx_t_10 = 0; - __pyx_t_11 = 0; - __pyx_t_12 = 0; + __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_1))) { - __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1); + 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_1); + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); __Pyx_INCREF(__pyx_t_12); __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); + __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_14 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { + if (PyFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_cls, __pyx_t_13}; - __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) + __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_7); + __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_1)) { + if (__Pyx_PyFastCFunction_Check(__pyx_t_11)) { PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_cls, __pyx_t_13}; - __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) + __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_7); + __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; } else #endif { - __pyx_t_11 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_11); + __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_11, 0, __pyx_t_12); __pyx_t_12 = NULL; + __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_11, 0+__pyx_t_14, __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_11, 1+__pyx_t_14, __pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_14, __pyx_t_13); __pyx_t_13 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 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_1); __pyx_t_1 = 0; - __pyx_r = __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":152 - * cls.__getattr__ = _get_attr - * + /* "cgurl.pyx":157 + * slice_component(url, parsed.query), + * slice_component(url, parsed.ref)) * if six.PY2: # <<<<<<<<<<<<<< * return tuple.__new__(cls, ( - * unicode(slice_component(url, parsed.scheme).lower()), + * scheme.decode('utf-8'), */ } - /* "cgurl.pyx":161 + /* "cgurl.pyx":166 * )) * else: - * return tuple.__new__(cls, ( # <<<<<<<<<<<<<< - * slice_component(url, parsed.scheme).lower(), - * build_netloc(url, parsed), + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) # <<<<<<<<<<<<<< + * + * def geturl(self): */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)(&PyTuple_Type)), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - - /* "cgurl.pyx":162 - * else: - * return tuple.__new__(cls, ( - * slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< - * build_netloc(url, parsed), - * slice_component(url, parsed.path), - */ - __pyx_t_13 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_13); - __pyx_t_12 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.scheme); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_lower); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_13))) { - __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_13); - if (likely(__pyx_t_12)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13); - __Pyx_INCREF(__pyx_t_12); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_13, function); - } - } - if (__pyx_t_12) { - __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_13, __pyx_t_12); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - } else { - __pyx_t_11 = __Pyx_PyObject_CallNoArg(__pyx_t_13); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 162, __pyx_L1_error) - } + __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_DECREF(__pyx_t_13); __pyx_t_13 = 0; - - /* "cgurl.pyx":163 - * 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_13 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_13); - __pyx_t_12 = __pyx_f_5cgurl_build_netloc(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - - /* "cgurl.pyx":164 - * 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_13 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_13); - __pyx_t_10 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.path); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 164, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - - /* "cgurl.pyx":165 - * build_netloc(url, parsed), - * slice_component(url, parsed.path), - * slice_component(url, parsed.query), # <<<<<<<<<<<<<< - * slice_component(url, parsed.ref) - * )) - */ - __pyx_t_13 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_13); - __pyx_t_8 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.query); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - - /* "cgurl.pyx":166 - * slice_component(url, parsed.path), - * slice_component(url, parsed.query), - * slice_component(url, parsed.ref) # <<<<<<<<<<<<<< - * )) - * - */ - __pyx_t_13 = __pyx_cur_scope->__pyx_v_url; - __Pyx_INCREF(__pyx_t_13); - __pyx_t_9 = __pyx_f_5cgurl_slice_component(((PyObject*)__pyx_t_13), __pyx_cur_scope->__pyx_v_parsed.ref); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - - /* "cgurl.pyx":162 - * else: - * return tuple.__new__(cls, ( - * slice_component(url, parsed.scheme).lower(), # <<<<<<<<<<<<<< - * build_netloc(url, parsed), - * slice_component(url, parsed.path), - */ - __pyx_t_13 = PyTuple_New(5); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 162, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_13); - __Pyx_GIVEREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_11); - __Pyx_GIVEREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_12); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_t_9); - __pyx_t_11 = 0; - __pyx_t_12 = 0; - __pyx_t_10 = 0; - __pyx_t_8 = 0; - __pyx_t_9 = 0; - __pyx_t_9 = NULL; + __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_1))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_9); + 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_1, function); + __Pyx_DECREF_SET(__pyx_t_11, function); __pyx_t_14 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_cls, __pyx_t_13}; - __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + 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_1)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_v_cls, __pyx_t_13}; - __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_14, 2+__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + 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_8 = PyTuple_New(2+__pyx_t_14); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_9) { - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL; + __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_8, 0+__pyx_t_14, __pyx_v_cls); - __Pyx_GIVEREF(__pyx_t_13); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_14, __pyx_t_13); - __pyx_t_13 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + 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_1); __pyx_t_1 = 0; - __pyx_r = __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; } @@ -3072,14 +3080,19 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple___new__(CYTHON_UNUSED P __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; } -/* "cgurl.pyx":169 - * )) +/* "cgurl.pyx":168 + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) @@ -3109,7 +3122,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P PyObject *__pyx_t_4 = NULL; __Pyx_RefNannySetupContext("geturl", 0); - /* "cgurl.pyx":170 + /* "cgurl.pyx":169 * * def geturl(self): * return stdlib_urlunsplit(self) # <<<<<<<<<<<<<< @@ -3117,7 +3130,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urlunsplit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __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 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { @@ -3130,13 +3143,13 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P } } if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error) + __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 { #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, 170, __pyx_L1_error) + __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 @@ -3144,19 +3157,19 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P #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, 170, __pyx_L1_error) + __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, 170, __pyx_L1_error) + __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, 170, __pyx_L1_error) + __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; } @@ -3166,8 +3179,8 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P __pyx_t_1 = 0; goto __pyx_L0; - /* "cgurl.pyx":169 - * )) + /* "cgurl.pyx":168 + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) @@ -3188,7 +3201,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P return __pyx_r; } -/* "cgurl.pyx":173 +/* "cgurl.pyx":172 * * * def urlsplit(url): # <<<<<<<<<<<<<< @@ -3224,7 +3237,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urlsplit", 0); - /* "cgurl.pyx":175 + /* "cgurl.pyx":174 * def urlsplit(url): * cdef bytes b_url * if isinstance(url, unicode): # <<<<<<<<<<<<<< @@ -3235,7 +3248,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "cgurl.pyx":176 + /* "cgurl.pyx":175 * cdef bytes b_url * if isinstance(url, unicode): * b_url = (url).encode('utf8') # <<<<<<<<<<<<<< @@ -3244,9 +3257,9 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py */ if (unlikely(__pyx_v_url == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); - __PYX_ERR(0, 176, __pyx_L1_error) + __PYX_ERR(0, 175, __pyx_L1_error) } - __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_url)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) + __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_url)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); @@ -3254,7 +3267,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_v_b_url = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cgurl.pyx":175 + /* "cgurl.pyx":174 * def urlsplit(url): * cdef bytes b_url * if isinstance(url, unicode): # <<<<<<<<<<<<<< @@ -3264,7 +3277,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py goto __pyx_L3; } - /* "cgurl.pyx":178 + /* "cgurl.pyx":177 * b_url = (url).encode('utf8') * else: * b_url = url # <<<<<<<<<<<<<< @@ -3272,7 +3285,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py * */ /*else*/ { - if (!(likely(PyBytes_CheckExact(__pyx_v_url))||((__pyx_v_url) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_url)->tp_name), 0))) __PYX_ERR(0, 178, __pyx_L1_error) + if (!(likely(PyBytes_CheckExact(__pyx_v_url))||((__pyx_v_url) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_url)->tp_name), 0))) __PYX_ERR(0, 177, __pyx_L1_error) __pyx_t_4 = __pyx_v_url; __Pyx_INCREF(__pyx_t_4); __pyx_v_b_url = ((PyObject*)__pyx_t_4); @@ -3280,7 +3293,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py } __pyx_L3:; - /* "cgurl.pyx":179 + /* "cgurl.pyx":178 * else: * b_url = url * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) # <<<<<<<<<<<<<< @@ -3288,12 +3301,12 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py * def urljoin(bytes base, bytes url, allow_fragments=True): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = NULL; __pyx_t_7 = 0; @@ -3310,7 +3323,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -3319,14 +3332,14 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else #endif { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; @@ -3337,7 +3350,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __Pyx_GIVEREF(__pyx_v_b_url); PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_b_url); __pyx_t_3 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 179, __pyx_L1_error) + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; } @@ -3346,7 +3359,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_t_4 = 0; goto __pyx_L0; - /* "cgurl.pyx":173 + /* "cgurl.pyx":172 * * * def urlsplit(url): # <<<<<<<<<<<<<< @@ -3370,7 +3383,7 @@ static PyObject *__pyx_pf_5cgurl_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, Py return __pyx_r; } -/* "cgurl.pyx":181 +/* "cgurl.pyx":180 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< @@ -3414,7 +3427,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ case 1: 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, 181, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, 1); __PYX_ERR(0, 180, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -3424,7 +3437,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 181, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 180, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3442,14 +3455,14 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 181, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 180, __pyx_L3_error) __pyx_L3_error:; __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, 181, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 181, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_base), (&PyBytes_Type), 1, "base", 1))) __PYX_ERR(0, 180, __pyx_L1_error) + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 180, __pyx_L1_error) __pyx_r = __pyx_pf_5cgurl_2urljoin(__pyx_self, __pyx_v_base, __pyx_v_url, __pyx_v_allow_fragments); /* function exit code */ @@ -3474,14 +3487,14 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py PyObject *__pyx_t_8 = NULL; __Pyx_RefNannySetupContext("urljoin", 0); - /* "cgurl.pyx":182 + /* "cgurl.pyx":181 * * 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, 182, __pyx_L1_error) + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_allow_fragments); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 181, __pyx_L1_error) if (__pyx_t_2) { } else { __pyx_t_1 = __pyx_t_2; @@ -3492,7 +3505,7 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __pyx_L4_bool_binop_done:; if (__pyx_t_1) { - /* "cgurl.pyx":183 + /* "cgurl.pyx":182 * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: * return GURL(base).Resolve(url).spec() # <<<<<<<<<<<<<< @@ -3500,15 +3513,15 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py * 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, 183, __pyx_L1_error) - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 183, __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, 183, __pyx_L1_error) + __pyx_t_3 = __pyx_convert_string_from_py_std__in_string(__pyx_v_base); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L1_error) + __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 182, __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, 182, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "cgurl.pyx":182 + /* "cgurl.pyx":181 * * def urljoin(bytes base, bytes url, allow_fragments=True): * if allow_fragments and base: # <<<<<<<<<<<<<< @@ -3517,16 +3530,16 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py */ } - /* "cgurl.pyx":185 + /* "cgurl.pyx":184 * return GURL(base).Resolve(url).spec() * else: * return stdlib_urljoin(base, url, allow_fragments=allow_fragments) # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_base); __Pyx_GIVEREF(__pyx_v_base); @@ -3534,10 +3547,10 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py __Pyx_INCREF(__pyx_v_url); __Pyx_GIVEREF(__pyx_v_url); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_url); - __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L1_error) + __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 184, __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, 185, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 185, __pyx_L1_error) + if (PyDict_SetItem(__pyx_t_7, __pyx_n_s_allow_fragments, __pyx_v_allow_fragments) < 0) __PYX_ERR(0, 184, __pyx_L1_error) + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 184, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -3547,7 +3560,7 @@ static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, Py goto __pyx_L0; } - /* "cgurl.pyx":181 + /* "cgurl.pyx":180 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< @@ -3990,6 +4003,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__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_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}, @@ -4012,6 +4026,7 @@ 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}, @@ -4026,6 +4041,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__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) { @@ -4051,6 +4067,17 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(__pyx_tuple__2); __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) + /* "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 * @@ -4058,46 +4085,46 @@ static int __Pyx_InitCachedConstants(void) { * * 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, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_new, 116, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(0, 116, __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) - /* "cgurl.pyx":169 - * )) + /* "cgurl.pyx":168 + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) * */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); - __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_geturl, 169, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(0, 169, __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) - /* "cgurl.pyx":173 + /* "cgurl.pyx":172 * * * def urlsplit(url): # <<<<<<<<<<<<<< * cdef bytes b_url * if isinstance(url, unicode): */ - __pyx_tuple__8 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_b_url); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 173, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urlsplit, 173, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) __PYX_ERR(0, 173, __pyx_L1_error) + __pyx_tuple__9 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_b_url); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 172, __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_urlsplit, 172, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 172, __pyx_L1_error) - /* "cgurl.pyx":181 + /* "cgurl.pyx":180 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __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, 181, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); - __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_urlparse4_cgurl_pyx, __pyx_n_s_urljoin, 181, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_tuple__11 = PyTuple_Pack(3, __pyx_n_s_base, __pyx_n_s_url, __pyx_n_s_allow_fragments); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 180, __pyx_L1_error) + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 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_urljoin, 180, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -4449,21 +4476,21 @@ if (!__Pyx_RefNanny) { * * cdef Parsed parsed */ - __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__5)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __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 (__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; - /* "cgurl.pyx":169 - * )) + /* "cgurl.pyx":168 + * return tuple.__new__(cls, (scheme, netloc, path, query, ref)) * * def geturl(self): # <<<<<<<<<<<<<< * return stdlib_urlunsplit(self) * */ - __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__7)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __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 (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_geturl, __pyx_t_4) < 0) __PYX_ERR(0, 169, __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; /* "cgurl.pyx":112 @@ -4481,28 +4508,28 @@ if (!__Pyx_RefNanny) { __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "cgurl.pyx":173 + /* "cgurl.pyx":172 * * * def urlsplit(url): # <<<<<<<<<<<<<< * cdef bytes b_url * if isinstance(url, unicode): */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 173, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urlsplit, __pyx_t_1) < 0) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "cgurl.pyx":181 + /* "cgurl.pyx":180 * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) * * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< * if allow_fragments and base: * return GURL(base).Resolve(url).spec() */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 181, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_urljoin, __pyx_t_1) < 0) __PYX_ERR(0, 180, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "cgurl.pyx":1 @@ -6098,6 +6125,33 @@ static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr 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) { From 30f581ff8f007a949bde63d82f7439a0eb79a383 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Fri, 8 Jun 2018 14:20:51 -0500 Subject: [PATCH 25/38] add travis config file --- .travis.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .travis.yml 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 From 06c658ad9d008b794051c1613643b01b80c52e10 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Fri, 8 Jun 2018 14:32:46 -0500 Subject: [PATCH 26/38] update gitignore --- .gitignore | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7e1a952..4068e2a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,10 @@ /tmp /MANIFEST /urlparse4/*.html -/dist \ No newline at end of file +/dist + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml +htmlcov From 26a94c28dc58e29d174941fd26af0183502e48b1 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Fri, 8 Jun 2018 14:59:02 -0500 Subject: [PATCH 27/38] add tox config file --- .gitignore | 1 + pytest.ini | 2 ++ tests/requirements.txt | 2 ++ tox.ini | 8 ++++++++ 4 files changed, 13 insertions(+) create mode 100644 pytest.ini create mode 100644 tests/requirements.txt create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index 4068e2a..0f7a21d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ .tox nosetests.xml htmlcov +.pytest_cache diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..15fee9c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --doctest-modules --assert=plain --ignore=setup.py diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..9955dec --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,2 @@ +pytest +pytest-cov diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e8c165f --- /dev/null +++ b/tox.ini @@ -0,0 +1,8 @@ +[tox] +envlist = py27, py34, py35, py36, pypy, pypy3 + +[testenv] +deps = + -r{toxinidir}/tests/requirements.txt + +commands = py.test --cov=urlparse4 --cov-report= {posargs:urlparse4 tests} From 3a5dd479fe37412051ec4b7deb31dc5f3309607c Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 12:12:29 -0500 Subject: [PATCH 28/38] update the test to the latest --- tests/test_urlparse.py | 910 +++++++++++++++++++++++++++++++++-------- 1 file changed, 750 insertions(+), 160 deletions(-) diff --git a/tests/test_urlparse.py b/tests/test_urlparse.py index af3df33..22fd9cc 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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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, + # urllib.parse.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(urllib.parse.urljoin(base, relurl), expected) + bytes_components = baseb, relurlb, expectedb = [ + x.encode('ascii') for x in str_components] + self.assertEqual(urllib.parse.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(urllib.parse.urlunsplit(urllib.parse.urlsplit(u)), u) + self.assertEqual(urllib.parse.urlunparse(urllib.parse.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(urllib.parse.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 = urllib.parse.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, urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 (urllib.parse.urlsplit, urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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 = urllib.parse.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(urllib.parse.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(urllib.parse.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(urllib.parse.urlparse("path"), ('','','path','','','')) - self.assertEqual(urlparse.urlparse("//www.python.org:80"), + self.assertEqual(urllib.parse.urlparse("//www.python.org:80"), ('','www.python.org:80','','','','')) - self.assertEqual(urlparse.urlparse("http://www.python.org:80"), + self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"), ('http','www.python.org:80','','','','')) + # Repeat for bytes input + self.assertEqual(urllib.parse.urlparse(b"path"), + (b'',b'',b'path',b'',b'',b'')) + self.assertEqual(urllib.parse.urlparse(b"//www.python.org:80"), + (b'',b'www.python.org:80',b'',b'',b'',b'')) + self.assertEqual(urllib.parse.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(urllib.parse.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(urllib.parse.urlparse("http:"),('http','','','','','')) + self.assertEqual(urllib.parse.urlparse("https:"),('https','','','','','')) + self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"), ('http','www.python.org:80','','','','')) + # As usual, need to check bytes input as well + self.assertEqual(urllib.parse.urlparse(b"path:80"), + (b'',b'',b'path:80',b'',b'',b'')) + self.assertEqual(urllib.parse.urlparse(b"http:"),(b'http',b'',b'',b'',b'',b'')) + self.assertEqual(urllib.parse.urlparse(b"https:"),(b'https',b'',b'',b'',b'',b'')) + self.assertEqual(urllib.parse.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, urllib.parse.urlencode, "foo") + + def test_anyscheme(self): + # Issue 7904: s3://foo.com/stuff has netloc "foo.com". + self.assertEqual(urllib.parse.urlparse("s3://foo.com/stuff"), + ('s3', 'foo.com', '/stuff', '', '', '')) + self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"), + ('x-newscheme', 'foo.com', '/stuff', '', '', '')) + self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query#fragment"), + ('x-newscheme', 'foo.com', '/stuff', '', 'query', 'fragment')) + self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query"), + ('x-newscheme', 'foo.com', '/stuff', '', 'query', '')) + + # And for bytes... + self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"), + (b's3', b'foo.com', b'/stuff', b'', b'', b'')) + self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"), + (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b'')) + self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query#fragment"), + (b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b'fragment')) + self.assertEqual(urllib.parse.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 (urllib.parse.urlparse, urllib.parse.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 (urllib.parse.urlparse, urllib.parse.urlsplit): + if attr == "params" and func is urllib.parse.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"): + urllib.parse.urlparse("www.python.org", b"http") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urllib.parse.urlparse(b"www.python.org", "http") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urllib.parse.urlsplit("www.python.org", b"http") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urllib.parse.urlsplit(b"www.python.org", "http") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urllib.parse.urlunparse(( b"http", "www.python.org","","","","")) + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urllib.parse.urlunparse(("http", b"www.python.org","","","","")) + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urllib.parse.urlunsplit((b"http", "www.python.org","","","")) + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urllib.parse.urlunsplit(("http", b"www.python.org","","","")) + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urllib.parse.urljoin("http://python.org", b"http://python.org") + with self.assertRaisesRegex(TypeError, "Cannot mix str"): + urllib.parse.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 = [ + urllib.parse.DefragResult, + urllib.parse.SplitResult, + urllib.parse.ParseResult, + ] + for result_type in result_types: + self._check_result_type(result_type) + + def test_parse_qs_encoding(self): + result = urllib.parse.parse_qs("key=\u0141%E9", encoding="latin-1") + self.assertEqual(result, {'key': ['\u0141\xE9']}) + result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="utf-8") + self.assertEqual(result, {'key': ['\u0141\xE9']}) + result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="ascii") + self.assertEqual(result, {'key': ['\u0141\ufffd\ufffd']}) + result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii") + self.assertEqual(result, {'key': ['\u0141\ufffd-']}) + result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii", + errors="ignore") + self.assertEqual(result, {'key': ['\u0141-']}) + + def test_parse_qsl_encoding(self): + result = urllib.parse.parse_qsl("key=\u0141%E9", encoding="latin-1") + self.assertEqual(result, [('key', '\u0141\xE9')]) + result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="utf-8") + self.assertEqual(result, [('key', '\u0141\xE9')]) + result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="ascii") + self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')]) + result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii") + self.assertEqual(result, [('key', '\u0141\ufffd-')]) + result = urllib.parse.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 = urllib.parse.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 = urllib.parse.urlencode({'a': Trivial()}, True) + self.assertEqual(result, 'a=trivial') + + def test_urlencode_quote_via(self): + result = urllib.parse.urlencode({'a': 'some value'}) + self.assertEqual(result, "a=some+value") + result = urllib.parse.urlencode({'a': 'some value/another'}, + quote_via=urllib.parse.quote) + self.assertEqual(result, "a=some%20value%2Fanother") + result = urllib.parse.urlencode({'a': 'some value/another'}, + safe='/', quote_via=urllib.parse.quote) + self.assertEqual(result, "a=some%20value/another") + + def test_quote_from_bytes(self): + self.assertRaises(TypeError, urllib.parse.quote_from_bytes, 'foo') + result = urllib.parse.quote_from_bytes(b'archaeological arcana') + self.assertEqual(result, 'archaeological%20arcana') + result = urllib.parse.quote_from_bytes(b'') + self.assertEqual(result, '') + + def test_unquote_to_bytes(self): + result = urllib.parse.unquote_to_bytes('abc%20def') + self.assertEqual(result, b'abc def') + result = urllib.parse.unquote_to_bytes('') + self.assertEqual(result, b'') + + def test_quote_errors(self): + self.assertRaises(TypeError, urllib.parse.quote, b'foo', + encoding='utf-8') + self.assertRaises(TypeError, urllib.parse.quote, b'foo', errors='strict') + + def test_issue14072(self): + p1 = urllib.parse.urlsplit('tel:+31-641044153') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+31-641044153') + p2 = urllib.parse.urlsplit('tel:+31641044153') + self.assertEqual(p2.scheme, 'tel') + self.assertEqual(p2.path, '+31641044153') + # assert the behavior for urlparse + p1 = urllib.parse.urlparse('tel:+31-641044153') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+31-641044153') + p2 = urllib.parse.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 = urllib.parse.urlparse('http://Server=sde; Service=sde:oracle') + with self.assertRaisesRegex(ValueError, message): + p1.port + + p2 = urllib.parse.urlsplit('http://Server=sde; Service=sde:oracle') + with self.assertRaisesRegex(ValueError, message): + p2.port + + def test_telurl_params(self): + p1 = urllib.parse.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 = urllib.parse.urlparse('tel:+1-201-555-0123') + self.assertEqual(p1.scheme, 'tel') + self.assertEqual(p1.path, '+1-201-555-0123') + self.assertEqual(p1.params, '') + + p1 = urllib.parse.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 = urllib.parse.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 = urllib.parse.Quoter(urllib.parse._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(urllib.parse): + if name.startswith('_') or name in undocumented: + continue + object = getattr(urllib.parse, name) + if getattr(object, '__module__', None) == 'urllib.parse': + expected.append(name) + self.assertCountEqual(urllib.parse.__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 = urllib.parse._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 = urllib.parse._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 = urllib.parse._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 = urllib.parse._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 = urllib.parse._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 = urllib.parse._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 = urllib.parse._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 = urllib.parse._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 = urllib.parse._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 = urllib.parse._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 = urllib.parse._to_bytes('http://www.python.org') + self.assertEqual(result, 'http://www.python.org') + self.assertRaises(UnicodeError, urllib.parse._to_bytes, + 'http://www.python.org/medi\u00e6val') + + def test_unwrap(self): + url = urllib.parse._unwrap('') + self.assertEqual(url, 'type://host/path') + + +class DeprecationTest(unittest.TestCase): + + def test_splittype_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splittype('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splittype() is deprecated as of 3.8, ' + 'use urllib.parse.urlparse() instead') + + def test_splithost_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splithost('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splithost() is deprecated as of 3.8, ' + 'use urllib.parse.urlparse() instead') + + def test_splituser_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splituser('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splituser() is deprecated as of 3.8, ' + 'use urllib.parse.urlparse() instead') + + def test_splitpasswd_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splitpasswd('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splitpasswd() is deprecated as of 3.8, ' + 'use urllib.parse.urlparse() instead') + + def test_splitport_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splitport('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splitport() is deprecated as of 3.8, ' + 'use urllib.parse.urlparse() instead') + + def test_splitnport_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splitnport('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splitnport() is deprecated as of 3.8, ' + 'use urllib.parse.urlparse() instead') + + def test_splitquery_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splitquery('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splitquery() is deprecated as of 3.8, ' + 'use urllib.parse.urlparse() instead') + + def test_splittag_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splittag('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splittag() is deprecated as of 3.8, ' + 'use urllib.parse.urlparse() instead') + + def test_splitattr_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splitattr('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splitattr() is deprecated as of 3.8, ' + 'use urllib.parse.urlparse() instead') + + def test_splitvalue_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.splitvalue('') + self.assertEqual(str(cm.warning), + 'urllib.parse.splitvalue() is deprecated as of 3.8, ' + 'use urllib.parse.parse_qsl() instead') + + def test_to_bytes_deprecation(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.to_bytes('') + self.assertEqual(str(cm.warning), + 'urllib.parse.to_bytes() is deprecated as of 3.8') + + def test_unwrap(self): + with self.assertWarns(DeprecationWarning) as cm: + urllib.parse.unwrap('') + self.assertEqual(str(cm.warning), + 'urllib.parse.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() From 5160908b9098f799030b22f84b06430b7907d6dd Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 12:12:38 -0500 Subject: [PATCH 29/38] compile on Python 2 first --- urlparse4/cgurl.cpp | 76 ++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index 3d9fe12..b002777 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -4,54 +4,54 @@ { "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" - ], + ], "include_dirs": [ "./urlparse4" - ], - "language": "c++", - "name": "cgurl", + ], + "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", + "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 */ From 8af35675134e1a6b29deb20b5d3cef7f9c065829 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 12:12:46 -0500 Subject: [PATCH 30/38] change the env to python 2 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index e8c165f..a38e8da 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27, py34, py35, py36, pypy, pypy3 +envlist = py27 [testenv] deps = From a0bc1ff9f2e9aee61d856999260b0f535ffdcdf3 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 12:24:40 -0500 Subject: [PATCH 31/38] update the test to use urlparse4 --- tests/test_urlparse.py | 320 ++++++++++++++++++++--------------------- 1 file changed, 160 insertions(+), 160 deletions(-) diff --git a/tests/test_urlparse.py b/tests/test_urlparse.py index 22fd9cc..a1fe0f5 100644 --- a/tests/test_urlparse.py +++ b/tests/test_urlparse.py @@ -82,19 +82,19 @@ class UrlParseTestCase(unittest.TestCase): def checkRoundtrips(self, url, parsed, split): - result = urllib.parse.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 = urllib.parse.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 = urllib.parse.urlparse(result.geturl()) + result3 = urlparse4.urlparse(result.geturl()) self.assertEqual(result3.geturl(), result.geturl()) self.assertEqual(result3, result) self.assertEqual(result3.scheme, result.scheme) @@ -109,17 +109,17 @@ def checkRoundtrips(self, url, parsed, split): self.assertEqual(result3.port, result.port) # check the roundtrip using urlsplit() as well - result = urllib.parse.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 = urllib.parse.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 = urllib.parse.urlsplit(result.geturl()) + result3 = urlparse4.urlsplit(result.geturl()) self.assertEqual(result3.geturl(), result.geturl()) self.assertEqual(result3, result) self.assertEqual(result3.scheme, result.scheme) @@ -134,20 +134,20 @@ def checkRoundtrips(self, url, parsed, split): def test_qsl(self): for orig, expect in parse_qsl_test_cases: - result = urllib.parse.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 = urllib.parse.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) def test_qs(self): for orig, expect in parse_qs_test_cases: - result = urllib.parse.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 = {v: expect[v] for v in expect if len(expect[v][0])} - result = urllib.parse.parse_qs(orig, keep_blank_values=False) + result = urlparse4.parse_qs(orig, keep_blank_values=False) self.assertEqual(result, expect_without_blanks, "Error parsing %r" % orig) @@ -187,7 +187,7 @@ def _encode(t): self.checkRoundtrips(url, parsed, split) def test_http_roundtrips(self): - # urllib.parse.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! str_cases = [ @@ -226,17 +226,17 @@ def _encode(t): def checkJoin(self, base, relurl, expected): str_components = (base, relurl, expected) - self.assertEqual(urllib.parse.urljoin(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(urllib.parse.urljoin(baseb, relurlb), expectedb) + self.assertEqual(urlparse4.urljoin(baseb, relurlb), expectedb) def test_unparse_parse(self): 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(urllib.parse.urlunsplit(urllib.parse.urlsplit(u)), u) - self.assertEqual(urllib.parse.urlunparse(urllib.parse.urlparse(u)), u) + 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: @@ -288,7 +288,7 @@ def test_RFC1808(self): def test_RFC2368(self): # Issue 11467: path that starts with a number is not parsed correctly - self.assertEqual(urllib.parse.urlparse('mailto:1337@example.org'), + self.assertEqual(urlparse4.urlparse('mailto:1337@example.org'), ('mailto', '', '1337@example.org', '', '', '')) def test_RFC2396(self): @@ -485,7 +485,7 @@ 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 = urllib.parse.urlparse(url) + urlparsed = urlparse4.urlparse(url) self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port)) str_cases = [ @@ -496,7 +496,7 @@ def _encode(t): '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, urllib.parse.urlparse, invalid_url) + self.assertRaises(ValueError, urlparse4.urlparse, invalid_url) def test_urldefrag(self): str_cases = [ @@ -515,24 +515,24 @@ 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 = urllib.parse.urldefrag(url) + 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 = urllib.parse.urlsplit('http://[FE80::822a:a8ff:fe49:470c%tESt]:1234') + 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 = urllib.parse.urlsplit(b'http://[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 = urllib.parse.urlsplit(url) + p = urlparse4.urlsplit(url) self.assertEqual(p.scheme, "http") self.assertEqual(p.netloc, "WWW.PYTHON.ORG") self.assertEqual(p.path, "/doc/") @@ -548,7 +548,7 @@ def test_urlsplit_attributes(self): self.assertEqual(p.geturl()[4:], url[4:]) url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag" - p = urllib.parse.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/") @@ -565,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 = urllib.parse.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/") @@ -579,7 +579,7 @@ def test_urlsplit_attributes(self): # And check them all again, only with bytes this time url = b"HTTP://WWW.PYTHON.ORG/doc/#frag" - p = urllib.parse.urlsplit(url) + p = urlparse4.urlsplit(url) self.assertEqual(p.scheme, b"http") self.assertEqual(p.netloc, b"WWW.PYTHON.ORG") self.assertEqual(p.path, b"/doc/") @@ -592,7 +592,7 @@ def test_urlsplit_attributes(self): self.assertEqual(p.geturl()[4:], url[4:]) url = b"http://User:Pass@www.python.org:080/doc/?query=yes#frag" - p = urllib.parse.urlsplit(url) + 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/") @@ -605,7 +605,7 @@ def test_urlsplit_attributes(self): self.assertEqual(p.geturl(), url) url = b"http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag" - p = urllib.parse.urlsplit(url) + 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/") @@ -619,14 +619,14 @@ def test_urlsplit_attributes(self): # Verify an illegal port raises ValueError url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag" - p = urllib.parse.urlsplit(url) + p = urlparse4.urlsplit(url) with self.assertRaisesRegex(ValueError, "out of range"): p.port def test_attributes_bad_port(self): """Check handling of invalid ports.""" for bytes in (False, True): - for parse in (urllib.parse.urlsplit, urllib.parse.urlparse): + 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 @@ -646,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 = urllib.parse.urlsplit(uri) + p = urlparse4.urlsplit(uri) self.assertEqual(p.netloc, "") self.assertEqual(p.username, None) self.assertEqual(p.password, None) @@ -654,7 +654,7 @@ def test_attributes_without_netloc(self): self.assertEqual(p.port, None) self.assertEqual(p.geturl(), uri) - p = urllib.parse.urlparse(uri) + p = urlparse4.urlparse(uri) self.assertEqual(p.netloc, "") self.assertEqual(p.username, None) self.assertEqual(p.password, None) @@ -664,7 +664,7 @@ def test_attributes_without_netloc(self): # You guessed it, repeating the test with bytes input uri = b"sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15" - p = urllib.parse.urlsplit(uri) + p = urlparse4.urlsplit(uri) self.assertEqual(p.netloc, b"") self.assertEqual(p.username, None) self.assertEqual(p.password, None) @@ -672,7 +672,7 @@ def test_attributes_without_netloc(self): self.assertEqual(p.port, None) self.assertEqual(p.geturl(), uri) - p = urllib.parse.urlparse(uri) + p = urlparse4.urlparse(uri) self.assertEqual(p.netloc, b"") self.assertEqual(p.username, None) self.assertEqual(p.password, None) @@ -682,9 +682,9 @@ def test_attributes_without_netloc(self): def test_noslash(self): # Issue 1637: http://foo.com?query is legal - self.assertEqual(urllib.parse.urlparse("http://example.com?blahblah=/foo"), + self.assertEqual(urlparse4.urlparse("http://example.com?blahblah=/foo"), ('http', 'example.com', '', '', 'blahblah=/foo', '')) - self.assertEqual(urllib.parse.urlparse(b"http://example.com?blahblah=/foo"), + 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): @@ -692,64 +692,64 @@ def test_withoutscheme(self): # 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(urllib.parse.urlparse("path"), + self.assertEqual(urlparse4.urlparse("path"), ('','','path','','','')) - self.assertEqual(urllib.parse.urlparse("//www.python.org:80"), + self.assertEqual(urlparse4.urlparse("//www.python.org:80"), ('','www.python.org:80','','','','')) - self.assertEqual(urllib.parse.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(urllib.parse.urlparse(b"path"), + self.assertEqual(urlparse4.urlparse(b"path"), (b'',b'',b'path',b'',b'',b'')) - self.assertEqual(urllib.parse.urlparse(b"//www.python.org:80"), + self.assertEqual(urlparse4.urlparse(b"//www.python.org:80"), (b'',b'www.python.org:80',b'',b'',b'',b'')) - self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"), + 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(urllib.parse.urlparse("path:80"), + self.assertEqual(urlparse4.urlparse("path:80"), ('','','path:80','','','')) - self.assertEqual(urllib.parse.urlparse("http:"),('http','','','','','')) - self.assertEqual(urllib.parse.urlparse("https:"),('https','','','','','')) - self.assertEqual(urllib.parse.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(urllib.parse.urlparse(b"path:80"), + self.assertEqual(urlparse4.urlparse(b"path:80"), (b'',b'',b'path:80',b'',b'',b'')) - self.assertEqual(urllib.parse.urlparse(b"http:"),(b'http',b'',b'',b'',b'',b'')) - self.assertEqual(urllib.parse.urlparse(b"https:"),(b'https',b'',b'',b'',b'',b'')) - self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"), + 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, urllib.parse.urlencode, "foo") + self.assertRaises(TypeError, urlparse4.urlencode, "foo") def test_anyscheme(self): # Issue 7904: s3://foo.com/stuff has netloc "foo.com". - self.assertEqual(urllib.parse.urlparse("s3://foo.com/stuff"), + self.assertEqual(urlparse4.urlparse("s3://foo.com/stuff"), ('s3', 'foo.com', '/stuff', '', '', '')) - self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"), + self.assertEqual(urlparse4.urlparse("x-newscheme://foo.com/stuff"), ('x-newscheme', 'foo.com', '/stuff', '', '', '')) - self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query#fragment"), + self.assertEqual(urlparse4.urlparse("x-newscheme://foo.com/stuff?query#fragment"), ('x-newscheme', 'foo.com', '/stuff', '', 'query', 'fragment')) - self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query"), + self.assertEqual(urlparse4.urlparse("x-newscheme://foo.com/stuff?query"), ('x-newscheme', 'foo.com', '/stuff', '', 'query', '')) # And for bytes... - self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"), + self.assertEqual(urlparse4.urlparse(b"s3://foo.com/stuff"), (b's3', b'foo.com', b'/stuff', b'', b'', b'')) - self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"), + self.assertEqual(urlparse4.urlparse(b"x-newscheme://foo.com/stuff"), (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b'')) - self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query#fragment"), + 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(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query"), + 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 (urllib.parse.urlparse, urllib.parse.urlsplit): + for func in (urlparse4.urlparse, urlparse4.urlsplit): with self.subTest(function=func): result = func("http://example.net/", "ftp") self.assertEqual(result.scheme, "http") @@ -777,8 +777,8 @@ def test_parse_fragments(self): ("//abc#@frag:80", "path", "@frag:80"), ) for url, attr, expected_frag in tests: - for func in (urllib.parse.urlparse, urllib.parse.urlsplit): - if attr == "params" and func is urllib.parse.urlsplit: + 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) @@ -799,25 +799,25 @@ 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"): - urllib.parse.urlparse("www.python.org", b"http") + urlparse4.urlparse("www.python.org", b"http") with self.assertRaisesRegex(TypeError, "Cannot mix str"): - urllib.parse.urlparse(b"www.python.org", "http") + urlparse4.urlparse(b"www.python.org", "http") with self.assertRaisesRegex(TypeError, "Cannot mix str"): - urllib.parse.urlsplit("www.python.org", b"http") + urlparse4.urlsplit("www.python.org", b"http") with self.assertRaisesRegex(TypeError, "Cannot mix str"): - urllib.parse.urlsplit(b"www.python.org", "http") + urlparse4.urlsplit(b"www.python.org", "http") with self.assertRaisesRegex(TypeError, "Cannot mix str"): - urllib.parse.urlunparse(( b"http", "www.python.org","","","","")) + urlparse4.urlunparse(( b"http", "www.python.org","","","","")) with self.assertRaisesRegex(TypeError, "Cannot mix str"): - urllib.parse.urlunparse(("http", b"www.python.org","","","","")) + urlparse4.urlunparse(("http", b"www.python.org","","","","")) with self.assertRaisesRegex(TypeError, "Cannot mix str"): - urllib.parse.urlunsplit((b"http", "www.python.org","","","")) + urlparse4.urlunsplit((b"http", "www.python.org","","","")) with self.assertRaisesRegex(TypeError, "Cannot mix str"): - urllib.parse.urlunsplit(("http", b"www.python.org","","","")) + urlparse4.urlunsplit(("http", b"www.python.org","","","")) with self.assertRaisesRegex(TypeError, "Cannot mix str"): - urllib.parse.urljoin("http://python.org", b"http://python.org") + urlparse4.urljoin("http://python.org", b"http://python.org") with self.assertRaisesRegex(TypeError, "Cannot mix str"): - urllib.parse.urljoin(b"http://python.org", "http://python.org") + urlparse4.urljoin(b"http://python.org", "http://python.org") def _check_result_type(self, str_type): num_args = len(str_type._fields) @@ -847,43 +847,43 @@ def _check_result_type(self, str_type): def test_result_pairs(self): # Check encoding and decoding between result pairs result_types = [ - urllib.parse.DefragResult, - urllib.parse.SplitResult, - urllib.parse.ParseResult, + 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 = urllib.parse.parse_qs("key=\u0141%E9", encoding="latin-1") + result = urlparse4.parse_qs("key=\u0141%E9", encoding="latin-1") self.assertEqual(result, {'key': ['\u0141\xE9']}) - result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="utf-8") + result = urlparse4.parse_qs("key=\u0141%C3%A9", encoding="utf-8") self.assertEqual(result, {'key': ['\u0141\xE9']}) - result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="ascii") + result = urlparse4.parse_qs("key=\u0141%C3%A9", encoding="ascii") self.assertEqual(result, {'key': ['\u0141\ufffd\ufffd']}) - result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii") + result = urlparse4.parse_qs("key=\u0141%E9-", encoding="ascii") self.assertEqual(result, {'key': ['\u0141\ufffd-']}) - result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii", + result = urlparse4.parse_qs("key=\u0141%E9-", encoding="ascii", errors="ignore") self.assertEqual(result, {'key': ['\u0141-']}) def test_parse_qsl_encoding(self): - result = urllib.parse.parse_qsl("key=\u0141%E9", encoding="latin-1") + result = urlparse4.parse_qsl("key=\u0141%E9", encoding="latin-1") self.assertEqual(result, [('key', '\u0141\xE9')]) - result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="utf-8") + result = urlparse4.parse_qsl("key=\u0141%C3%A9", encoding="utf-8") self.assertEqual(result, [('key', '\u0141\xE9')]) - result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="ascii") + result = urlparse4.parse_qsl("key=\u0141%C3%A9", encoding="ascii") self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')]) - result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii") + result = urlparse4.parse_qsl("key=\u0141%E9-", encoding="ascii") self.assertEqual(result, [('key', '\u0141\ufffd-')]) - result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii", + 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 = urllib.parse.urlencode({'a': [1, 2], 'b': (3, 4, 5)}, True) + 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'} @@ -891,85 +891,85 @@ class Trivial: def __str__(self): return 'trivial' - result = urllib.parse.urlencode({'a': Trivial()}, True) + result = urlparse4.urlencode({'a': Trivial()}, True) self.assertEqual(result, 'a=trivial') def test_urlencode_quote_via(self): - result = urllib.parse.urlencode({'a': 'some value'}) + result = urlparse4.urlencode({'a': 'some value'}) self.assertEqual(result, "a=some+value") - result = urllib.parse.urlencode({'a': 'some value/another'}, - quote_via=urllib.parse.quote) + result = urlparse4.urlencode({'a': 'some value/another'}, + quote_via=urlparse4.quote) self.assertEqual(result, "a=some%20value%2Fanother") - result = urllib.parse.urlencode({'a': 'some value/another'}, - safe='/', quote_via=urllib.parse.quote) + 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, urllib.parse.quote_from_bytes, 'foo') - result = urllib.parse.quote_from_bytes(b'archaeological arcana') + self.assertRaises(TypeError, urlparse4.quote_from_bytes, 'foo') + result = urlparse4.quote_from_bytes(b'archaeological arcana') self.assertEqual(result, 'archaeological%20arcana') - result = urllib.parse.quote_from_bytes(b'') + result = urlparse4.quote_from_bytes(b'') self.assertEqual(result, '') def test_unquote_to_bytes(self): - result = urllib.parse.unquote_to_bytes('abc%20def') + result = urlparse4.unquote_to_bytes('abc%20def') self.assertEqual(result, b'abc def') - result = urllib.parse.unquote_to_bytes('') + result = urlparse4.unquote_to_bytes('') self.assertEqual(result, b'') def test_quote_errors(self): - self.assertRaises(TypeError, urllib.parse.quote, b'foo', + self.assertRaises(TypeError, urlparse4.quote, b'foo', encoding='utf-8') - self.assertRaises(TypeError, urllib.parse.quote, b'foo', errors='strict') + self.assertRaises(TypeError, urlparse4.quote, b'foo', errors='strict') def test_issue14072(self): - p1 = urllib.parse.urlsplit('tel:+31-641044153') + p1 = urlparse4.urlsplit('tel:+31-641044153') self.assertEqual(p1.scheme, 'tel') self.assertEqual(p1.path, '+31-641044153') - p2 = urllib.parse.urlsplit('tel:+31641044153') + p2 = urlparse4.urlsplit('tel:+31641044153') self.assertEqual(p2.scheme, 'tel') self.assertEqual(p2.path, '+31641044153') # assert the behavior for urlparse - p1 = urllib.parse.urlparse('tel:+31-641044153') + p1 = urlparse4.urlparse('tel:+31-641044153') self.assertEqual(p1.scheme, 'tel') self.assertEqual(p1.path, '+31-641044153') - p2 = urllib.parse.urlparse('tel:+31641044153') + 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 = urllib.parse.urlparse('http://Server=sde; Service=sde:oracle') + p1 = urlparse4.urlparse('http://Server=sde; Service=sde:oracle') with self.assertRaisesRegex(ValueError, message): p1.port - p2 = urllib.parse.urlsplit('http://Server=sde; Service=sde:oracle') + p2 = urlparse4.urlsplit('http://Server=sde; Service=sde:oracle') with self.assertRaisesRegex(ValueError, message): p2.port def test_telurl_params(self): - p1 = urllib.parse.urlparse('tel:123-4;phone-context=+1-650-516') + 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 = urllib.parse.urlparse('tel:+1-201-555-0123') + 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 = urllib.parse.urlparse('tel:7042;phone-context=example.com') + 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 = urllib.parse.urlparse('tel:863-1234;phone-context=+1-914-555') + 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 = urllib.parse.Quoter(urllib.parse._ALWAYS_SAFE) + quoter = urlparse4.Quoter(urlparse4._ALWAYS_SAFE) self.assertIn('Quoter', repr(quoter)) def test_all(self): @@ -980,13 +980,13 @@ def test_all(self): 'splitvalue', 'Quoter', 'ResultBase', 'clear_cache', 'to_bytes', 'unwrap', } - for name in dir(urllib.parse): + for name in dir(urlparse4): if name.startswith('_') or name in undocumented: continue - object = getattr(urllib.parse, name) - if getattr(object, '__module__', None) == 'urllib.parse': + object = getattr(urlparse4, name) + if getattr(object, '__module__', None) == 'urlparse4': expected.append(name) - self.assertCountEqual(urllib.parse.__all__, expected) + self.assertCountEqual(urlparse4.__all__, expected) class Utility_Tests(unittest.TestCase): @@ -994,7 +994,7 @@ class Utility_Tests(unittest.TestCase): # In Python 2 this test class was in test_urllib. def test_splittype(self): - splittype = urllib.parse._splittype + splittype = urlparse4._splittype self.assertEqual(splittype('type:opaquestring'), ('type', 'opaquestring')) self.assertEqual(splittype('opaquestring'), (None, 'opaquestring')) self.assertEqual(splittype(':opaquestring'), (None, ':opaquestring')) @@ -1002,7 +1002,7 @@ def test_splittype(self): self.assertEqual(splittype('type:opaque:string'), ('type', 'opaque:string')) def test_splithost(self): - splithost = urllib.parse._splithost + 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'), @@ -1031,7 +1031,7 @@ def test_splithost(self): ('example.net', '/file#')) def test_splituser(self): - splituser = urllib.parse._splituser + 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'), @@ -1046,7 +1046,7 @@ def test_splituser(self): def test_splitpasswd(self): # Some of the password examples are not sensible, but it is added to # confirming to RFC2617 and addressing issue4675. - splitpasswd = urllib.parse._splitpasswd + 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')) @@ -1062,7 +1062,7 @@ def test_splitpasswd(self): self.assertEqual(splitpasswd(':ab'), ('', 'ab')) def test_splitport(self): - splitport = urllib.parse._splitport + splitport = urlparse4._splitport self.assertEqual(splitport('parrot:88'), ('parrot', '88')) self.assertEqual(splitport('parrot'), ('parrot', None)) self.assertEqual(splitport('parrot:'), ('parrot', None)) @@ -1073,7 +1073,7 @@ def test_splitport(self): self.assertEqual(splitport(':88'), ('', '88')) def test_splitnport(self): - splitnport = urllib.parse._splitnport + splitnport = urlparse4._splitnport self.assertEqual(splitnport('parrot:88'), ('parrot', 88)) self.assertEqual(splitnport('parrot'), ('parrot', -1)) self.assertEqual(splitnport('parrot', 55), ('parrot', 55)) @@ -1087,7 +1087,7 @@ def test_splitnport(self): 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 = urllib.parse._splitquery + 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?'), @@ -1097,7 +1097,7 @@ def test_splitquery(self): self.assertEqual(splitquery('?foo=bar'), ('', 'foo=bar')) def test_splittag(self): - splittag = urllib.parse._splittag + 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#'), @@ -1109,7 +1109,7 @@ def test_splittag(self): ('http://example.com?foo=bar#baz', 'boo')) def test_splitattr(self): - splitattr = urllib.parse._splitattr + splitattr = urlparse4._splitattr self.assertEqual(splitattr('/path;attr1=value1;attr2=value2'), ('/path', ['attr1=value1', 'attr2=value2'])) self.assertEqual(splitattr('/path;'), ('/path', [''])) @@ -1120,7 +1120,7 @@ def test_splitattr(self): def test_splitvalue(self): # Normal cases are exercised by other tests; test pathological cases # with no key/value pairs. (testcase ensuring coverage) - splitvalue = urllib.parse._splitvalue + splitvalue = urlparse4._splitvalue self.assertEqual(splitvalue('foo=bar'), ('foo', 'bar')) self.assertEqual(splitvalue('foo='), ('foo', '')) self.assertEqual(splitvalue('=bar'), ('', 'bar')) @@ -1128,13 +1128,13 @@ def test_splitvalue(self): self.assertEqual(splitvalue('foo=bar=baz'), ('foo', 'bar=baz')) def test_to_bytes(self): - result = urllib.parse._to_bytes('http://www.python.org') + result = urlparse4._to_bytes('http://www.python.org') self.assertEqual(result, 'http://www.python.org') - self.assertRaises(UnicodeError, urllib.parse._to_bytes, + self.assertRaises(UnicodeError, urlparse4._to_bytes, 'http://www.python.org/medi\u00e6val') def test_unwrap(self): - url = urllib.parse._unwrap('') + url = urlparse4._unwrap('') self.assertEqual(url, 'type://host/path') @@ -1142,85 +1142,85 @@ class DeprecationTest(unittest.TestCase): def test_splittype_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splittype('') + urlparse4.splittype('') self.assertEqual(str(cm.warning), - 'urllib.parse.splittype() is deprecated as of 3.8, ' - 'use urllib.parse.urlparse() instead') + 'urlparse4.splittype() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') def test_splithost_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splithost('') + urlparse4.splithost('') self.assertEqual(str(cm.warning), - 'urllib.parse.splithost() is deprecated as of 3.8, ' - 'use urllib.parse.urlparse() instead') + 'urlparse4.splithost() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') def test_splituser_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splituser('') + urlparse4.splituser('') self.assertEqual(str(cm.warning), - 'urllib.parse.splituser() is deprecated as of 3.8, ' - 'use urllib.parse.urlparse() instead') + 'urlparse4.splituser() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') def test_splitpasswd_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splitpasswd('') + urlparse4.splitpasswd('') self.assertEqual(str(cm.warning), - 'urllib.parse.splitpasswd() is deprecated as of 3.8, ' - 'use urllib.parse.urlparse() instead') + 'urlparse4.splitpasswd() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') def test_splitport_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splitport('') + urlparse4.splitport('') self.assertEqual(str(cm.warning), - 'urllib.parse.splitport() is deprecated as of 3.8, ' - 'use urllib.parse.urlparse() instead') + 'urlparse4.splitport() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') def test_splitnport_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splitnport('') + urlparse4.splitnport('') self.assertEqual(str(cm.warning), - 'urllib.parse.splitnport() is deprecated as of 3.8, ' - 'use urllib.parse.urlparse() instead') + 'urlparse4.splitnport() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') def test_splitquery_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splitquery('') + urlparse4.splitquery('') self.assertEqual(str(cm.warning), - 'urllib.parse.splitquery() is deprecated as of 3.8, ' - 'use urllib.parse.urlparse() instead') + 'urlparse4.splitquery() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') def test_splittag_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splittag('') + urlparse4.splittag('') self.assertEqual(str(cm.warning), - 'urllib.parse.splittag() is deprecated as of 3.8, ' - 'use urllib.parse.urlparse() instead') + 'urlparse4.splittag() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') def test_splitattr_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splitattr('') + urlparse4.splitattr('') self.assertEqual(str(cm.warning), - 'urllib.parse.splitattr() is deprecated as of 3.8, ' - 'use urllib.parse.urlparse() instead') + 'urlparse4.splitattr() is deprecated as of 3.8, ' + 'use urlparse4.urlparse() instead') def test_splitvalue_deprecation(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.splitvalue('') + urlparse4.splitvalue('') self.assertEqual(str(cm.warning), - 'urllib.parse.splitvalue() is deprecated as of 3.8, ' - 'use urllib.parse.parse_qsl() instead') + '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: - urllib.parse.to_bytes('') + urlparse4.to_bytes('') self.assertEqual(str(cm.warning), - 'urllib.parse.to_bytes() is deprecated as of 3.8') + 'urlparse4.to_bytes() is deprecated as of 3.8') def test_unwrap(self): with self.assertWarns(DeprecationWarning) as cm: - urllib.parse.unwrap('') + urlparse4.unwrap('') self.assertEqual(str(cm.warning), - 'urllib.parse.unwrap() is deprecated as of 3.8') + 'urlparse4.unwrap() is deprecated as of 3.8') if __name__ == "__main__": From 480da474cd6c65326398797caa18dd660b3ae1c9 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 12:58:54 -0500 Subject: [PATCH 32/38] put urls into the correct place --- {tests => benchmarks}/urls/blink-performancetests.txt | 0 {tests => benchmarks}/urls/seeds_es_dmoz.txt | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {tests => benchmarks}/urls/blink-performancetests.txt (100%) rename {tests => benchmarks}/urls/seeds_es_dmoz.txt (100%) 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 From 25c134d1bcbd4c99a8512dbb15e2a8c60373b7c4 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 12:59:22 -0500 Subject: [PATCH 33/38] fix the benchmark file location --- benchmarks/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = [] From faa1feb329327f3a94cea0f02d399dda90a2af01 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 13:02:35 -0500 Subject: [PATCH 34/38] delete the pytest-cov for now --- pytest.ini | 2 -- tests/requirements.txt | 2 -- tox.ini | 4 ++-- 3 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 pytest.ini delete mode 100644 tests/requirements.txt diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 15fee9c..0000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -addopts = --doctest-modules --assert=plain --ignore=setup.py diff --git a/tests/requirements.txt b/tests/requirements.txt deleted file mode 100644 index 9955dec..0000000 --- a/tests/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -pytest -pytest-cov diff --git a/tox.ini b/tox.ini index a38e8da..bdcdb6d 100644 --- a/tox.ini +++ b/tox.ini @@ -3,6 +3,6 @@ envlist = py27 [testenv] deps = - -r{toxinidir}/tests/requirements.txt + pytest -commands = py.test --cov=urlparse4 --cov-report= {posargs:urlparse4 tests} +commands = pytest tests/ From 74b5549644a3949ce72ee354e4e7a920e3adac82 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 13:26:23 -0500 Subject: [PATCH 35/38] change the test env to py 3 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index bdcdb6d..e74b66b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27 +envlist = py36 [testenv] deps = From b67aa6f5869c2523fb0cd46592bc527ec62ebd82 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 13:26:34 -0500 Subject: [PATCH 36/38] recompile urlparse4 on py3 --- urlparse4/cgurl.cpp | 76 ++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index b002777..3d9fe12 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -4,54 +4,54 @@ { "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" - ], + ], "include_dirs": [ "./urlparse4" - ], - "language": "c++", - "name": "cgurl", + ], + "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", + "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 */ From e6110d7abb4042ce60604ca137a20a1a94d7c28c Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 14:05:29 -0500 Subject: [PATCH 37/38] support unicode handling for urljoin --- urlparse4/cgurl.pyx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/urlparse4/cgurl.pyx b/urlparse4/cgurl.pyx index d0e11ac..d26b3c5 100644 --- a/urlparse4/cgurl.pyx +++ b/urlparse4/cgurl.pyx @@ -168,16 +168,21 @@ class SplitResultNamedTuple(tuple): def geturl(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): - cdef bytes b_url - if isinstance(url, unicode): - b_url = (url).encode('utf8') - else: - b_url = url - return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) + url = unicode_handling(url) + return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + +def urljoin(base, url, allow_fragments=True): + 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: From b19d0e7d84392abfbd37c87bbbf8b2accb38b688 Mon Sep 17 00:00:00 2001 From: nctl144 Date: Mon, 11 Jun 2018 14:05:36 -0500 Subject: [PATCH 38/38] compile cython on py3 --- urlparse4/cgurl.cpp | 659 ++++++++++++++++++++++++++++++-------------- 1 file changed, 456 insertions(+), 203 deletions(-) diff --git a/urlparse4/cgurl.cpp b/urlparse4/cgurl.cpp index cd2eb0b..a097cfa 100644 --- a/urlparse4/cgurl.cpp +++ b/urlparse4/cgurl.cpp @@ -1297,6 +1297,7 @@ 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:"; @@ -1306,7 +1307,6 @@ 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_b_url[] = "b_url"; static const char __pyx_k_cgurl[] = "cgurl"; static const char __pyx_k_lower[] = "lower"; static const char __pyx_k_query[] = "query"; @@ -1329,11 +1329,13 @@ static const char __pyx_k_password[] = "password"; static const char __pyx_k_qualname[] = "__qualname__"; 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_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"; @@ -1350,8 +1352,8 @@ static PyObject *__pyx_n_s_SplitResultNamedTuple___new___lo; 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_b_url; 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; @@ -1386,7 +1388,9 @@ static PyObject *__pyx_n_s_six_moves_urllib_parse; static PyObject *__pyx_n_s_slots; 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_kp_s_urlparse4_cgurl_pyx; @@ -1397,8 +1401,9 @@ 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_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url); /* proto */ -static PyObject *__pyx_pf_5cgurl_2urljoin(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_base, PyObject *__pyx_v_url, PyObject *__pyx_v_allow_fragments); /* 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; @@ -1407,11 +1412,13 @@ 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__6; static PyObject *__pyx_codeobj__8; static PyObject *__pyx_codeobj__10; static PyObject *__pyx_codeobj__12; +static PyObject *__pyx_codeobj__14; /* Late includes */ /* "cgurl.pyx":11 @@ -3127,7 +3134,7 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P * def geturl(self): * return stdlib_urlunsplit(self) # <<<<<<<<<<<<<< * - * + * def unicode_handling(str): */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urlunsplit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) @@ -3201,200 +3208,318 @@ static PyObject *__pyx_pf_5cgurl_21SplitResultNamedTuple_2geturl(CYTHON_UNUSED P return __pyx_r; } -/* "cgurl.pyx":172 - * +/* "cgurl.pyx":171 + * return stdlib_urlunsplit(self) * - * def urlsplit(url): # <<<<<<<<<<<<<< - * cdef bytes b_url - * if isinstance(url, unicode): + * def unicode_handling(str): # <<<<<<<<<<<<<< + * cdef bytes bytes_str + * if isinstance(str, unicode): */ /* Python wrapper */ -static PyObject *__pyx_pw_5cgurl_1urlsplit(PyObject *__pyx_self, PyObject *__pyx_v_url); /*proto*/ -static PyMethodDef __pyx_mdef_5cgurl_1urlsplit = {"urlsplit", (PyCFunction)__pyx_pw_5cgurl_1urlsplit, METH_O, 0}; -static PyObject *__pyx_pw_5cgurl_1urlsplit(PyObject *__pyx_self, PyObject *__pyx_v_url) { +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("urlsplit (wrapper)", 0); - __pyx_r = __pyx_pf_5cgurl_urlsplit(__pyx_self, ((PyObject *)__pyx_v_url)); + __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_urlsplit(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_url) { - PyObject *__pyx_v_b_url = 0; +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; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("urlsplit", 0); + __Pyx_RefNannySetupContext("unicode_handling", 0); - /* "cgurl.pyx":174 - * def urlsplit(url): - * cdef bytes b_url - * if isinstance(url, unicode): # <<<<<<<<<<<<<< - * b_url = (url).encode('utf8') + /* "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_url); + __pyx_t_1 = PyUnicode_Check(__pyx_v_str); __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "cgurl.pyx":175 - * cdef bytes b_url - * if isinstance(url, unicode): - * b_url = (url).encode('utf8') # <<<<<<<<<<<<<< + /* "cgurl.pyx":174 + * cdef bytes bytes_str + * if isinstance(str, unicode): + * bytes_str = (str).encode('utf8') # <<<<<<<<<<<<<< * else: - * b_url = url + * bytes_str = str */ - if (unlikely(__pyx_v_url == Py_None)) { + if (unlikely(__pyx_v_str == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "encode"); - __PYX_ERR(0, 175, __pyx_L1_error) + __PYX_ERR(0, 174, __pyx_L1_error) } - __pyx_t_3 = PyUnicode_AsUTF8String(((PyObject*)__pyx_v_url)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __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_b_url = ((PyObject*)__pyx_t_4); + __pyx_v_bytes_str = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "cgurl.pyx":174 - * def urlsplit(url): - * cdef bytes b_url - * if isinstance(url, unicode): # <<<<<<<<<<<<<< - * b_url = (url).encode('utf8') + /* "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":177 - * b_url = (url).encode('utf8') + /* "cgurl.pyx":176 + * bytes_str = (str).encode('utf8') * else: - * b_url = url # <<<<<<<<<<<<<< - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) + * bytes_str = str # <<<<<<<<<<<<<< + * return bytes_str * */ /*else*/ { - if (!(likely(PyBytes_CheckExact(__pyx_v_url))||((__pyx_v_url) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_url)->tp_name), 0))) __PYX_ERR(0, 177, __pyx_L1_error) - __pyx_t_4 = __pyx_v_url; + 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_b_url = ((PyObject*)__pyx_t_4); + __pyx_v_bytes_str = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; } __pyx_L3:; - /* "cgurl.pyx":178 + /* "cgurl.pyx":177 * else: - * b_url = url - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) # <<<<<<<<<<<<<< + * bytes_str = str + * return bytes_str # <<<<<<<<<<<<<< * - * def urljoin(bytes base, bytes url, allow_fragments=True): + * def urlsplit(url): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_new); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 178, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_SplitResultNamedTuple); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 178, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); + __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_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_5cgurl_2urlsplit(__pyx_self, ((PyObject *)__pyx_v_url)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +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; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + __Pyx_RefNannySetupContext("urlsplit", 0); + __Pyx_INCREF(__pyx_v_url); + + /* "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(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, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __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, 181, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = NULL; + __pyx_t_5 = 0; + 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_5, function); - __pyx_t_7 = 1; + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + 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_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_t_3, __pyx_v_b_url}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + 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_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 178, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_t_3); - __Pyx_INCREF(__pyx_v_b_url); - __Pyx_GIVEREF(__pyx_v_b_url); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_b_url); - __pyx_t_3 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __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_5); __pyx_t_5 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; goto __pyx_L0; - /* "cgurl.pyx":172 - * + /* "cgurl.pyx":179 + * return bytes_str * * def urlsplit(url): # <<<<<<<<<<<<<< - * cdef bytes b_url - * if isinstance(url, unicode): + * url = unicode_handling(url) + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, 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_8); __Pyx_AddTraceback("cgurl.urlsplit", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_b_url); + __Pyx_XDECREF(__pyx_v_url); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "cgurl.pyx":180 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) +/* "cgurl.pyx":183 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + * + * def urljoin(base, url, allow_fragments=True): # <<<<<<<<<<<<<< + * 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() */ /* Python wrapper */ -static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_5cgurl_3urljoin = {"urljoin", (PyCFunction)__pyx_pw_5cgurl_3urljoin, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_pw_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; @@ -3427,7 +3552,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ case 1: 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, 180, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("urljoin", 0, 2, 3, 1); __PYX_ERR(0, 183, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: @@ -3437,7 +3562,7 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "urljoin") < 0)) __PYX_ERR(0, 180, __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)) { @@ -3449,134 +3574,236 @@ static PyObject *__pyx_pw_5cgurl_3urljoin(PyObject *__pyx_self, PyObject *__pyx_ 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, 180, __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("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, 180, __pyx_L1_error) - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_url), (&PyBytes_Type), 1, "url", 1))) __PYX_ERR(0, 180, __pyx_L1_error) - __pyx_r = __pyx_pf_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_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":181 + /* "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; + + /* "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, 181, __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) { - /* "cgurl.pyx":182 - * 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_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, 182, __pyx_L1_error) - __pyx_t_4 = __pyx_convert_string_from_py_std__in_string(__pyx_v_url); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 182, __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, 182, __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; - /* "cgurl.pyx":181 + /* "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: */ } - /* "cgurl.pyx":184 + /* "cgurl.pyx":189 * return GURL(base).Resolve(url).spec() * else: * return stdlib_urljoin(base, url, allow_fragments=allow_fragments) # <<<<<<<<<<<<<< */ /*else*/ { __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_stdlib_urljoin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); + __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_6, 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_6, 1, __pyx_v_url); - __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 184, __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, 184, __pyx_L1_error) - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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; } - /* "cgurl.pyx":180 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) + /* "cgurl.pyx":183 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + * + * def urljoin(base, url, allow_fragments=True): # <<<<<<<<<<<<<< + * 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() */ /* 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("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; @@ -3998,8 +4225,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_SplitResultNamedTuple_geturl, __pyx_k_SplitResultNamedTuple_geturl, sizeof(__pyx_k_SplitResultNamedTuple_geturl), 0, 0, 1, 1}, {&__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_b_url, __pyx_k_b_url, sizeof(__pyx_k_b_url), 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}, @@ -4034,7 +4261,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_slots, __pyx_k_slots, sizeof(__pyx_k_slots), 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_kp_s_urlparse4_cgurl_pyx, __pyx_k_urlparse4_cgurl_pyx, sizeof(__pyx_k_urlparse4_cgurl_pyx), 0, 0, 1, 0}, @@ -4102,29 +4331,41 @@ static int __Pyx_InitCachedConstants(void) { __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) - /* "cgurl.pyx":172 - * + /* "cgurl.pyx":171 + * return stdlib_urlunsplit(self) * - * def urlsplit(url): # <<<<<<<<<<<<<< - * cdef bytes b_url - * if isinstance(url, unicode): + * def unicode_handling(str): # <<<<<<<<<<<<<< + * cdef bytes bytes_str + * if isinstance(str, unicode): */ - __pyx_tuple__9 = PyTuple_Pack(2, __pyx_n_s_url, __pyx_n_s_b_url); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 172, __pyx_L1_error) + __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_urlsplit, 172, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 172, __pyx_L1_error) + __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":180 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) + /* "cgurl.pyx":179 + * return bytes_str * - * def urljoin(bytes base, bytes url, allow_fragments=True): # <<<<<<<<<<<<<< - * if allow_fragments and base: - * return GURL(base).Resolve(url).spec() + * def urlsplit(url): # <<<<<<<<<<<<<< + * url = unicode_handling(url) + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) */ - __pyx_tuple__11 = PyTuple_Pack(3, __pyx_n_s_base, __pyx_n_s_url, __pyx_n_s_allow_fragments); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 180, __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(3, 0, 3, 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_urljoin, 180, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 180, __pyx_L1_error) + __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) + + /* "cgurl.pyx":183 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + * + * def urljoin(base, url, allow_fragments=True): # <<<<<<<<<<<<<< + * base, url = unicode_handling(base), unicode_handling(url) + * + */ + __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:; @@ -4508,28 +4749,40 @@ if (!__Pyx_RefNanny) { __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "cgurl.pyx":172 + /* "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): # <<<<<<<<<<<<<< - * cdef bytes b_url - * if isinstance(url, unicode): + * url = unicode_handling(url) + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_1urlsplit, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 172, __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, 172, __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; - /* "cgurl.pyx":180 - * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, b_url) + /* "cgurl.pyx":183 + * return SplitResultNamedTuple.__new__(SplitResultNamedTuple, url) + * + * def urljoin(base, url, allow_fragments=True): # <<<<<<<<<<<<<< + * 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() */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5cgurl_3urljoin, NULL, __pyx_n_s_cgurl); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __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, 180, __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; /* "cgurl.pyx":1