-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
merge upstream (Sourcery refactored) #3
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,14 +43,13 @@ def scan_argv(argv, s, default=None): | |
del argv[i] | ||
else: | ||
i += 1 | ||
elif s == arg: | ||
# --option | ||
# set value to True | ||
p = True | ||
del argv[i] | ||
else: | ||
if s == arg: | ||
# --option | ||
# set value to True | ||
p = True | ||
del argv[i] | ||
else: | ||
i = i + 1 | ||
i += 1 | ||
Comment on lines
+46
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
##print argv | ||
return p | ||
|
||
|
@@ -69,7 +68,7 @@ def scan_argvs(argv, s): | |
assert p[-1], arg | ||
del argv[i] | ||
else: | ||
i = i + 1 | ||
i += 1 | ||
Comment on lines
-72
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
##print argv | ||
return p | ||
|
||
|
@@ -107,10 +106,10 @@ def add_libdirs(self, envvar, sep, fatal=False): | |
continue | ||
dir = os.path.normpath(dir) | ||
if os.path.isdir(dir): | ||
if not dir in self.library_dirs: | ||
if dir not in self.library_dirs: | ||
self.library_dirs.append(dir) | ||
elif fatal: | ||
fail("FATAL: bad directory %s in environment variable %s" % (dir, envvar)) | ||
fail(f"FATAL: bad directory {dir} in environment variable {envvar}") | ||
Comment on lines
-110
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
def detect_features(self): | ||
p = subprocess.Popen((self.curl_config(), '--features'), | ||
|
@@ -146,9 +145,11 @@ def detect_ssl_option(self): | |
for option in self.ssl_options(): | ||
if scan_argv(self.argv, option) is not None: | ||
for other_option in self.ssl_options(): | ||
if option != other_option: | ||
if scan_argv(self.argv, other_option) is not None: | ||
raise ConfigurationError('Cannot give both %s and %s' % (option, other_option)) | ||
if ( | ||
option != other_option | ||
and scan_argv(self.argv, other_option) is not None | ||
): | ||
raise ConfigurationError(f'Cannot give both {option} and {other_option}') | ||
Comment on lines
-149
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
return option | ||
|
||
|
@@ -157,14 +158,19 @@ def detect_ssl_backend(self): | |
|
||
if 'PYCURL_SSL_LIBRARY' in os.environ: | ||
ssl_lib = os.environ['PYCURL_SSL_LIBRARY'] | ||
if ssl_lib in ['openssl', 'wolfssl', 'gnutls', 'nss', 'mbedtls', 'sectransp']: | ||
ssl_lib_detected = ssl_lib | ||
getattr(self, 'using_%s' % ssl_lib)() | ||
else: | ||
if ssl_lib not in [ | ||
'openssl', | ||
'wolfssl', | ||
'gnutls', | ||
'nss', | ||
'mbedtls', | ||
'sectransp', | ||
]: | ||
raise ConfigurationError('Invalid value "%s" for PYCURL_SSL_LIBRARY' % ssl_lib) | ||
|
||
option = self.detect_ssl_option() | ||
if option: | ||
ssl_lib_detected = ssl_lib | ||
getattr(self, f'using_{ssl_lib_detected}')() | ||
if option := self.detect_ssl_option(): | ||
Comment on lines
-160
to
+173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
ssl_lib_detected = option.replace('--with-', '') | ||
self.ssl_options()[option]() | ||
|
||
|
@@ -230,7 +236,7 @@ def configure_unix(self): | |
stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
except OSError: | ||
exc = sys.exc_info()[1] | ||
msg = 'Could not run curl-config: %s' % str(exc) | ||
msg = f'Could not run curl-config: {str(exc)}' | ||
Comment on lines
-233
to
+239
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ):
|
||
raise ConfigurationError(msg) | ||
stdout, stderr = p.communicate() | ||
if p.wait() != 0: | ||
|
@@ -239,7 +245,7 @@ def configure_unix(self): | |
msg += ":\n" + stderr.decode() | ||
raise ConfigurationError(msg) | ||
libcurl_version = stdout.decode().strip() | ||
print("Using %s (%s)" % (self.curl_config(), libcurl_version)) | ||
print(f"Using {self.curl_config()} ({libcurl_version})") | ||
p = subprocess.Popen((self.curl_config(), '--cflags'), | ||
stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
stdout, stderr = p.communicate() | ||
|
@@ -294,14 +300,9 @@ def configure_unix(self): | |
else: | ||
# second successful call | ||
sslhintbuf += stdout.decode() | ||
else: | ||
if optbuf == '': | ||
# no successful call yet | ||
errtext += stderr.decode() | ||
else: | ||
# first call succeeded and second call failed | ||
# ignore stderr and the error exit | ||
pass | ||
elif optbuf == '': | ||
# no successful call yet | ||
errtext += stderr.decode() | ||
if optbuf == "": | ||
msg = "Neither curl-config --libs nor curl-config --static-libs" +\ | ||
" succeeded and produced output" | ||
|
@@ -324,9 +325,8 @@ def configure_unix(self): | |
OpenSSL, LibreSSL, BoringSSL, GnuTLS, NSS, mbedTLS, or Secure Transport \ | ||
please specify the SSL backend manually. For other SSL backends please \ | ||
ignore this message.''') | ||
else: | ||
if self.detect_ssl_option(): | ||
sys.stderr.write("Warning: SSL backend specified manually but libcurl does not use SSL\n") | ||
elif self.detect_ssl_option(): | ||
sys.stderr.write("Warning: SSL backend specified manually but libcurl does not use SSL\n") | ||
|
||
# libraries and options - all libraries and options are forwarded | ||
# but if --libs succeeded, --static-libs output is ignored | ||
|
@@ -420,10 +420,10 @@ def configure_windows(self): | |
if curl_dir is None: | ||
fail("Please specify --curl-dir=/path/to/built/libcurl") | ||
if not os.path.exists(curl_dir): | ||
fail("Curl directory does not exist: %s" % curl_dir) | ||
fail(f"Curl directory does not exist: {curl_dir}") | ||
if not os.path.isdir(curl_dir): | ||
fail("Curl directory is not a directory: %s" % curl_dir) | ||
print("Using curl directory: %s" % curl_dir) | ||
fail(f"Curl directory is not a directory: {curl_dir}") | ||
print(f"Using curl directory: {curl_dir}") | ||
Comment on lines
-423
to
+426
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
self.include_dirs.append(os.path.join(curl_dir, "include")) | ||
|
||
# libcurl windows documentation states that for linking against libcurl | ||
|
@@ -476,7 +476,7 @@ def configure_windows(self): | |
p = subprocess.Popen(['cl.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
out, err = p.communicate() | ||
match = re.search(r'Version (\d+)', err.decode().split("\n")[0]) | ||
if match and int(match.group(1)) < 16: | ||
if match and int(match[1]) < 16: | ||
# option removed in vs 2010: | ||
# connect.microsoft.com/VisualStudio/feedback/details/475896/link-fatal-error-lnk1117-syntax-error-in-option-opt-nowin98/ | ||
self.extra_link_args.append("/opt:nowin98") # use small section alignment | ||
|
@@ -634,11 +634,12 @@ def get_extension(argv, split_extension_source=False): | |
ext_config = ExtensionConfiguration(argv) | ||
|
||
if ext_config.ssl_lib_detected: | ||
print('Using SSL library: %s' % PRETTY_SSL_LIBS[ext_config.ssl_lib_detected]) | ||
print(f'Using SSL library: {PRETTY_SSL_LIBS[ext_config.ssl_lib_detected]}') | ||
else: | ||
print('Not using an SSL library') | ||
|
||
ext = Extension( | ||
##print(ext.__dict__); sys.exit(1) | ||
return Extension( | ||
Comment on lines
-637
to
+642
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
name=PACKAGE, | ||
sources=sources, | ||
depends=depends, | ||
|
@@ -651,8 +652,6 @@ def get_extension(argv, split_extension_source=False): | |
extra_compile_args=ext_config.extra_compile_args, | ||
extra_link_args=ext_config.extra_link_args, | ||
) | ||
##print(ext.__dict__); sys.exit(1) | ||
return ext | ||
|
||
|
||
############################################################################### | ||
|
@@ -666,16 +665,19 @@ def get_data_files(): | |
datadir = os.path.join("doc", PACKAGE) | ||
else: | ||
datadir = os.path.join("share", "doc", PACKAGE) | ||
# | ||
files = ["AUTHORS", "ChangeLog", "COPYING-LGPL", "COPYING-MIT", | ||
"INSTALL.rst", "README.rst", "RELEASE-NOTES.rst"] | ||
if files: | ||
if files := [ | ||
"AUTHORS", | ||
"ChangeLog", | ||
"COPYING-LGPL", | ||
"COPYING-MIT", | ||
"INSTALL.rst", | ||
"README.rst", | ||
"RELEASE-NOTES.rst", | ||
]: | ||
data_files.append((os.path.join(datadir), files)) | ||
files = glob.glob(os.path.join("examples", "*.py")) | ||
if files: | ||
if files := glob.glob(os.path.join("examples", "*.py")): | ||
data_files.append((os.path.join(datadir, "examples"), files)) | ||
files = glob.glob(os.path.join("examples", "quickstart", "*.py")) | ||
if files: | ||
if files := glob.glob(os.path.join("examples", "quickstart", "*.py")): | ||
Comment on lines
-669
to
+680
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
data_files.append((os.path.join(datadir, "examples", "quickstart"), files)) | ||
# | ||
assert data_files | ||
|
@@ -694,7 +696,7 @@ def check_manifest(): | |
f = open('MANIFEST.in') | ||
globs = [] | ||
try: | ||
for line in f.readlines(): | ||
for line in f: | ||
Comment on lines
-697
to
+699
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
stripped = line.strip() | ||
if stripped == '' or stripped.startswith('#'): | ||
continue | ||
|
@@ -716,11 +718,7 @@ def check_manifest(): | |
paths.append(rel) | ||
|
||
for path in paths: | ||
included = False | ||
for glob in globs: | ||
if fnmatch.fnmatch(path, glob): | ||
included = True | ||
break | ||
included = any(fnmatch.fnmatch(path, glob) for glob in globs) | ||
if not included: | ||
print(path) | ||
|
||
|
@@ -735,7 +733,7 @@ def check_authors(): | |
|
||
paras = contents.split("\n\n") | ||
authors_para = paras[AUTHORS_PARAGRAPH] | ||
authors = [author for author in authors_para.strip().split("\n")] | ||
authors = list(authors_para.strip().split("\n")) | ||
Comment on lines
-738
to
+736
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
log = subprocess.check_output(['git', 'log', '--format=%an (%ae)']) | ||
for author in log.strip().split("\n"): | ||
|
@@ -758,7 +756,7 @@ def convert_docstrings(): | |
continue | ||
|
||
name = entry.replace('.rst', '') | ||
f = open('doc/docstrings/%s' % entry) | ||
f = open(f'doc/docstrings/{entry}') | ||
Comment on lines
-761
to
+759
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
try: | ||
text = f.read().strip() | ||
finally: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,7 @@ def min_python(major, minor): | |
def decorator(fn): | ||
@functools.wraps(fn) | ||
def decorated(*args, **kwargs): | ||
if sys.version_info[0:2] < (major, minor): | ||
if sys.version_info[:2] < (major, minor): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
raise unittest.SkipTest('python < %d.%d' % (major, minor)) | ||
|
||
return fn(*args, **kwargs) | ||
|
@@ -180,11 +180,12 @@ def decorated(*args, **kwargs): | |
else: | ||
current_backend = 'none' | ||
if current_backend not in backends: | ||
raise unittest.SkipTest('SSL backend is %s' % current_backend) | ||
raise unittest.SkipTest(f'SSL backend is {current_backend}') | ||
|
||
return fn(*args, **kwargs) | ||
|
||
return decorated | ||
|
||
Comment on lines
-183
to
+188
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
return decorator | ||
|
||
def only_ipv6(fn): | ||
|
@@ -244,7 +245,7 @@ def create_connection(netloc, timeout=None): | |
|
||
def wait_for_network_service(netloc, check_interval, num_attempts): | ||
ok = False | ||
for i in range(num_attempts): | ||
for _ in range(num_attempts): | ||
Comment on lines
-247
to
+248
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
try: | ||
conn = create_connection(netloc, check_interval) | ||
except socket.error: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
ProxyCURLHandlerPool.get_additional_curl_options
refactored with the following changes:hoist-statement-from-if
)