86>Aug 3 09:24:25 userdel[2357360]: delete user 'rooter' <86>Aug 3 09:24:25 userdel[2357360]: removed group 'rooter' owned by 'rooter' <86>Aug 3 09:24:25 userdel[2357360]: removed shadow group 'rooter' owned by 'rooter' <86>Aug 3 09:24:25 groupadd[2357385]: group added to /etc/group: name=rooter, GID=591 <86>Aug 3 09:24:25 groupadd[2357385]: group added to /etc/gshadow: name=rooter <86>Aug 3 09:24:25 groupadd[2357385]: new group: name=rooter, GID=591 <86>Aug 3 09:24:25 useradd[2357395]: new user: name=rooter, UID=591, GID=591, home=/root, shell=/bin/bash <86>Aug 3 09:24:25 userdel[2357419]: delete user 'builder' <86>Aug 3 09:24:25 userdel[2357419]: removed group 'builder' owned by 'builder' <86>Aug 3 09:24:25 userdel[2357419]: removed shadow group 'builder' owned by 'builder' <86>Aug 3 09:24:25 groupadd[2357430]: group added to /etc/group: name=builder, GID=592 <86>Aug 3 09:24:25 groupadd[2357430]: group added to /etc/gshadow: name=builder <86>Aug 3 09:24:25 groupadd[2357430]: new group: name=builder, GID=592 <86>Aug 3 09:24:25 useradd[2357437]: new user: name=builder, UID=592, GID=592, home=/usr/src, shell=/bin/bash /usr/src/in/srpm/python-module-ClientForm-0.2.10-alt4.1.2.src.rpm: license not found in '/usr/share/license' directory: BSD-like <13>Aug 3 09:24:27 rpmi: libgdbm-1.8.3-alt10 1454943334 installed <13>Aug 3 09:24:27 rpmi: libexpat-2.2.9-alt1 sisyphus+252464.200.2.1 1590958865 installed <13>Aug 3 09:24:27 rpmi: libp11-kit-0.23.15-alt2 sisyphus+252784.100.2.2 1591274901 installed <13>Aug 3 09:24:27 rpmi: libtasn1-4.16.0-alt1 sisyphus+245480.100.1.1 1580825062 installed <13>Aug 3 09:24:27 rpmi: rpm-macros-alternatives-0.5.1-alt1 sisyphus+226946.100.1.1 1554830426 installed <13>Aug 3 09:24:27 rpmi: alternatives-0.5.1-alt1 sisyphus+226946.100.1.1 1554830426 installed <13>Aug 3 09:24:27 rpmi: ca-certificates-2020.06.29-alt1 sisyphus+254237.300.1.1 1593450881 installed <13>Aug 3 09:24:27 rpmi: ca-trust-0.1.2-alt1 sisyphus+233348.100.1.1 1561653823 installed <13>Aug 3 09:24:27 rpmi: p11-kit-trust-0.23.15-alt2 sisyphus+252784.100.2.2 1591274901 installed <13>Aug 3 09:24:27 rpmi: libcrypto1.1-1.1.1g-alt1 sisyphus+249982.60.8.1 1587743711 installed <13>Aug 3 09:24:27 rpmi: libssl1.1-1.1.1g-alt1 sisyphus+249982.60.8.1 1587743711 installed <13>Aug 3 09:24:27 rpmi: python3-3.8.5-alt1 sisyphus+244405.100.3.1 1595544514 installed <13>Aug 3 09:24:28 rpmi: python3-base-3.8.5-alt1 sisyphus+244405.100.3.1 1595544514 installed <13>Aug 3 09:24:28 rpmi: libpython3-3.8.5-alt1 sisyphus+244405.100.3.1 1595544514 installed <13>Aug 3 09:24:28 rpmi: tests-for-installed-python3-pkgs-0.1.13.1-alt2 1535450458 installed <13>Aug 3 09:24:28 rpmi: rpm-build-python3-0.1.13.1-alt2 1535450458 installed <13>Aug 3 09:24:31 rpmi: python3-module-pkg_resources-1:46.1.3-alt1 sisyphus+250566.200.3.1 1587973342 installed <13>Aug 3 09:24:31 rpmi: libffi6-1:3.2.1-alt4 sisyphus+251953.300.2.1 1589891360 installed <13>Aug 3 09:24:31 rpmi: python-modules-curses-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:31 rpmi: libtinfo-devel-6.1.20180407-alt2 sisyphus+222164.200.1.1 1550686226 installed <13>Aug 3 09:24:31 rpmi: libncurses-devel-6.1.20180407-alt2 sisyphus+222164.200.1.1 1550686226 installed <13>Aug 3 09:24:31 rpmi: python3-dev-3.8.5-alt1 sisyphus+244405.100.3.1 1595544514 installed <13>Aug 3 09:24:31 rpmi: libverto-0.3.0-alt1_7 sisyphus+225932.100.1.1 1553994919 installed <13>Aug 3 09:24:31 rpmi: liblmdb-0.9.23-alt1 sisyphus+225277.100.2.1 1553001679 installed <13>Aug 3 09:24:31 rpmi: libkeyutils-1.6-alt2 sisyphus+226520.100.2.1 1554512089 installed <13>Aug 3 09:24:31 rpmi: libcom_err-1.44.6-alt1 sisyphus+224154.100.1.1 1552091678 installed <86>Aug 3 09:24:31 groupadd[2380620]: group added to /etc/group: name=_keytab, GID=499 <86>Aug 3 09:24:31 groupadd[2380620]: group added to /etc/gshadow: name=_keytab <86>Aug 3 09:24:31 groupadd[2380620]: new group: name=_keytab, GID=499 <13>Aug 3 09:24:32 rpmi: libkrb5-1.18.2-alt2 sisyphus+254565.100.4.1 1594375666 installed <13>Aug 3 09:24:32 rpmi: libtirpc-1.2.6-alt1 sisyphus+250076.100.1.1 1587038270 installed <13>Aug 3 09:24:32 rpmi: libnsl2-1.1.0-alt1_1 1511548749 installed <13>Aug 3 09:24:32 rpmi: python-modules-compiler-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-email-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-unittest-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-encodings-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-nis-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-ctypes-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-multiprocessing-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-logging-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-tools-2to3-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-xml-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-hotshot-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-bsddb-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-modules-distutils-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-module-pkg_resources-1:42.0.0-alt2 sisyphus+250566.100.6.1 1588187716 installed <13>Aug 3 09:24:32 rpmi: python-modules-json-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: libnsl2-devel-1.1.0-alt1_1 1511548749 installed <13>Aug 3 09:24:32 rpmi: python-dev-2.7.18-alt1 sisyphus+250345.100.4.1 1588665080 installed <13>Aug 3 09:24:32 rpmi: python-module-setuptools-1:42.0.0-alt2 sisyphus+250566.100.6.1 1588187716 installed <13>Aug 3 09:24:32 rpmi: python3-module-setuptools-1:46.1.3-alt1 sisyphus+250566.200.3.1 1587973342 installed Building target platforms: i586 Building for target i586 Wrote: /usr/src/in/nosrpm/python-module-ClientForm-0.2.10-alt4.1.2.nosrc.rpm Installing python-module-ClientForm-0.2.10-alt4.1.2.src.rpm Building target platforms: i586 Building for target i586 Executing(%prep): /bin/sh -e /usr/src/tmp/rpm-tmp.71980 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + rm -rf ClientForm-0.2.10 + echo 'Source #0 (ClientForm-0.2.10.tar.gz):' Source #0 (ClientForm-0.2.10.tar.gz): + /bin/gzip -dc /usr/src/RPM/SOURCES/ClientForm-0.2.10.tar.gz + /bin/tar -xf - + cd ClientForm-0.2.10 + /bin/chmod -c -Rf u+rwX,go-w . + cp -fR . ../python3 + exit 0 Executing(%build): /bin/sh -e /usr/src/tmp/rpm-tmp.92397 + umask 022 + /bin/mkdir -p /usr/src/RPM/BUILD + cd /usr/src/RPM/BUILD + cd ClientForm-0.2.10 + CFLAGS='-pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic' + export CFLAGS + CXXFLAGS='-pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic' + export CXXFLAGS + FFLAGS='-pipe -frecord-gcc-switches -Wall -g -O2 -march=i586 -mtune=generic' + export FFLAGS + /usr/bin/python2.7 setup.py build running build running build_py creating build creating build/lib copying ClientForm.py -> build/lib + pushd ../python3 ~/RPM/BUILD/python3 ~/RPM/BUILD/ClientForm-0.2.10 + find ../python3 -type f -name '*.py' -exec 2to3 -w -n '{}' + RefactoringTool: Skipping optional fixer: buffer RefactoringTool: Skipping optional fixer: idioms RefactoringTool: Skipping optional fixer: set_literal RefactoringTool: Skipping optional fixer: ws_comma RefactoringTool: Refactored ../python3/ClientForm.py --- ../python3/ClientForm.py (original) +++ ../python3/ClientForm.py (refactored) @@ -102,9 +102,9 @@ handler.setLevel(logging.DEBUG) _logger.addHandler(handler) -import sys, urllib, urllib2, types, copy, urlparse, \ - htmlentitydefs, re, random -from cStringIO import StringIO +import sys, urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse, types, copy, urllib.parse, \ + html.entities, re, random +from io import StringIO import sgmllib # monkeypatch to fix http://www.python.org/sf/803422 :-( @@ -113,7 +113,7 @@ # HTMLParser.HTMLParser is recent, so live without it if it's not available # (also, sgmllib.SGMLParser is much more tolerant of bad HTML) try: - import HTMLParser + import html.parser except ImportError: HAVE_MODULE_HTMLPARSER = oFalse else: @@ -160,7 +160,7 @@ if hasattr(query,"items"): # mapping objects - query = query.items() + query = list(query.items()) else: # it's a bother at times that strings and string-like objects are # sequences... @@ -168,7 +168,7 @@ # non-sequence items should not work with len() x = len(query) # non-empty strings will fail this - if len(query) and type(query[0]) != types.TupleType: + if len(query) and type(query[0]) != tuple: raise TypeError() # zero-length sequences of all types will get here and succeed, # but that's a minor nit - since the original implementation @@ -183,20 +183,20 @@ if not doseq: # preserve old behavior for k, v in query: - k = urllib.quote_plus(str(k)) - v = urllib.quote_plus(str(v)) + k = urllib.parse.quote_plus(str(k)) + v = urllib.parse.quote_plus(str(v)) l.append(k + '=' + v) else: for k, v in query: - k = urllib.quote_plus(str(k)) - if type(v) == types.StringType: - v = urllib.quote_plus(v) + k = urllib.parse.quote_plus(str(k)) + if type(v) == bytes: + v = urllib.parse.quote_plus(v) l.append(k + '=' + v) - elif type(v) == types.UnicodeType: + elif type(v) == str: # is there a reasonable way to convert to ASCII? # encode generates a string, but "replace" or "ignore" # lose information and "strict" can raise UnicodeError - v = urllib.quote_plus(v.encode("ASCII","replace")) + v = urllib.parse.quote_plus(v.encode("ASCII","replace")) l.append(k + '=' + v) else: try: @@ -204,12 +204,12 @@ x = len(v) except TypeError: # not a sequence - v = urllib.quote_plus(str(v)) + v = urllib.parse.quote_plus(str(v)) l.append(k + '=' + v) else: # loop over the sequence for elt in v: - l.append(k + '=' + urllib.quote_plus(str(elt))) + l.append(k + '=' + urllib.parse.quote_plus(str(elt))) return '&'.join(l) def unescape(data, entities, encoding=DEFAULT_ENCODING): @@ -239,7 +239,7 @@ name, base = data, 10 if name.startswith("x"): name, base= name[1:], 16 - uc = unichr(int(name, base)) + uc = chr(int(name, base)) if encoding is None: return uc else: @@ -250,21 +250,21 @@ return repl def get_entitydefs(): - import htmlentitydefs + import html.entities from codecs import latin_1_decode entitydefs = {} try: - htmlentitydefs.name2codepoint + html.entities.name2codepoint except AttributeError: entitydefs = {} - for name, char in htmlentitydefs.entitydefs.items(): + for name, char in list(html.entities.entitydefs.items()): uc = latin_1_decode(char)[0] if uc.startswith("") and uc.endswith(";"): uc = unescape_charref(uc[2:-1], None) entitydefs["&%s;" % name] = uc else: - for name, codepoint in htmlentitydefs.name2codepoint.items(): - entitydefs["&%s;" % name] = unichr(codepoint) + for name, codepoint in list(html.entities.name2codepoint.items()): + entitydefs["&%s;" % name] = chr(codepoint) return entitydefs @@ -286,7 +286,7 @@ def choose_boundary(): """Return a string usable as a multipart boundary.""" # follow IE and firefox - nonce = "".join([str(random.randint(0, sys.maxint-1)) for i in 0,1,2]) + nonce = "".join([str(random.randint(0, sys.maxsize-1)) for i in (0,1,2)]) return "-"*27 + nonce # This cut-n-pasted MimeWriter from standard library is here so can add @@ -448,7 +448,7 @@ if HAVE_MODULE_HTMLPARSER: SGMLLIB_PARSEERROR = sgmllib.SGMLParseError class ParseError(sgmllib.SGMLParseError, - HTMLParser.HTMLParseError, + html.parser.HTMLParseError, ): pass else: @@ -586,8 +586,8 @@ self._option = {} self._option.update(d) - if (self._optgroup and self._optgroup.has_key("disabled") and - not self._option.has_key("disabled")): + if (self._optgroup and "disabled" in self._optgroup and + "disabled" not in self._option): self._option["disabled"] = None def _end_option(self): @@ -597,9 +597,9 @@ contents = self._option.get("contents", "").strip() self._option["contents"] = contents - if not self._option.has_key("value"): + if "value" not in self._option: self._option["value"] = contents - if not self._option.has_key("label"): + if "label" not in self._option: self._option["label"] = contents # stuff dict of SELECT HTML attrs into a special private key # (gets deleted again later) @@ -687,7 +687,7 @@ else: return - if data and not map.has_key(key): + if data and key not in map: # according to # http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.1 line break # immediately after start tags or immediately before end tags must @@ -759,7 +759,7 @@ def unescape_attrs(self, attrs): #debug("%s", attrs) escaped_attrs = {} - for key, val in attrs.items(): + for key, val in list(attrs.items()): try: val.items except AttributeError: @@ -778,17 +778,17 @@ def __init__(self, entitydefs=None, encoding=DEFAULT_ENCODING): raise ValueError("HTMLParser could not be imported") else: - class XHTMLCompatibleFormParser(_AbstractFormParser, HTMLParser.HTMLParser): + class XHTMLCompatibleFormParser(_AbstractFormParser, html.parser.HTMLParser): """Good for XHTML, bad for tolerance of incorrect HTML.""" # thanks to Michael Howitz for this! def __init__(self, entitydefs=None, encoding=DEFAULT_ENCODING): - HTMLParser.HTMLParser.__init__(self) + html.parser.HTMLParser.__init__(self) _AbstractFormParser.__init__(self, entitydefs, encoding) def feed(self, data): try: - HTMLParser.HTMLParser.feed(self, data) - except HTMLParser.HTMLParseError, exc: + html.parser.HTMLParser.feed(self, data) + except html.parser.HTMLParseError as exc: raise ParseError(exc) def start_option(self, attrs): @@ -829,7 +829,7 @@ return attrs # ditto def close(self): - HTMLParser.HTMLParser.close(self) + html.parser.HTMLParser.close(self) self.end_body() @@ -866,7 +866,7 @@ def feed(self, data): try: sgmllib.SGMLParser.feed(self, data) - except SGMLLIB_PARSEERROR, exc: + except SGMLLIB_PARSEERROR as exc: raise ParseError(exc) def close(self): @@ -892,7 +892,7 @@ def feed(self, data): try: self.bs_base_class.feed(self, data) - except SGMLLIB_PARSEERROR, exc: + except SGMLLIB_PARSEERROR as exc: raise ParseError(exc) def close(self): self.bs_base_class.close(self) @@ -934,14 +934,14 @@ def ParseResponseEx(response, select_default=oFalse, form_parser_class=FormParser, - request_class=urllib2.Request, + request_class=urllib.request.Request, entitydefs=None, encoding=DEFAULT_ENCODING, # private - _urljoin=urlparse.urljoin, - _urlparse=urlparse.urlparse, - _urlunparse=urlparse.urlunparse, + _urljoin=urllib.parse.urljoin, + _urlparse=urllib.parse.urlparse, + _urlunparse=urllib.parse.urlunparse, ): """Identical to ParseResponse, except that: @@ -968,14 +968,14 @@ def ParseFileEx(file, base_uri, select_default=oFalse, form_parser_class=FormParser, - request_class=urllib2.Request, + request_class=urllib.request.Request, entitydefs=None, encoding=DEFAULT_ENCODING, # private - _urljoin=urlparse.urljoin, - _urlparse=urlparse.urlparse, - _urlunparse=urlparse.urlunparse, + _urljoin=urllib.parse.urljoin, + _urlparse=urllib.parse.urlparse, + _urlunparse=urllib.parse.urlunparse, ): """Identical to ParseFile, except that: @@ -1081,13 +1081,13 @@ select_default=oFalse, ignore_errors=oFalse, form_parser_class=FormParser, - request_class=urllib2.Request, + request_class=urllib.request.Request, entitydefs=None, backwards_compat=oTrue, encoding=DEFAULT_ENCODING, - _urljoin=urlparse.urljoin, - _urlparse=urlparse.urlparse, - _urlunparse=urlparse.urlunparse, + _urljoin=urllib.parse.urljoin, + _urlparse=urllib.parse.urlparse, + _urlunparse=urllib.parse.urlunparse, ): if backwards_compat: deprecation("operating in backwards-compatibility mode", 1) @@ -1096,7 +1096,7 @@ data = file.read(CHUNK) try: fp.feed(data) - except ParseError, e: + except ParseError as e: e.base_uri = base_uri raise if len(data) != CHUNK: break @@ -1310,16 +1310,16 @@ self.__dict__["type"] = type.lower() self.__dict__["name"] = name self._value = attrs.get("value") - self.disabled = attrs.has_key("disabled") - self.readonly = attrs.has_key("readonly") + self.disabled = "disabled" in attrs + self.readonly = "readonly" in attrs self.id = attrs.get("id") self.attrs = attrs.copy() self._clicked = oFalse - self._urlparse = urlparse.urlparse - self._urlunparse = urlparse.urlunparse + self._urlparse = urllib.parse.urlparse + self._urlunparse = urllib.parse.urlunparse def __getattr__(self, name): if name == "value": @@ -1531,7 +1531,7 @@ def _totally_ordered_pairs(self): return [] - def _click(self, form, coord, return_type, request_class=urllib2.Request): + def _click(self, form, coord, return_type, request_class=urllib.request.Request): # Relative URL for ISINDEX submission: instead of "foo=bar+baz", # want "bar+baz". # This doesn't seem to be specified in HTML 4.01 spec. (ISINDEX is @@ -1539,7 +1539,7 @@ # Submission of ISINDEX is explained in the HTML 3.2 spec, though. parts = self._urlparse(form.action) rest, (query, frag) = parts[:-2], parts[-2:] - parts = rest + (urllib.quote_plus(self.value), None) + parts = rest + (urllib.parse.quote_plus(self.value), None) url = self._urlunparse(parts) req_data = url, None, [] @@ -1611,7 +1611,7 @@ "_labels": label and [label] or [], "attrs": attrs, "_control": control, - "disabled": attrs.has_key("disabled"), + "disabled": "disabled" in attrs, "_selected": oFalse, "id": attrs.get("id"), "_index": index, @@ -1665,7 +1665,7 @@ def __repr__(self): # XXX appending the attrs without distinguishing them from name and id # is silly - attrs = [("name", self.name), ("id", self.id)]+self.attrs.items() + attrs = [("name", self.name), ("id", self.id)]+list(self.attrs.items()) return "<%s %s>" % ( self.__class__.__name__, " ".join(["%s=%r" % (k, v) for k, v in attrs]) @@ -1673,7 +1673,7 @@ def disambiguate(items, nr, **kwds): msgs = [] - for key, value in kwds.items(): + for key, value in list(kwds.items()): msgs.append("%s=%r" % (key, value)) msg = " ".join(msgs) if not items: @@ -2143,11 +2143,11 @@ item.selected and (not item.disabled or compat)] names = {} for nn in value: - if nn in names.keys(): + if nn in list(names.keys()): names[nn] += 1 else: names[nn] = 1 - for name, count in names.items(): + for name, count in list(names.items()): on, off = self._get_items(name, count) for i in range(count): if on: @@ -2279,7 +2279,7 @@ called_as_base_class=oTrue, index=index) self.__dict__["multiple"] = oFalse o = Item(self, attrs, index) - o.__dict__["_selected"] = attrs.has_key("checked") + o.__dict__["_selected"] = "checked" in attrs def fixup(self): ListControl.fixup(self) @@ -2312,7 +2312,7 @@ called_as_base_class=oTrue, index=index) self.__dict__["multiple"] = oTrue o = Item(self, attrs, index) - o.__dict__["_selected"] = attrs.has_key("checked") + o.__dict__["_selected"] = "checked" in attrs def get_labels(self): return [] @@ -2380,7 +2380,7 @@ self.attrs = attrs["__select"].copy() self.__dict__["_label"] = _get_label(self.attrs) self.__dict__["id"] = self.attrs.get("id") - self.__dict__["multiple"] = self.attrs.has_key("multiple") + self.__dict__["multiple"] = "multiple" in self.attrs # the majority of the contents, label, and value dance already happened contents = attrs.get("contents") attrs = attrs.copy() @@ -2388,12 +2388,12 @@ ListControl.__init__(self, type, name, self.attrs, select_default, called_as_base_class=oTrue, index=index) - self.disabled = self.attrs.has_key("disabled") - self.readonly = self.attrs.has_key("readonly") - if attrs.has_key("value"): + self.disabled = "disabled" in self.attrs + self.readonly = "readonly" in self.attrs + if "value" in attrs: # otherwise it is a marker 'select started' token o = Item(self, attrs, index) - o.__dict__["_selected"] = attrs.has_key("selected") + o.__dict__["_selected"] = "selected" in attrs # add 'label' label and contents label, if different. If both are # provided, the 'label' label is used for display in HTML # 4.0-compliant browsers (and any lower spec? not sure) while the @@ -2458,7 +2458,7 @@ def is_of_kind(self, kind): return kind == "clickable" - def _click(self, form, coord, return_type, request_class=urllib2.Request): + def _click(self, form, coordRefactoringTool: Refactored ../python3/test/test_clientform.py , return_type, request_class=urllib.request.Request): self._clicked = coord r = form._switch_click(return_type, request_class) self._clicked = oFalse @@ -2754,7 +2754,7 @@ def __init__(self, action, method="GET", enctype="application/x-www-form-urlencoded", name=None, attrs=None, - request_class=urllib2.Request, + request_class=urllib.request.Request, forms=None, labels=None, id_to_labels=None, backwards_compat=True): """ @@ -2786,8 +2786,8 @@ self.backwards_compat = backwards_compat # note __setattr__ - self._urlunparse = urlparse.urlunparse - self._urlparse = urlparse.urlparse + self._urlunparse = urllib.parse.urlunparse + self._urlparse = urllib.parse.urlparse def __getattr__(self, name): if name == "backwards_compat": @@ -2893,7 +2893,7 @@ control = self.find_control(name) try: control.value = value - except AttributeError, e: + except AttributeError as e: raise ValueError(str(e)) def get_value(self, @@ -3085,7 +3085,7 @@ # Form submission methods, applying only to clickable controls. def click(self, name=None, type=None, id=None, nr=0, coord=(1,1), - request_class=urllib2.Request, + request_class=urllib.request.Request, label=None): """Return request that would result from clicking on a control. @@ -3114,7 +3114,7 @@ def click_request_data(self, name=None, type=None, id=None, nr=0, coord=(1,1), - request_class=urllib2.Request, + request_class=urllib.request.Request, label=None): """As for click method, but return a tuple (url, data, headers). @@ -3305,7 +3305,7 @@ assert oFalse def _click(self, name, type, id, label, nr, coord, return_type, - request_class=urllib2.Request): + request_class=urllib.request.Request): try: control = self._find_control( name, type, "clickable", id, label, None, nr) @@ -3377,7 +3377,7 @@ else: raise ValueError("Unknown method '%s'" % method) - def _switch_click(self, return_type, request_class=urllib2.Request): + def _switch_click(self, return_type, request_class=urllib.request.Request): # This is called by HTMLForm and clickable Controls to hide switching # on return_type. if return_type == "pairs": --- ../python3/test/test_clientform.py (original) +++ ../python3/test/test_clientform.py (refactored) @@ -8,7 +8,7 @@ import unittest, string from unittest import TestCase -from cStringIO import StringIO +from io import StringIO import ClientForm from ClientForm import ControlNotFoundError, ItemNotFoundError, \ @@ -107,13 +107,13 @@ def test_unescape_charref(self): from ClientForm import unescape_charref, get_entitydefs - mdash_utf8 = u"\u2014".encode("utf-8") + mdash_utf8 = "\u2014".encode("utf-8") for ref, codepoint, utf8, latin1 in [ - ("38", 38, u"&".encode("utf-8"), "&"), + ("38", 38, "&".encode("utf-8"), "&"), ("x2014", 0x2014, mdash_utf8, "—"), ("8212", 8212, mdash_utf8, "—"), ]: - self.assertEqual(unescape_charref(ref, None), unichr(codepoint)) + self.assertEqual(unescape_charref(ref, None), chr(codepoint)) self.assertEqual(unescape_charref(ref, 'latin-1'), latin1) self.assertEqual(unescape_charref(ref, 'utf-8'), utf8) @@ -121,19 +121,19 @@ from ClientForm import get_entitydefs ed = get_entitydefs() for name, char in [ - ("&", u"&"), - ("<", u"<"), - (">", u">"), - ("—", u"\u2014"), - ("♠", u"\u2660"), + ("&", "&"), + ("<", "<"), + (">", ">"), + ("—", "\u2014"), + ("♠", "\u2660"), ]: self.assertEqual(ed[name], char) def test_unescape1(self): - import htmlentitydefs + import html.entities from ClientForm import unescape, get_entitydefs data = "& < — — —" - mdash_utf8 = u"\u2014".encode("utf-8") + mdash_utf8 = "\u2014".encode("utf-8") ue = unescape(data, get_entitydefs(), "utf-8") self.assertEqual("& < %s %s %s" % ((mdash_utf8,)*3), ue) @@ -160,7 +160,7 @@ self.assertEqual(unescape("&", {}), "&") for encoding, expected in [ - ("utf-8", u"&\u06aa\u2014\u2014".encode("utf-8")), + ("utf-8", "&\u06aa\u2014\u2014".encode("utf-8")), ("latin-1", "&ڪ——")]: self.assertEqual( expected, @@ -175,7 +175,7 @@ forms = ClientForm.ParseFile(file, "http://localhost/", backwards_compat=False, encoding="utf-8") form = forms[0] - test_string = "&"+(u"\u2014".encode('utf8')*3) + test_string = "&"+("\u2014".encode('utf8')*3) self.assertEqual(form.action, "http://localhost/"+test_string) control = form.find_control(type="textarea", nr=0) self.assertEqual(control.value, "val"+test_string) @@ -193,7 +193,7 @@ forms = ClientForm.ParseFileEx( f, "http://localhost/", encoding="utf-8") form = forms[1] - test_string = "&"+(u"\u2014".encode('utf8')*3) + test_string = "&"+("\u2014".encode('utf8')*3) control = form.find_control(nr=0) for ii in range(len(control.items)): item = control.items[ii] @@ -221,7 +221,7 @@ def testEmptyParse(self): forms = ClientForm.ParseFile(StringIO(""), "http://localhost", backwards_compat=False) - self.assert_(len(forms) == 0) + self.assertTrue(len(forms) == 0) def _forms(self): file = StringIO("""