Skip to content

Commit 56c0954

Browse files
committed
Drop python2 support
Python 2 is end-of-life since Jan 1 2020. The 2.5.0 release can still be used if python2 support is needed. Signed-off-by: Cole Robinson <crobinso@redhat.com>
1 parent 674f439 commit 56c0954

18 files changed

Lines changed: 19 additions & 201 deletions

bugzilla/_cli.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
# This work is licensed under the GNU GPLv2 or later.
1010
# See the COPYING file in the top-level directory.
1111

12-
from __future__ import print_function
13-
1412
import argparse
1513
import base64
1614
import datetime
@@ -28,7 +26,6 @@
2826

2927
import bugzilla
3028
from bugzilla._compatimports import Fault, ProtocolError, urlparse
31-
from bugzilla._util import to_encoding
3229

3330

3431
DEFAULT_BZ = 'https://bugzilla.redhat.com'
@@ -620,13 +617,12 @@ def _filter_components(compdetails):
620617
elif opt.versions:
621618
proddict = bz.getproducts()[0]
622619
for v in proddict['versions']:
623-
print(to_encoding(v["name"]))
620+
print(str(v["name"] or ''))
624621

625622
elif opt.component_owners:
626623
details = bz.getcomponentsdetails(productname)
627624
for c in sorted(_filter_components(details)):
628-
print(to_encoding(u"%s: %s" % (c,
629-
details[c]['default_assigned_to'])))
625+
print(u"%s: %s" % (c, details[c]['default_assigned_to']))
630626

631627

632628
def _convert_to_outputformat(output):
@@ -691,8 +687,7 @@ def _format_output_raw(buglist):
691687
continue
692688
if attrname.startswith("_"):
693689
continue
694-
print(to_encoding(u"ATTRIBUTE[%s]: %s" %
695-
(attrname, b.__dict__[attrname])))
690+
print("ATTRIBUTE[%s]: %s" % (attrname, b.__dict__[attrname]))
696691
print("\n\n")
697692

698693

@@ -758,7 +753,7 @@ def _bug_field_repl_cb(bz, b, matchobj):
758753
val = getattr(b, fieldname, "")
759754

760755
vallist = isinstance(val, list) and val or [val]
761-
val = ','.join([to_encoding(v) for v in vallist])
756+
val = ','.join([str(v or '') for v in vallist])
762757

763758
return val
764759

bugzilla/_compatimports.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
# This work is licensed under the GNU GPLv2 or later.
22
# See the COPYING file in the top-level directory.
33

4-
import sys
4+
# pylint: disable=unused-import
55

6-
IS_PY3 = sys.version_info[0] >= 3
7-
8-
# pylint: disable=import-error,unused-import,ungrouped-imports
9-
# pylint: disable=no-name-in-module
10-
if IS_PY3:
11-
from collections.abc import Mapping
12-
from configparser import ConfigParser
13-
from http.cookiejar import LoadError, MozillaCookieJar
14-
from urllib.parse import urlparse, urlunparse, parse_qsl
15-
from xmlrpc.client import (Binary, DateTime, Fault, ProtocolError,
16-
ServerProxy, Transport)
17-
else: # pragma: no cover
18-
from collections import Mapping
19-
from ConfigParser import SafeConfigParser as ConfigParser
20-
from cookielib import LoadError, MozillaCookieJar
21-
from urlparse import urlparse
22-
from xmlrpclib import (Binary, DateTime, Fault, ProtocolError,
6+
from collections.abc import Mapping
7+
from configparser import ConfigParser
8+
from http.cookiejar import LoadError, MozillaCookieJar
9+
from urllib.parse import urlparse, urlunparse, parse_qsl
10+
from xmlrpc.client import (Binary, DateTime, Fault, ProtocolError,
2311
ServerProxy, Transport)
24-
from urlparse import urlparse, urlunparse, parse_qsl

bugzilla/_util.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# This work is licensed under the GNU GPLv2 or later.
22
# See the COPYING file in the top-level directory.
33

4-
import locale
5-
6-
from ._compatimports import IS_PY3
7-
84

95
def listify(val):
106
"""Ensure that value is either None or a list, converting single values
@@ -14,20 +10,3 @@ def listify(val):
1410
if isinstance(val, list):
1511
return val
1612
return [val]
17-
18-
19-
def to_encoding(ustring):
20-
"""
21-
Locale specific printing per python version
22-
"""
23-
# pylint: disable=undefined-variable
24-
25-
ustring = ustring or ''
26-
if IS_PY3:
27-
return str(ustring)
28-
else: # pragma: no cover
29-
strtype = basestring # noqa
30-
string = ustring
31-
if not isinstance(ustring, strtype):
32-
string = str(ustring)
33-
return string.encode(locale.getpreferredencoding(), 'replace')

bugzilla/bug.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import copy
1010
from logging import getLogger
1111

12-
from ._util import to_encoding
13-
1412

1513
log = getLogger(__name__)
1614

@@ -49,17 +47,13 @@ def __init__(self, bugzilla, bug_id=None, dict=None, autorefresh=False):
4947
def __str__(self):
5048
"""
5149
Return a simple string representation of this bug
52-
53-
This is available only for compatibility. Using 'str(bug)' and
54-
'print(bug)' is not recommended because of potential encoding issues.
55-
Please use unicode(bug) where possible.
5650
"""
57-
return to_encoding(self.__unicode__())
51+
return self.__unicode__()
5852

5953
def __unicode__(self):
6054
"""
6155
Return a simple unicode string representation of this bug
62-
"""
56+
"""
6357
return "#%-6s %-10s - %s - %s" % (self.bug_id, self.bug_status,
6458
self.assigned_to, self.summary)
6559

examples/apikey.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
# apikey.py: Demostrate prompting for API key and passing it to Bugzilla
77
# pylint: disable=undefined-variable
88

9-
from __future__ import print_function
10-
import sys
11-
129
import bugzilla
1310

1411
# Don't worry, changing things here is fine, and won't send any email to
@@ -19,10 +16,7 @@
1916
" https://landfill.bugzilla.org/bugzilla-5.0-branch/userprefs.cgi")
2017
print("This is a test site, so no harm will come!\n")
2118

22-
if sys.version_info[0] >= 3:
23-
api_key = input("Enter Bugzilla API Key: ") # noqa
24-
else:
25-
api_key = raw_input("Enter Bugzilla API Key: ") # noqa
19+
api_key = input("Enter Bugzilla API Key: ")
2620

2721
# API key usage assumes the API caller is storing the API key; if you would
2822
# like to use one of the login options that stores credentials on-disk for

examples/bug_autorefresh.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
# bug_autorefresh.py: Show what bug_autorefresh is all about, and explain
77
# how to handle the default change via python-bugzilla in 2016
88

9-
from __future__ import print_function
10-
119
import bugzilla
1210

1311
# public test instance of bugzilla.redhat.com. It's okay to make changes

examples/create.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
# create.py: Create a new bug report
77

8-
from __future__ import print_function
9-
108
import time
119

1210
import bugzilla

examples/getbug.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
# getbug.py: Simple demonstration of connecting to bugzilla, fetching
77
# a bug, and printing some details.
88

9-
from __future__ import print_function
10-
119
import pprint
1210

1311
import bugzilla

examples/getbug_restapi.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
# Simple demonstration of connecting to bugzilla over the REST
88
# API and printing some bug details.
99

10-
from __future__ import print_function
11-
1210
import bugzilla
1311

1412
# public test instance of bugzilla.redhat.com. It's okay to make changes

examples/query.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
# query.py: Perform a few varieties of queries
77

8-
from __future__ import print_function
9-
108
import time
119

1210
import bugzilla

0 commit comments

Comments
 (0)