Skip to content

drop python<=3.7 support #102

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Paste documentation build configuration file, created by
# sphinx-quickstart on Tue Apr 22 22:08:49 2008.
Expand Down
8 changes: 4 additions & 4 deletions paste/auth/auth_tkt.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,14 @@ def set_user_cookie(self, environ, userid, tokens, user_data):

cookies = []
if self.no_domain_cookie:
cookies.append(('Set-Cookie', '%s=%s; Path=/%s' % (
cookies.append(('Set-Cookie', '{}={}; Path=/{}'.format(
self.cookie_name, ticket.cookie_value(), cookie_options)))
if self.current_domain_cookie:
cookies.append(('Set-Cookie', '%s=%s; Path=/; Domain=%s%s' % (
cookies.append(('Set-Cookie', '{}={}; Path=/; Domain={}{}'.format(
self.cookie_name, ticket.cookie_value(), cur_domain,
cookie_options)))
if self.wildcard_cookie:
cookies.append(('Set-Cookie', '%s=%s; Path=/; Domain=%s%s' % (
cookies.append(('Set-Cookie', '{}={}; Path=/; Domain={}{}'.format(
self.cookie_name, ticket.cookie_value(), wild_domain,
cookie_options)))

Expand All @@ -395,7 +395,7 @@ def logout_user_cookie(self, environ):
wild_domain = '.' + cur_domain
expires = 'Sat, 01-Jan-2000 12:00:00 GMT'
cookies = [
('Set-Cookie', '%s=""; Expires="%s"; Path=/' % (self.cookie_name, expires)),
('Set-Cookie', '{}=""; Expires="{}"; Path=/'.format(self.cookie_name, expires)),
('Set-Cookie', '%s=""; Expires="%s"; Path=/; Domain=%s' %
(self.cookie_name, expires, cur_domain)),
('Set-Cookie', '%s=""; Expires="%s"; Path=/; Domain=%s' %
Expand Down
10 changes: 7 additions & 3 deletions paste/auth/cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@

"""

import hmac, base64, random, time, warnings
import hmac
import base64
import random
import time
import warnings
from functools import reduce
try:
from hashlib import sha1
Expand Down Expand Up @@ -301,12 +305,12 @@ def response_hook(status, response_headers, exc_info=None):
"The value of the environmental variable %r "
"is not a str (only str is allowed; got %r)"
% (k, v))
content.append("%s=%s" % (encode(k), encode(v)))
content.append("{}={}".format(encode(k), encode(v)))
if content:
content = ";".join(content)
content = self.signer.sign(content)
content = content.decode('utf8')
cookie = '%s=%s; Path=/;' % (self.cookie_name, content)
cookie = '{}={}; Path=/;'.format(self.cookie_name, content)
if 'https' == environ['wsgi.url_scheme']:
cookie += ' secure;'
response_headers.append(('Set-Cookie', cookie))
Expand Down
19 changes: 10 additions & 9 deletions paste/auth/digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
from hashlib import md5
except ImportError:
from md5 import md5
import time, random
import time
import random
from urllib.parse import quote as url_quote

def _split_auth_string(auth_string):
Expand All @@ -51,7 +52,7 @@ def _split_auth_string(auth_string):
for item in auth_string.split(","):
try:
if prev.count('"') == 1:
prev = "%s,%s" % (prev, item)
prev = "{},{}".format(prev, item)
continue
except AttributeError:
if prev is None:
Expand All @@ -74,7 +75,7 @@ def _auth_to_kv_pairs(auth_string):

def digest_password(realm, username, password):
""" construct the appropriate hashcode needed for HTTP digest """
content = "%s:%s:%s" % (username, realm, password)
content = "{}:{}:{}".format(username, realm, password)
content = content.encode('utf8')
return md5(content).hexdigest()

Expand All @@ -87,11 +88,11 @@ def __init__(self, realm, authfunc):

def build_authentication(self, stale = ''):
""" builds the authentication error """
content = "%s:%s" % (time.time(), random.random())
content = "{}:{}".format(time.time(), random.random())
content = content.encode('utf-8')
nonce = md5(content).hexdigest()

content = "%s:%s" % (time.time(), random.random())
content = "{}:{}".format(time.time(), random.random())
content = content.encode('utf-8')
opaque = md5(content).hexdigest()

Expand All @@ -100,7 +101,7 @@ def build_authentication(self, stale = ''):
'nonce': nonce, 'opaque': opaque }
if stale:
parts['stale'] = 'true'
head = ", ".join(['%s="%s"' % (k, v) for (k, v) in parts.items()])
head = ", ".join(['{}="{}"'.format(k, v) for (k, v) in parts.items()])
head = [("WWW-Authenticate", 'Digest %s' % head)]
return HTTPUnauthorized(headers=head)

Expand All @@ -109,13 +110,13 @@ def compute(self, ha1, username, response, method,
""" computes the authentication, raises error if unsuccessful """
if not ha1:
return self.build_authentication()
content = '%s:%s' % (method, path)
content = '{}:{}'.format(method, path)
content = content.encode('utf8')
ha2 = md5(content).hexdigest()
if qop:
chk = "%s:%s:%s:%s:%s:%s" % (ha1, nonce, nc, cnonce, qop, ha2)
chk = "{}:{}:{}:{}:{}:{}".format(ha1, nonce, nc, cnonce, qop, ha2)
else:
chk = "%s:%s:%s" % (ha1, nonce, ha2)
chk = "{}:{}:{}".format(ha1, nonce, ha2)
chk = chk.encode('utf8')
if response != md5(chk).hexdigest():
if nonce in self.nonce:
Expand Down
2 changes: 1 addition & 1 deletion paste/auth/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def set_default(self, name):
self.default = self.binding[name]
def set_query_argument(self, name, key = '*authmeth', value = None):
""" choose authentication method based on a query argument """
lookfor = "%s=%s" % (key, value or name)
lookfor = "{}={}".format(key, value or name)
self.add_predicate(name,
lambda environ: lookfor in environ.get('QUERY_STRING',''))
def __call__(self, environ, start_response):
Expand Down
44 changes: 22 additions & 22 deletions paste/auth/open_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

def quoteattr(s):
qs = html.escape(s)
return '"%s"' % (qs,)
return '"{}"'.format(qs)

# You may need to manually add the openid package into your
# python path if you don't have it installed with your system python.
Expand Down Expand Up @@ -314,7 +314,7 @@ def render(self, request, message=None, css_class='alert', form_contents=None,

self.page_header(request, title)
if message:
request['body'].append("<div class='%s'>" % (css_class,))
request['body'].append("<div class='{}'>".format(css_class))
request['body'].append(message)
request['body'].append("</div>")
self.page_footer(request, form_contents)
Expand All @@ -324,45 +324,45 @@ def page_header(self, request, title):
"""Render the page header"""
request['body'].append('''\
<html>
<head><title>%s</title></head>
<head><title>{}</title></head>
<style type="text/css">
* {
* {{
font-family: verdana,sans-serif;
}
body {
}}
body {{
width: 50em;
margin: 1em;
}
div {
}}
div {{
padding: .5em;
}
table {
}}
table {{
margin: none;
padding: none;
}
.alert {
}}
.alert {{
border: 1px solid #e7dc2b;
background: #fff888;
}
.error {
}}
.error {{
border: 1px solid #ff0000;
background: #ffaaaa;
}
#verify-form {
}}
#verify-form {{
border: 1px solid #777777;
background: #dddddd;
margin-top: 1em;
padding-bottom: 0em;
}
}}
</style>
<body>
<h1>%s</h1>
<h1>{}</h1>
<p>
This example consumer uses the <a
href="http://openid.schtuff.com/">Python OpenID</a> library. It
just verifies that the URL that you enter is your identity URL.
</p>
''' % (title, title))
'''.format(title, title))

def page_footer(self, request, form_contents):
"""Render the page footer"""
Expand All @@ -371,15 +371,15 @@ def page_footer(self, request, form_contents):

request['body'].append('''\
<div id="verify-form">
<form method="get" action=%s>
<form method="get" action={}>
Identity&nbsp;URL:
<input type="text" name="openid_url" value=%s />
<input type="text" name="openid_url" value={} />
<input type="submit" value="Verify" />
</form>
</div>
</body>
</html>
''' % (quoteattr(self.build_url(request, 'verify')), quoteattr(form_contents)))
'''.format(quoteattr(self.build_url(request, 'verify')), quoteattr(form_contents)))


middleware = AuthOpenIDHandler
Expand Down
2 changes: 1 addition & 1 deletion paste/cascade.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def repl_start_response(status, headers, exc_info=None):
while copy_len > 0:
chunk = environ['wsgi.input'].read(min(copy_len, 4096))
if not chunk:
raise IOError("Request body truncated")
raise OSError("Request body truncated")
f.write(chunk)
copy_len -= len(chunk)
f.seek(0)
Expand Down
3 changes: 1 addition & 2 deletions paste/cgitb_catcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def catching_iter(self, app_iter, environ):
return
error_on_close = False
try:
for v in app_iter:
yield v
yield from app_iter
if hasattr(app_iter, 'close'):
error_on_close = True
app_iter.close()
Expand Down
4 changes: 2 additions & 2 deletions paste/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DispatchingConfig(StackedObjectProxy):
# resolved, and get rid of this delegation wrapper

def __init__(self, name='DispatchingConfig'):
super(DispatchingConfig, self).__init__(name=name)
super().__init__(name=name)
self.__dict__['_process_configs'] = []

def push_thread_config(self, conf):
Expand Down Expand Up @@ -71,7 +71,7 @@ def _pop_from(self, lst, conf):

def _current_obj(self):
try:
return super(DispatchingConfig, self)._current_obj()
return super()._current_obj()
except TypeError:
if self._process_configs:
return self._process_configs[-1]
Expand Down
2 changes: 1 addition & 1 deletion paste/debug/debugapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __call__(self, environ, start_response):
remaining = int(total)
while remaining > 0:
if self.progress:
print("%s of %s remaining" % (remaining, total))
print("{} of {} remaining".format(remaining, total))
if remaining > 4096:
chunk = environ['wsgi.input'].read(4096)
else:
Expand Down
11 changes: 5 additions & 6 deletions paste/debug/doctest_webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import sys
import shutil
import re
import html
import rfc822
from io import StringIO
from paste.util import PySourceColor
Expand Down Expand Up @@ -49,7 +48,7 @@ def run_raw(command):

def run_command(command, name, and_print=False):
output = run_raw(command)
data = '$ %s\n%s' % (command, output)
data = '$ {}\n{}'.format(command, output)
show_file('shell-command', name, description='shell transcript',
data=data)
if and_print and output:
Expand Down Expand Up @@ -215,9 +214,9 @@ def show_file(path, version, description=None, data=None):
% PySourceColor.str2html(data, PySourceColor.dark))
else:
html = '<pre class="source-code">%s</pre>' % html.escape(data)
html = '<span class="source-filename">%s</span><br>%s' % (
html = '<span class="source-filename">{}</span><br>{}'.format(
description or path, html)
write_data(resource_filename('%s.%s.gen.html' % (path, version)),
write_data(resource_filename('{}.{}.gen.html'.format(path, version)),
html)

def call_source_highlight(input, format):
Expand Down Expand Up @@ -417,7 +416,7 @@ def parse(self, string, name='<string>'):
if sys.argv[1:] and sys.argv[1] == 'doctest':
doctest.testmod()
sys.exit()
if not paste_parent in sys.path:
if paste_parent not in sys.path:
sys.path.append(paste_parent)
for fn in sys.argv[1:]:
fn = os.path.abspath(fn)
Expand All @@ -429,4 +428,4 @@ def parse(self, string, name='<string>'):
parser=LongFormDocTestParser())
new = os.path.splitext(fn)[0] + '.html'
assert new != fn
os.system('rst2html.py %s > %s' % (fn, new))
os.system('rst2html.py {} > {}'.format(fn, new))
8 changes: 4 additions & 4 deletions paste/debug/fsdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _find_traverse(self, path, result):
result[path] = File(self.base_path, path)

def __repr__(self):
return '<%s in %r from %r>' % (
return '<{} in {!r} from {!r}>'.format(
self.__class__.__name__, self.base_path,
self.calculated or '(no calculation done)')

Expand Down Expand Up @@ -257,7 +257,7 @@ def mustcontain(self, s):
assert s in bytes

def __repr__(self):
return '<%s %s:%s>' % (
return '<{} {}:{}>'.format(
self.__class__.__name__,
self.base_path, self.path)

Expand All @@ -278,7 +278,7 @@ def __init__(self, base_path, path):
self.mtime = 'N/A'

def __repr__(self):
return '<%s %s:%s>' % (
return '<{} {}:{}>'.format(
self.__class__.__name__,
self.base_path, self.path)

Expand Down Expand Up @@ -401,7 +401,7 @@ def show_diff(actual_content, expected_content):
expected_lines = [l.strip() for l in expected_content.splitlines()
if l.strip()]
if len(actual_lines) == len(expected_lines) == 1:
return '%r not %r' % (actual_lines[0], expected_lines[0])
return '{!r} not {!r}'.format(actual_lines[0], expected_lines[0])
if not actual_lines:
return 'Empty; should have:\n'+expected_content
import difflib
Expand Down
1 change: 0 additions & 1 deletion paste/debug/prints.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from io import StringIO
import re
import html
from paste.util import threadedprint
from paste import wsgilib
from paste import response
Expand Down
6 changes: 3 additions & 3 deletions paste/debug/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def run_app():
output = capture_output(stats.print_stats, self.limit)
output_callers = capture_output(
stats.print_callers, self.limit)
body += '<pre style="%s">%s\n%s</pre>' % (
body += '<pre style="{}">{}\n{}</pre>'.format(
self.style, html.escape(output), html.escape(output_callers))
return [body]
finally:
Expand Down Expand Up @@ -206,8 +206,8 @@ def profile(self, func, *args, **kw):
def format_function(self, func, *args, **kw):
args = map(repr, args)
args.extend(
['%s=%r' % (k, v) for k, v in kw.items()])
return '%s(%s)' % (func.__name__, ', '.join(args))
['{}={!r}'.format(k, v) for k, v in kw.items()])
return '{}({})'.format(func.__name__, ', '.join(args))


def make_profile_middleware(
Expand Down
Loading