Mock Version: 1.4.16 Mock Version: 1.4.16 Mock Version: 1.4.16 ENTER ['do_with_status'](['bash', '--login', '-c', '/usr/bin/rpmbuild -bs --target x86_64 --nodeps /builddir/build/SPECS/python-beautifulsoup4.spec'], chrootPath='/var/lib/mock/943062-fedora-rawhide-x86_64-1561147866.565520/root'env={'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;\\007"', 'PS1': ' \\s-\\v\\$ ', 'LANG': 'en_US.UTF-8'}shell=Falselogger=timeout=0uid=1001gid=135user='mockbuild'nspawn_args=['--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf']unshare_net=FalseprintOutput=True) ENTER ['do_with_status'](['bash', '--login', '-c', '/usr/bin/rpmbuild -bs --target x86_64 --nodeps /builddir/build/SPECS/python-beautifulsoup4.spec'], chrootPath='/var/lib/mock/943062-fedora-rawhide-x86_64-1561147866.565520/root'env={'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;\\007"', 'PS1': ' \\s-\\v\\$ ', 'LANG': 'en_US.UTF-8'}shell=Falselogger=timeout=0uid=1001gid=135user='mockbuild'nspawn_args=['--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf']unshare_net=FalseprintOutput=True) Using nspawn with args ['--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf'] Using nspawn with args ['--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf'] Executing command: ['/usr/bin/systemd-nspawn', '-q', '-M', 'd015f200fd9d4fb698a9783d28f7372e', '-D', '/var/lib/mock/943062-fedora-rawhide-x86_64-1561147866.565520/root', '-a', '--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf', '--setenv=TERM=vt100', '--setenv=SHELL=/bin/bash', '--setenv=HOME=/builddir', '--setenv=HOSTNAME=mock', '--setenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin', '--setenv=PROMPT_COMMAND=printf "\\033]0;\\007"', '--setenv=PS1= \\s-\\v\\$ ', '--setenv=LANG=en_US.UTF-8', '-u', 'mockbuild', 'bash', '--login', '-c', '/usr/bin/rpmbuild -bs --target x86_64 --nodeps /builddir/build/SPECS/python-beautifulsoup4.spec'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;\\007"', 'PS1': ' \\s-\\v\\$ ', 'LANG': 'en_US.UTF-8'} and shell False Executing command: ['/usr/bin/systemd-nspawn', '-q', '-M', 'd015f200fd9d4fb698a9783d28f7372e', '-D', '/var/lib/mock/943062-fedora-rawhide-x86_64-1561147866.565520/root', '-a', '--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf', '--setenv=TERM=vt100', '--setenv=SHELL=/bin/bash', '--setenv=HOME=/builddir', '--setenv=HOSTNAME=mock', '--setenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin', '--setenv=PROMPT_COMMAND=printf "\\033]0;\\007"', '--setenv=PS1= \\s-\\v\\$ ', '--setenv=LANG=en_US.UTF-8', '-u', 'mockbuild', 'bash', '--login', '-c', '/usr/bin/rpmbuild -bs --target x86_64 --nodeps /builddir/build/SPECS/python-beautifulsoup4.spec'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;\\007"', 'PS1': ' \\s-\\v\\$ ', 'LANG': 'en_US.UTF-8'} and shell False Building target platforms: x86_64 Building target platforms: x86_64 Building for target x86_64 Building for target x86_64 Wrote: /builddir/build/SRPMS/python-beautifulsoup4-4.7.1-1.fc31.src.rpm Wrote: /builddir/build/SRPMS/python-beautifulsoup4-4.7.1-1.fc31.src.rpm Child return code was: 0 Child return code was: 0 ENTER ['do_with_status'](['bash', '--login', '-c', '/usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/python-beautifulsoup4.spec'], chrootPath='/var/lib/mock/943062-fedora-rawhide-x86_64-1561147866.565520/root'env={'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;\\007"', 'PS1': ' \\s-\\v\\$ ', 'LANG': 'en_US.UTF-8'}shell=Falselogger=timeout=0uid=1001gid=135user='mockbuild'nspawn_args=['--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf']unshare_net=FalseprintOutput=True) ENTER ['do_with_status'](['bash', '--login', '-c', '/usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/python-beautifulsoup4.spec'], chrootPath='/var/lib/mock/943062-fedora-rawhide-x86_64-1561147866.565520/root'env={'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;\\007"', 'PS1': ' \\s-\\v\\$ ', 'LANG': 'en_US.UTF-8'}shell=Falselogger=timeout=0uid=1001gid=135user='mockbuild'nspawn_args=['--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf']unshare_net=FalseprintOutput=True) Using nspawn with args ['--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf'] Using nspawn with args ['--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf'] Executing command: ['/usr/bin/systemd-nspawn', '-q', '-M', '3548edbf14334b4fac232367c851157b', '-D', '/var/lib/mock/943062-fedora-rawhide-x86_64-1561147866.565520/root', '-a', '--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf', '--setenv=TERM=vt100', '--setenv=SHELL=/bin/bash', '--setenv=HOME=/builddir', '--setenv=HOSTNAME=mock', '--setenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin', '--setenv=PROMPT_COMMAND=printf "\\033]0;\\007"', '--setenv=PS1= \\s-\\v\\$ ', '--setenv=LANG=en_US.UTF-8', '-u', 'mockbuild', 'bash', '--login', '-c', '/usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/python-beautifulsoup4.spec'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;\\007"', 'PS1': ' \\s-\\v\\$ ', 'LANG': 'en_US.UTF-8'} and shell False Executing command: ['/usr/bin/systemd-nspawn', '-q', '-M', '3548edbf14334b4fac232367c851157b', '-D', '/var/lib/mock/943062-fedora-rawhide-x86_64-1561147866.565520/root', '-a', '--capability=cap_ipc_lock', '--bind=/tmp/mock-resolv.ewih9cci:/etc/resolv.conf', '--setenv=TERM=vt100', '--setenv=SHELL=/bin/bash', '--setenv=HOME=/builddir', '--setenv=HOSTNAME=mock', '--setenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin', '--setenv=PROMPT_COMMAND=printf "\\033]0;\\007"', '--setenv=PS1= \\s-\\v\\$ ', '--setenv=LANG=en_US.UTF-8', '-u', 'mockbuild', 'bash', '--login', '-c', '/usr/bin/rpmbuild -bb --target x86_64 --nodeps /builddir/build/SPECS/python-beautifulsoup4.spec'] with env {'TERM': 'vt100', 'SHELL': '/bin/bash', 'HOME': '/builddir', 'HOSTNAME': 'mock', 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'PROMPT_COMMAND': 'printf "\\033]0;\\007"', 'PS1': ' \\s-\\v\\$ ', 'LANG': 'en_US.UTF-8'} and shell False Building target platforms: x86_64 Building target platforms: x86_64 Building for target x86_64 Building for target x86_64 Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.HHhJRv Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.HHhJRv + umask 022 + umask 022 + cd /builddir/build/BUILD + cd /builddir/build/BUILD + cd /builddir/build/BUILD + cd /builddir/build/BUILD + rm -rf beautifulsoup4-4.7.1 + rm -rf beautifulsoup4-4.7.1 + /usr/bin/gzip -dc /builddir/build/SOURCES/beautifulsoup4-4.7.1.tar.gz + /usr/bin/gzip -dc /builddir/build/SOURCES/beautifulsoup4-4.7.1.tar.gz + /usr/bin/tar -xof - + /usr/bin/tar -xof - + STATUS=0 + STATUS=0 + '[' 0 -ne 0 ']' + '[' 0 -ne 0 ']' + cd beautifulsoup4-4.7.1 + cd beautifulsoup4-4.7.1 + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w . + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w . + rm -rf /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 + rm -rf /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 + cp -a . /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 + cp -a . /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 + RPM_EC=0 + RPM_EC=0 BUILDSTDERR: ++ jobs -p BUILDSTDERR: ++ jobs -p + exit 0 + exit 0 Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.GZCyPu Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.GZCyPu + umask 022 + umask 022 + cd /builddir/build/BUILD + cd /builddir/build/BUILD + cd beautifulsoup4-4.7.1 + cd beautifulsoup4-4.7.1 + sleep 1 + sleep 1 + CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' + CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' + /usr/bin/python2 setup.py build '--executable=/usr/bin/python2 -s' + /usr/bin/python2 setup.py build '--executable=/usr/bin/python2 -s' + sleep 1 + sleep 1 + pushd /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 + pushd /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 + 2to3 --write --nobackups . + 2to3 --write --nobackups . BUILDSTDERR: RefactoringTool: Skipping optional fixer: buffer BUILDSTDERR: RefactoringTool: Skipping optional fixer: buffer BUILDSTDERR: RefactoringTool: Skipping optional fixer: idioms BUILDSTDERR: RefactoringTool: Skipping optional fixer: idioms BUILDSTDERR: RefactoringTool: Skipping optional fixer: set_literal BUILDSTDERR: RefactoringTool: Skipping optional fixer: set_literal BUILDSTDERR: RefactoringTool: Skipping optional fixer: ws_comma BUILDSTDERR: RefactoringTool: Skipping optional fixer: ws_comma BUILDSTDERR: RefactoringTool: No changes to ./setup.py BUILDSTDERR: RefactoringTool: No changes to ./setup.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/__init__.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/__init__.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/dammit.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/dammit.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/diagnose.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/diagnose.py running build running build running build_py running build_py creating build creating build creating build/lib creating build/lib creating build/lib/bs4 creating build/lib/bs4 copying bs4/testing.py -> build/lib/bs4 copying bs4/testing.py -> build/lib/bs4 copying bs4/element.py -> build/lib/bs4 copying bs4/element.py -> build/lib/bs4 copying bs4/diagnose.py -> build/lib/bs4 copying bs4/diagnose.py -> build/lib/bs4 copying bs4/dammit.py -> build/lib/bs4 copying bs4/dammit.py -> build/lib/bs4 copying bs4/__init__.py -> build/lib/bs4 copying bs4/__init__.py -> build/lib/bs4 creating build/lib/bs4/tests creating build/lib/bs4/tests copying bs4/tests/test_tree.py -> build/lib/bs4/tests copying bs4/tests/test_tree.py -> build/lib/bs4/tests copying bs4/tests/test_soup.py -> build/lib/bs4/tests copying bs4/tests/test_soup.py -> build/lib/bs4/tests copying bs4/tests/test_lxml.py -> build/lib/bs4/tests copying bs4/tests/test_lxml.py -> build/lib/bs4/tests copying bs4/tests/test_htmlparser.py -> build/lib/bs4/tests copying bs4/tests/test_htmlparser.py -> build/lib/bs4/tests copying bs4/tests/test_html5lib.py -> build/lib/bs4/tests copying bs4/tests/test_html5lib.py -> build/lib/bs4/tests copying bs4/tests/test_docs.py -> build/lib/bs4/tests copying bs4/tests/test_docs.py -> build/lib/bs4/tests copying bs4/tests/test_builder_registry.py -> build/lib/bs4/tests copying bs4/tests/test_builder_registry.py -> build/lib/bs4/tests copying bs4/tests/__init__.py -> build/lib/bs4/tests copying bs4/tests/__init__.py -> build/lib/bs4/tests creating build/lib/bs4/builder creating build/lib/bs4/builder copying bs4/builder/_lxml.py -> build/lib/bs4/builder copying bs4/builder/_lxml.py -> build/lib/bs4/builder copying bs4/builder/_htmlparser.py -> build/lib/bs4/builder copying bs4/builder/_htmlparser.py -> build/lib/bs4/builder copying bs4/builder/_html5lib.py -> build/lib/bs4/builder copying bs4/builder/_html5lib.py -> build/lib/bs4/builder copying bs4/builder/__init__.py -> build/lib/bs4/builder copying bs4/builder/__init__.py -> build/lib/bs4/builder ~/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 ~/build/BUILD/beautifulsoup4-4.7.1 ~/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 ~/build/BUILD/beautifulsoup4-4.7.1 --- ./bs4/__init__.py (original) --- ./bs4/__init__.py (original) +++ ./bs4/__init__.py (refactored) +++ ./bs4/__init__.py (refactored) @@ -49,7 +49,7 @@ @@ -49,7 +49,7 @@ # The very first thing we do is give a useful error if someone is # The very first thing we do is give a useful error if someone is # running this code under Python 3 without converting it. # running this code under Python 3 without converting it. -'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'<>'You need to convert the code, either by installing it (`python setup.py install`) or by running 2to3 (`2to3 -w bs4`).' -'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'<>'You need to convert the code, either by installing it (`python setup.py install`) or by running 2to3 (`2to3 -w bs4`).' +'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'!='You need to convert the code, either by installing it (`python setup.py install`) or by running 2to3 (`2to3 -w bs4`).' +'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'!='You need to convert the code, either by installing it (`python setup.py install`) or by running 2to3 (`2to3 -w bs4`).' class BeautifulSoup(Tag): class BeautifulSoup(Tag): """ """ @@ -73,7 +73,7 @@ @@ -73,7 +73,7 @@ like HTML's
tag), call handle_starttag and then like HTML's
tag), call handle_starttag and then handle_endtag. handle_endtag. """ """ - ROOT_TAG_NAME = u'[document]' - ROOT_TAG_NAME = u'[document]' + ROOT_TAG_NAME = '[document]' + ROOT_TAG_NAME = '[document]' # If the end-user gives no indication which tree builder they # If the end-user gives no indication which tree builder they # want, look for one with these features. # want, look for one with these features. @@ -173,18 +173,18 @@ @@ -173,18 +173,18 @@ from_encoding = from_encoding or deprecated_argument( from_encoding = from_encoding or deprecated_argument( "fromEncoding", "from_encoding") "fromEncoding", "from_encoding") - if from_encoding and isinstance(markup, unicode): - if from_encoding and isinstance(markup, unicode): + if from_encoding and isinstance(markup, str): + if from_encoding and isinstance(markup, str): warnings.warn("You provided Unicode markup but also provided a value for from_encoding. Your from_encoding will be ignored.") warnings.warn("You provided Unicode markup but also provided a value for from_encoding. Your from_encoding will be ignored.") from_encoding = None from_encoding = None if len(kwargs) > 0: if len(kwargs) > 0: - arg = kwargs.keys().pop() - arg = kwargs.keys().pop() + arg = list(kwargs.keys()).pop() + arg = list(kwargs.keys()).pop() raise TypeError( raise TypeError( "__init__() got an unexpected keyword argument '%s'" % arg) "__init__() got an unexpected keyword argument '%s'" % arg) if builder is None: if builder is None: original_features = features original_features = features - if isinstance(features, basestring): - if isinstance(features, basestring): + if isinstance(features, str): + if isinstance(features, str): features = [features] features = [features] if features is None or len(features) == 0: if features is None or len(features) == 0: features = self.DEFAULT_BUILDER_FEATURES features = self.DEFAULT_BUILDER_FEATURES @@ -244,13 +244,13 @@ @@ -244,13 +244,13 @@ markup = markup.read() markup = markup.read() elif len(markup) <= 256 and ( elif len(markup) <= 256 and ( (isinstance(markup, bytes) and not b'<' in markup) (isinstance(markup, bytes) and not b'<' in markup) - or (isinstance(markup, unicode) and not u'<' in markup) - or (isinstance(markup, unicode) and not u'<' in markup) + or (isinstance(markup, str) and not '<' in markup) + or (isinstance(markup, str) and not '<' in markup) ): ): # Print out warnings for a couple beginner problems # Print out warnings for a couple beginner problems # involving passing non-markup to Beautiful Soup. # involving passing non-markup to Beautiful Soup. # Beautiful Soup will still parse the input as markup, # Beautiful Soup will still parse the input as markup, # just in case that's what the user really wants. # just in case that's what the user really wants. - if (isinstance(markup, unicode) - if (isinstance(markup, unicode) + if (isinstance(markup, str) + if (isinstance(markup, str) and not os.path.supports_unicode_filenames): and not os.path.supports_unicode_filenames): possible_filename = markup.encode("utf8") possible_filename = markup.encode("utf8") else: else: @@ -258,13 +258,13 @@ @@ -258,13 +258,13 @@ is_file = False is_file = False try: try: is_file = os.path.exists(possible_filename) is_file = os.path.exists(possible_filename) - except Exception, e: - except Exception, e: + except Exception as e: + except Exception as e: # This is almost certainly a problem involving # This is almost certainly a problem involving # characters not valid in filenames on this # characters not valid in filenames on this # system. Just let it go. # system. Just let it go. pass pass if is_file: if is_file: - if isinstance(markup, unicode): - if isinstance(markup, unicode): + if isinstance(markup, str): + if isinstance(markup, str): markup = markup.encode("utf8") markup = markup.encode("utf8") warnings.warn( warnings.warn( '"%s" looks like a filename, not markup. You should' '"%s" looks like a filename, not markup. You should' @@ -316,9 +316,9 @@ @@ -316,9 +316,9 @@ if isinstance(markup, bytes): if isinstance(markup, bytes): space = b' ' space = b' ' cant_start_with = (b"http:", b"https:") cant_start_with = (b"http:", b"https:") - elif isinstance(markup, unicode): - elif isinstance(markup, unicode): - space = u' ' - space = u' ' - cant_start_with = (u"http:", u"https:") - cant_start_with = (u"http:", u"https:") + elif isinstance(markup, str): + elif isinstance(markup, str): + space = ' ' + space = ' ' + cant_start_with = ("http:", "https:") + cant_start_with = ("http:", "https:") else: else: return return @@ -390,7 +390,7 @@ @@ -390,7 +390,7 @@ def endData(self, containerClass=NavigableString): def endData(self, containerClass=NavigableString): if self.current_data: if self.current_data: - current_data = u''.join(self.current_data) - current_data = u''.join(self.current_data) + current_data = ''.join(self.current_data) + current_data = ''.join(self.current_data) # If whitespace is not preserved, and this string contains # If whitespace is not preserved, and this string contains # nothing but ASCII spaces, replace it with a single space # nothing but ASCII spaces, replace it with a single space # or newline. # or newline. @@ -555,9 +555,9 @@ @@ -555,9 +555,9 @@ encoding_part = '' encoding_part = '' if eventual_encoding != None: if eventual_encoding != None: encoding_part = ' encoding="%s"' % eventual_encoding encoding_part = ' encoding="%s"' % eventual_encoding - prefix = u'\n' % encoding_part - prefix = u'\n' % encoding_part + prefix = '\n' % encoding_part + prefix = '\n' % encoding_part else: else: - prefix = u'' - prefix = u'' + prefix = '' + prefix = '' if not pretty_print: if not pretty_print: indent_level = None indent_level = None else: else: @@ -591,4 +591,4 @@ @@ -591,4 +591,4 @@ if __name__ == '__main__': if __name__ == '__main__': import sys import sys soup = BeautifulSoup(sys.stdin) soup = BeautifulSoup(sys.stdin) - print soup.prettify() - print soup.prettify() + print(soup.prettify()) + print(soup.prettify()) --- ./bs4/dammit.py (original) --- ./bs4/dammit.py (original) +++ ./bs4/dammit.py (refactored) +++ ./bs4/dammit.py (refactored) @@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@ __license__ = "MIT" __license__ = "MIT" import codecs import codecs -from htmlentitydefs import codepoint2name -from htmlentitydefs import codepoint2name +from html.entities import codepoint2name +from html.entities import codepoint2name import re import re import logging import logging import string import string @@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@ reverse_lookup = {} reverse_lookup = {} characters_for_re = [] characters_for_re = [] for codepoint, name in list(codepoint2name.items()): for codepoint, name in list(codepoint2name.items()): - character = unichr(codepoint) - character = unichr(codepoint) + character = chr(codepoint) + character = chr(codepoint) if codepoint != 34: if codepoint != 34: # There's no point in turning the quotation mark into # There's no point in turning the quotation mark into # ", unless it happens within an attribute value, which # ", unless it happens within an attribute value, which @@ -273,7 +273,7 @@ @@ -273,7 +273,7 @@ def strip_byte_order_mark(cls, data): def strip_byte_order_mark(cls, data): """If a byte-order mark is present, strip it and return the encoding it implies.""" """If a byte-order mark is present, strip it and return the encoding it implies.""" encoding = None encoding = None - if isinstance(data, unicode): - if isinstance(data, unicode): + if isinstance(data, str): + if isinstance(data, str): # Unicode data cannot have a byte-order mark. # Unicode data cannot have a byte-order mark. return data, encoding return data, encoding if (len(data) >= 4) and (data[:2] == b'\xfe\xff') \ if (len(data) >= 4) and (data[:2] == b'\xfe\xff') \ @@ -351,9 +351,9 @@ @@ -351,9 +351,9 @@ markup, override_encodings, is_html, exclude_encodings) markup, override_encodings, is_html, exclude_encodings) # Short-circuit if the data is in Unicode to begin with. # Short-circuit if the data is in Unicode to begin with. - if isinstance(markup, unicode) or markup == '': - if isinstance(markup, unicode) or markup == '': + if isinstance(markup, str) or markup == '': + if isinstance(markup, str) or markup == '': self.markup = markup self.markup = markup - self.unicode_markup = unicode(markup) - self.unicode_markup = unicode(markup) + self.unicode_markup = str(markup) + self.unicode_markup = str(markup) self.original_encoding = None self.original_encoding = None return return @@ -437,7 +437,7 @@ @@ -437,7 +437,7 @@ def _to_unicode(self, data, encoding, errors="strict"): def _to_unicode(self, data, encoding, errors="strict"): '''Given a string and its encoding, decodes the string into Unicode. '''Given a string and its encoding, decodes the string into Unicode. %encoding is a string recognized by encodings.aliases''' %encoding is a string recognized by encodings.aliases''' - return unicode(data, encoding, errors) - return unicode(data, encoding, errors) + return str(data, encoding, errors) + return str(data, encoding, errors) @property @property def declared_html_encoding(self): def declared_html_encoding(self): --- ./bs4/diagnose.py (original) --- ./bs4/diagnose.py (original) +++ ./bs4/diagnose.py (refactored) +++ ./bs4/diagnose.py (refactored) @@ -4,8 +4,8 @@ @@ -4,8 +4,8 @@ __license__ = "MIT" __license__ = "MIT" import cProfile import cProfile -from StringIO import StringIO -from StringIO import StringIO -from HTMLParser import HTMLParser -from HTMLParser import HTMLParser +from io import StringIO +from io import StringIO +from html.parser import HTMLParser +from html.parser import HTMLParser import bs4 import bs4 from bs4 import BeautifulSoup, __version__ from bs4 import BeautifulSoup, __version__ from bs4.builder import builder_registry from bs4.builder import builder_registry BUILDSTDERR: @@ -RefactoringTool: Refactored ./bs4/element.py BUILDSTDERR: @@ -RefactoringTool: Refactored ./bs4/element.py 21,8 +21,8 @@ 21,8 +21,8 @@ def diagnose(data): def diagnose(data): """Diagnostic suite for isolating common problems.""" """Diagnostic suite for isolating common problems.""" - print "Diagnostic running on Beautiful Soup %s" % __version__ - print "Diagnostic running on Beautiful Soup %s" % __version__ - print "Python version %s" % sys.version - print "Python version %s" % sys.version + print("Diagnostic running on Beautiful Soup %s" % __version__) + print("Diagnostic running on Beautiful Soup %s" % __version__) + print("Python version %s" % sys.version) + print("Python version %s" % sys.version) basic_parsers = ["html.parser", "html5lib", "lxml"] basic_parsers = ["html.parser", "html5lib", "lxml"] for name in basic_parsers: for name in basic_parsers: @@ -31,16 +31,16 @@ @@ -31,16 +31,16 @@ break break else: else: basic_parsers.remove(name) basic_parsers.remove(name) - print ( - print ( + print(( + print(( "I noticed that %s is not installed. Installing it may help." % "I noticed that %s is not installed. Installing it may help." % - name) - name) + name)) + name)) if 'lxml' in basic_parsers: if 'lxml' in basic_parsers: basic_parsers.append("lxml-xml") basic_parsers.append("lxml-xml") try: try: from lxml import etree from lxml import etree - print "Found lxml version %s" % ".".join(map(str,etree.LXML_VERSION)) - print "Found lxml version %s" % ".".join(map(str,etree.LXML_VERSION)) - except ImportError, e: - except ImportError, e: + print("Found lxml version %s" % ".".join(map(str,etree.LXML_VERSION))) + print("Found lxml version %s" % ".".join(map(str,etree.LXML_VERSION))) + except ImportError as e: + except ImportError as e: print ( print ( "lxml is not installed or couldn't be imported.") "lxml is not installed or couldn't be imported.") @@ -48,43 +48,43 @@ @@ -48,43 +48,43 @@ if 'html5lib' in basic_parsers: if 'html5lib' in basic_parsers: try: try: import html5lib import html5lib - print "Found html5lib version %s" % html5lib.__version__ - print "Found html5lib version %s" % html5lib.__version__ - except ImportError, e: - except ImportError, e: + print("Found html5lib version %s" % html5lib.__version__) + print("Found html5lib version %s" % html5lib.__version__) + except ImportError as e: + except ImportError as e: print ( print ( "html5lib is not installed or couldn't be imported.") "html5lib is not installed or couldn't be imported.") if hasattr(data, 'read'): if hasattr(data, 'read'): data = data.read() data = data.read() elif data.startswith("http:") or data.startswith("https:"): elif data.startswith("http:") or data.startswith("https:"): - print '"%s" looks like a URL. Beautiful Soup is not an HTTP client.' % data - print '"%s" looks like a URL. Beautiful Soup is not an HTTP client.' % data - print "You need to use some other library to get the document behind the URL, and feed that document to Beautiful Soup." - print "You need to use some other library to get the document behind the URL, and feed that document to Beautiful Soup." + print('"%s" looks like a URL. Beautiful Soup is not an HTTP client.' % data) + print('"%s" looks like a URL. Beautiful Soup is not an HTTP client.' % data) + print("You need to use some other library to get the document behind the URL, and feed that document to Beautiful Soup.") + print("You need to use some other library to get the document behind the URL, and feed that document to Beautiful Soup.") return return else: else: try: try: if os.path.exists(data): if os.path.exists(data): - print '"%s" looks like a filename. Reading data from the file.' % data - print '"%s" looks like a filename. Reading data from the file.' % data + print('"%s" looks like a filename. Reading data from the file.' % data) + print('"%s" looks like a filename. Reading data from the file.' % data) with open(data) as fp: with open(data) as fp: data = fp.read() data = fp.read() except ValueError: except ValueError: # This can happen on some platforms when the 'filename' is # This can happen on some platforms when the 'filename' is # too long. Assume it's data and not a filename. # too long. Assume it's data and not a filename. pass pass - print - print + print() + print() for parser in basic_parsers: for parser in basic_parsers: - print "Trying to parse your markup with %s" % parser - print "Trying to parse your markup with %s" % parser + print("Trying to parse your markup with %s" % parser) + print("Trying to parse your markup with %s" % parser) success = False success = False try: try: soup = BeautifulSoup(data, features=parser) soup = BeautifulSoup(data, features=parser) success = True success = True - except Exception, e: - except Exception, e: - print "%s could not parse the markup." % parser - print "%s could not parse the markup." % parser + except Exception as e: + except Exception as e: + print("%s could not parse the markup." % parser) + print("%s could not parse the markup." % parser) traceback.print_exc() traceback.print_exc() if success: if success: - print "Here's what %s did with the markup:" % parser - print "Here's what %s did with the markup:" % parser - print soup.prettify() - print soup.prettify() - - - print "-" * 80 - print "-" * 80 + print("Here's what %s did with the markup:" % parser) + print("Here's what %s did with the markup:" % parser) + print(soup.prettify()) + print(soup.prettify()) + + + print("-" * 80) + print("-" * 80) def lxml_trace(data, html=True, **kwargs): def lxml_trace(data, html=True, **kwargs): """Print out the lxml events that occur during parsing. """Print out the lxml events that occur during parsing. @@ -94,7 +94,7 @@ @@ -94,7 +94,7 @@ """ """ from lxml import etree from lxml import etree for event, element in etree.iterparse(StringIO(data), html=html, **kwargs): for event, element in etree.iterparse(StringIO(data), html=html, **kwargs): - print("%s, %4s, %s" % (event, element.tag, element.text)) - print("%s, %4s, %s" % (event, element.tag, element.text)) + print(("%s, %4s, %s" % (event, element.tag, element.text))) + print(("%s, %4s, %s" % (event, element.tag, element.text))) class AnnouncingParser(HTMLParser): class AnnouncingParser(HTMLParser): """Announces HTMLParser parse events, without doing anything else.""" """Announces HTMLParser parse events, without doing anything else.""" @@ -176,9 +176,9 @@ @@ -176,9 +176,9 @@ def benchmark_parsers(num_elements=100000): def benchmark_parsers(num_elements=100000): """Very basic head-to-head performance benchmark.""" """Very basic head-to-head performance benchmark.""" - print "Comparative parser benchmark on Beautiful Soup %s" % __version__ - print "Comparative parser benchmark on Beautiful Soup %s" % __version__ + print("Comparative parser benchmark on Beautiful Soup %s" % __version__) + print("Comparative parser benchmark on Beautiful Soup %s" % __version__) data = rdoc(num_elements) data = rdoc(num_elements) - print "Generated a large invalid HTML document (%d bytes)." % len(data) - print "Generated a large invalid HTML document (%d bytes)." % len(data) + print("Generated a large invalid HTML document (%d bytes)." % len(data)) + print("Generated a large invalid HTML document (%d bytes)." % len(data)) for parser in ["lxml", ["lxml", "html"], "html5lib", "html.parser"]: for parser in ["lxml", ["lxml", "html"], "html5lib", "html.parser"]: success = False success = False @@ -187,24 +187,24 @@ @@ -187,24 +187,24 @@ soup = BeautifulSoup(data, parser) soup = BeautifulSoup(data, parser) b = time.time() b = time.time() success = True success = True - except Exception, e: - except Exception, e: - print "%s could not parse the markup." % parser - print "%s could not parse the markup." % parser + except Exception as e: + except Exception as e: + print("%s could not parse the markup." % parser) + print("%s could not parse the markup." % parser) traceback.print_exc() traceback.print_exc() if success: if success: - print "BS4+%s parsed the markup in %.2fs." % (parser, b-a) - print "BS4+%s parsed the markup in %.2fs." % (parser, b-a) + print("BS4+%s parsed the markup in %.2fs." % (parser, b-a)) + print("BS4+%s parsed the markup in %.2fs." % (parser, b-a)) from lxml import etree from lxml import etree a = time.time() a = time.time() etree.HTML(data) etree.HTML(data) b = time.time() b = time.time() - print "Raw lxml parsed the markup in %.2fs." % (b-a) - print "Raw lxml parsed the markup in %.2fs." % (b-a) + print("Raw lxml parsed the markup in %.2fs." % (b-a)) + print("Raw lxml parsed the markup in %.2fs." % (b-a)) import html5lib import html5lib parser = html5lib.HTMLParser() parser = html5lib.HTMLParser() a = time.time() a = time.time() parser.parse(data) parser.parse(data) b = time.time() b = time.time() - print "Raw html5lib parsed the markup in %.2fs." % (b-a) - print "Raw html5lib parsed the markup in %.2fs." % (b-a) + print("Raw html5lib parsed the markup in %.2fs." % (b-a)) + print("Raw html5lib parsed the markup in %.2fs." % (b-a)) def profile(num_elements=100000, parser="lxml"): def profile(num_elements=100000, parser="lxml"): --- ./bs4/element.py (original) --- ./bs4/element.py (original) +++ ./bs4/element.py (refactored) +++ ./bs4/element.py (refactored) @@ -3,14 +3,14 @@ @@ -3,14 +3,14 @@ try: try: from collections.abc import Callable # Python 3.6 from collections.abc import Callable # Python 3.6 -except ImportError , e: -except ImportError , e: +except ImportError as e: +except ImportError as e: from collections import Callable from collections import Callable import re import re import sys import sys import warnings import warnings try: try: import soupsieve import soupsieve -except ImportError, e: -except ImportError, e: +except ImportError as e: +except ImportError as e: soupsieve = None soupsieve = None warnings.warn( warnings.warn( 'The soupsieve package is not installed. CSS selectors cannot be used.' 'The soupsieve package is not installed. CSS selectors cannot be used.' @@ -39,22 +39,22 @@ @@ -39,22 +39,22 @@ return alias return alias -class NamespacedAttribute(unicode): -class NamespacedAttribute(unicode): +class NamespacedAttribute(str): +class NamespacedAttribute(str): def __new__(cls, prefix, name, namespace=None): def __new__(cls, prefix, name, namespace=None): if name is None: if name is None: - obj = unicode.__new__(cls, prefix) - obj = unicode.__new__(cls, prefix) + obj = str.__new__(cls, prefix) + obj = str.__new__(cls, prefix) elif prefix is None: elif prefix is None: # Not really namespaced. # Not really namespaced. - obj = unicode.__new__(cls, name) - obj = unicode.__new__(cls, name) - else: - else: - obj = unicode.__new__(cls, prefix + ":" + name) - obj = unicode.__new__(cls, prefix + ":" + name) + obj = str.__new__(cls, name) + obj = str.__new__(cls, name) + else: + else: + obj = str.__new__(cls, prefix + ":" + name) + obj = str.__new__(cls, prefix + ":" + name) obj.prefix = prefix obj.prefix = prefix obj.name = name obj.name = name obj.namespace = namespace obj.namespace = namespace return obj return obj -class AttributeValueWithCharsetSubstitution(unicode): -class AttributeValueWithCharsetSubstitution(unicode): +class AttributeValueWithCharsetSubstitution(str): +class AttributeValueWithCharsetSubstitution(str): """A stand-in object for a character encoding specified in HTML.""" """A stand-in object for a character encoding specified in HTML.""" class CharsetMetaAttributeValue(AttributeValueWithCharsetSubstitution): class CharsetMetaAttributeValue(AttributeValueWithCharsetSubstitution): @@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@ """ """ def __new__(cls, original_value): def __new__(cls, original_value): - obj = unicode.__new__(cls, original_value) - obj = unicode.__new__(cls, original_value) + obj = str.__new__(cls, original_value) + obj = str.__new__(cls, original_value) obj.original_value = original_value obj.original_value = original_value return obj return obj @@ -88,9 +88,9 @@ @@ -88,9 +88,9 @@ match = cls.CHARSET_RE.search(original_value) match = cls.CHARSET_RE.search(original_value) if match is None: if match is None: # No substitution necessary. # No substitution necessary. - return unicode.__new__(unicode, original_value) - return unicode.__new__(unicode, original_value) - - - obj = unicode.__new__(cls, original_value) - obj = unicode.__new__(cls, original_value) + return str.__new__(str, original_value) + return str.__new__(str, original_value) + + + obj = str.__new__(cls, original_value) + obj = str.__new__(cls, original_value) obj.original_value = original_value obj.original_value = original_value return obj return obj @@ -212,7 +212,7 @@ @@ -212,7 +212,7 @@ def format_string(self, s, formatter='minimal'): def format_string(self, s, formatter='minimal'): """Format the given string using the given formatter.""" """Format the given string using the given formatter.""" - if isinstance(formatter, basestring): - if isinstance(formatter, basestring): + if isinstance(formatter, str): + if isinstance(formatter, str): formatter = self._formatter_for_name(formatter) formatter = self._formatter_for_name(formatter) if formatter is None: if formatter is None: output = s output = s @@ -367,7 +367,7 @@ @@ -367,7 +367,7 @@ raise ValueError("Cannot insert None into a tag.") raise ValueError("Cannot insert None into a tag.") if new_child is self: if new_child is self: raise ValueError("Cannot insert a tag into itself.") raise ValueError("Cannot insert a tag into itself.") - if (isinstance(new_child, basestring) - if (isinstance(new_child, basestring) + if (isinRefactoringTool: Refactored ./bs4/testing.py + if (isinRefactoringTool: Refactored ./bs4/testing.py stance(new_child, str) stance(new_child, str) and not isinstance(new_child, NavigableString)): and not isinstance(new_child, NavigableString)): new_child = NavigableString(new_child) new_child = NavigableString(new_child) @@ -607,7 +607,7 @@ @@ -607,7 +607,7 @@ result = (element for element in generator result = (element for element in generator if isinstance(element, Tag)) if isinstance(element, Tag)) return ResultSet(strainer, result) return ResultSet(strainer, result) - elif isinstance(name, basestring): - elif isinstance(name, basestring): + elif isinstance(name, str): + elif isinstance(name, str): # Optimization to find all tags with a given name. # Optimization to find all tags with a given name. if name.count(':') == 1: if name.count(':') == 1: # This is a name with a prefix. If this is a namespace-aware document, # This is a name with a prefix. If this is a namespace-aware document, @@ -696,7 +696,7 @@ @@ -696,7 +696,7 @@ return self.parents return self.parents -class NavigableString(unicode, PageElement): -class NavigableString(unicode, PageElement): +class NavigableString(str, PageElement): +class NavigableString(str, PageElement): PREFIX = '' PREFIX = '' SUFFIX = '' SUFFIX = '' @@ -714,10 +714,10 @@ @@ -714,10 +714,10 @@ passed in to the superclass's __new__ or the superclass won't know passed in to the superclass's __new__ or the superclass won't know how to handle non-ASCII characters. how to handle non-ASCII characters. """ """ - if isinstance(value, unicode): - if isinstance(value, unicode): - u = unicode.__new__(cls, value) - u = unicode.__new__(cls, value) - else: - else: - u = unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING) - u = unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING) + if isinstance(value, str): + if isinstance(value, str): + u = str.__new__(cls, value) + u = str.__new__(cls, value) + else: + else: + u = str.__new__(cls, value, DEFAULT_OUTPUT_ENCODING) + u = str.__new__(cls, value, DEFAULT_OUTPUT_ENCODING) u.setup() u.setup() return u return u @@ -728,7 +728,7 @@ @@ -728,7 +728,7 @@ return type(self)(self) return type(self)(self) def __getnewargs__(self): def __getnewargs__(self): - return (unicode(self),) - return (unicode(self),) + return (str(self),) + return (str(self),) def __getattr__(self, attr): def __getattr__(self, attr): """text.string gives you text. This is for backwards """text.string gives you text. This is for backwards @@ -768,29 +768,29 @@ @@ -768,29 +768,29 @@ class CData(PreformattedString): class CData(PreformattedString): - PREFIX = u'' - SUFFIX = u']]>' + PREFIX = '' + SUFFIX = ']]>' class ProcessingInstruction(PreformattedString): class ProcessingInstruction(PreformattedString): """A SGML processing instruction.""" """A SGML processing instruction.""" - PREFIX = u'' - SUFFIX = u'>' + PREFIX = '' + SUFFIX = '>' class XMLProcessingInstruction(ProcessingInstruction): class XMLProcessingInstruction(ProcessingInstruction): """An XML processing instruction.""" """An XML processing instruction.""" - PREFIX = u'' - SUFFIX = u'?>' + PREFIX = '' + SUFFIX = '?>' class Comment(PreformattedString): class Comment(PreformattedString): - PREFIX = u'' - SUFFIX = u'-->' + PREFIX = '' + SUFFIX = '-->' class Declaration(PreformattedString): class Declaration(PreformattedString): - PREFIX = u'' - SUFFIX = u'?>' + PREFIX = '' + SUFFIX = '?>' class Doctype(PreformattedString): class Doctype(PreformattedString): @@ -807,8 +807,8 @@ @@ -807,8 +807,8 @@ return Doctype(value) return Doctype(value) - PREFIX = u'\n' - SUFFIX = u'>\n' + PREFIX = '\n' + SUFFIX = '>\n' class Tag(PageElement): class Tag(PageElement): @@ -947,7 +947,7 @@ @@ -947,7 +947,7 @@ for string in self._all_strings(True): for string in self._all_strings(True): yield string yield string - def get_text(self, separator=u"", strip=False, - def get_text(self, separator=u"", strip=False, + def get_text(self, separator="", strip=False, + def get_text(self, separator="", strip=False, types=(NavigableString, CData)): types=(NavigableString, CData)): """ """ Get all child strings, concatenated using the given separator. Get all child strings, concatenated using the given separator. @@ -1026,7 +1026,7 @@ @@ -1026,7 +1026,7 @@ def __contains__(self, x): def __contains__(self, x): return x in self.contents return x in self.contents - def __nonzero__(self): - def __nonzero__(self): + def __bool__(self): + def __bool__(self): "A tag is non-None even if it has no contents." "A tag is non-None even if it has no contents." return True return True @@ -1148,8 +1148,8 @@ @@ -1148,8 +1148,8 @@ else: else: if isinstance(val, list) or isinstance(val, tuple): if isinstance(val, list) or isinstance(val, tuple): val = ' '.join(val) val = ' '.join(val) - elif not isinstance(val, basestring): - elif not isinstance(val, basestring): - val = unicode(val) - val = unicode(val) + elif not isinstance(val, str): + elif not isinstance(val, str): + val = str(val) + val = str(val) elif ( elif ( isinstance(val, AttributeValueWithCharsetSubstitution) isinstance(val, AttributeValueWithCharsetSubstitution) and eventual_encoding is not None): and eventual_encoding is not None): @@ -1157,7 +1157,7 @@ @@ -1157,7 +1157,7 @@ text = self.format_string(val, formatter) text = self.format_string(val, formatter) decoded = ( decoded = ( - unicode(key) + '=' - unicode(key) + '=' + str(key) + '=' + str(key) + '=' + EntitySubstitution.quoted_attribute_value(text)) + EntitySubstitution.quoted_attribute_value(text)) attrs.append(decoded) attrs.append(decoded) close = '' close = '' @@ -1416,7 +1416,7 @@ @@ -1416,7 +1416,7 @@ else: else: attrs = kwargs attrs = kwargs normalized_attrs = {} normalized_attrs = {} - for key, value in attrs.items(): - for key, value in attrs.items(): + for key, value in list(attrs.items()): + for key, value in list(attrs.items()): normalized_attrs[key] = self._normalize_search_value(value) normalized_attrs[key] = self._normalize_search_value(value) self.attrs = normalized_attrs self.attrs = normalized_attrs @@ -1425,7 +1425,7 @@ @@ -1425,7 +1425,7 @@ def _normalize_search_value(self, value): def _normalize_search_value(self, value): # Leave it alone if it's a Unicode string, a callable, a # Leave it alone if it's a Unicode string, a callable, a # regular expression, a boolean, or None. # regular expression, a boolean, or None. - if (isinstance(value, unicode) or isinstance(value, Callable) or hasattr(value, 'match') - if (isinstance(value, unicode) or isinstance(value, Callable) or hasattr(value, 'match') + if (isinstance(value, str) or isinstance(value, Callable) or hasattr(value, 'match') + if (isinstance(value, str) or isinstance(value, Callable) or hasattr(value, 'match') or isinstance(value, bool) or value is None): or isinstance(value, bool) or value is None): return value return value @@ -1438,7 +1438,7 @@ @@ -1438,7 +1438,7 @@ new_value = [] new_value = [] for v in value: for v in value: if (hasattr(v, '__iter__') and not isinstance(v, bytes) if (hasattr(v, '__iter__') and not isinstance(v, bytes) - and not isinstance(v, unicode)): - and not isinstance(v, unicode)): + and not isinstance(v, str)): + and not isinstance(v, str)): # This is almost certainly the user's mistake. In the # This is almost certainly the user's mistake. In the # interests of avoiding infinite loops, we'll let # interests of avoiding infinite loops, we'll let # it through as-is rather than doing a recursive call. # it through as-is rather than doing a recursive call. @@ -1450,7 +1450,7 @@ @@ -1450,7 +1450,7 @@ # Otherwise, convert it into a Unicode string. # Otherwise, convert it into a Unicode string. # The unicode(str()) thing is so this will do the same thing on Python 2 # The unicode(str()) thing is so this will do the same thing on Python 2 # and Python 3. # and Python 3. - return unicode(str(value)) - return unicode(str(value)) + return str(str(value)) + return str(str(value)) def __str__(self): def __str__(self): if self.text: if self.text: @@ -1504,7 +1504,7 @@ @@ -1504,7 +1504,7 @@ found = None found = None # If given a list of items, scan it for a text element that # If given a list of items, scan it for a text element that # matches. # matches. - if hasattr(markup, '__iter__') and not isinstance(markup, (Tag, basestring)): - if hasattr(markup, '__iter__') and not isinstance(markup, (Tag, basestring)): + if hasattr(markup, '__iter__') and not isinstance(markup, (Tag, str)): + if hasattr(markup, '__iter__') and not isinstance(markup, (Tag, str)): for element in markup: for element in markup: if isinstance(element, NavigableString) \ if isinstance(element, NavigableString) \ and self.search(element): and self.search(element): @@ -1517,7 +1517,7 @@ @@ -1517,7 +1517,7 @@ found = self.search_tag(markup) found = self.search_tag(markup) # If it's text, make sure the text matches. # If it's text, make sure the text matches. elif isinstance(markup, NavigableString) or \ elif isinstance(markup, NavigableString) or \ - isinstance(markup, basestring): - isinstance(markup, basestring): + isinstance(markup, str): + isinstance(markup, str): if not self.name and not self.attrs and self._matches(markup, self.text): if not self.name and not self.attrs and self._matches(markup, self.text): found = markup found = markup else: else: @@ -1562,7 +1562,7 @@ @@ -1562,7 +1562,7 @@ return not match_against return not match_against if (hasattr(match_against, '__iter__') if (hasattr(match_against, '__iter__') - and not isinstance(match_against, basestring)): - and not isinstance(match_against, basestring)): + and not isinstance(match_against, str)): + and not isinstance(match_against, str)): # We're asked to match against an iterable of items. # We're asked to match against an iterable of items. # The markup must be match at least one item in the # The markup must be match at least one item in the # iterable. We'll try each one in turn. # iterable. We'll try each one in turn. @@ -1589,7 +1589,7 @@ @@ -1589,7 +1589,7 @@ # the tag's name and once against its prefixed name. # the tag's name and once against its prefixed name. match = False match = False - if not match and isinstance(match_against, unicode): - if not match and isinstance(match_against, unicode): + if not match and isinstance(match_against, str): + if not match and isinstance(match_against, str): # Exact string match # Exact string match match = markup == match_against match = markup == match_against --- ./bs4/testing.py (original) --- ./bs4/testing.py (original) +++ ./bs4/testing.py (refactored) +++ ./bs4/testing.py (refactored) @@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@ from bs4.builder import HTMLParserTreeBuilder from bs4.builder import HTMLParserTreeBuilder default_builder = HTMLParserTreeBuilder default_builder = HTMLParserTreeBuilder -BAD_DOCUMENT = u"""A bare string -BAD_DOCUMENT = u"""A bare string +BAD_DOCUMENT = """A bare string +BAD_DOCUMENT = """A bare string
@@ -315,7 +315,7 @@ @@ -315,7 +315,7 @@ # process_markup correctly sets processing_instruction_class # process_markup correctly sets processing_instruction_class # even when the markup is already Unicode and there is no # even when the markup is already Unicode and there is no # need to process anything. # need to process anything. - markup = u"""""" - markup = u"""""" + markup = """""" + markup = """""" soup = self.soup(markup) soup = self.soup(markup) self.assertEqual(markup, soup.decode()) self.assertEqual(markup, soup.decode()) @@ -487,8 +487,8 @@ @@ -487,8 +487,8 @@ # "&T" and "&p" look like incomplete character entities, but they are # "&T" and "&p" look like incomplete character entities, but they are # not. # not. self.assertSoupEquals( self.assertSoupEquals( - u"

• AT&T is in the s&p 500

", - u"

• AT&T is in the s&p 500

", - u"

\u2022 AT&T is in the s&p 500

" - u"

\u2022 AT&T is in the s&p 500

" + "

• AT&T is in the s&p 500

", + "

• AT&T is in the s&p 500

", + RefactoringTool: Refactored ./bs4/builder/__init__.py + RefactoringTool: Refactored ./bs4/builder/__init__.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/builder/_html5lib.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/builder/_html5lib.py "

\u2022 AT&T is in the s&p 500

" "

\u2022 AT&T is in the s&p 500

" ) ) def test_entities_in_foreign_document_encoding(self): def test_entities_in_foreign_document_encoding(self): @@ -501,17 +501,17 @@ @@ -501,17 +501,17 @@ # characters. # characters. markup = "

“Hello” -☃

" markup = "

“Hello” -☃

" soup = self.soup(markup) soup = self.soup(markup) - self.assertEquals(u"“Hello” -☃", soup.p.string) - self.assertEquals(u"“Hello” -☃", soup.p.string) + self.assertEqual("“Hello” -☃", soup.p.string) + self.assertEqual("“Hello” -☃", soup.p.string) def test_entities_in_attributes_converted_to_unicode(self): def test_entities_in_attributes_converted_to_unicode(self): - expect = u'

' - expect = u'

' + expect = '

' + expect = '

' self.assertSoupEquals('

', expect) self.assertSoupEquals('

', expect) self.assertSoupEquals('

', expect) self.assertSoupEquals('

', expect) self.assertSoupEquals('

', expect) self.assertSoupEquals('

', expect) self.assertSoupEquals('

', expect) self.assertSoupEquals('

', expect) def test_entities_in_text_converted_to_unicode(self): def test_entities_in_text_converted_to_unicode(self): - expect = u'

pi\N{LATIN SMALL LETTER N WITH TILDE}ata

' - expect = u'

pi\N{LATIN SMALL LETTER N WITH TILDE}ata

' + expect = '

pi\N{LATIN SMALL LETTER N WITH TILDE}ata

' + expect = '

pi\N{LATIN SMALL LETTER N WITH TILDE}ata

' self.assertSoupEquals("

piñata

", expect) self.assertSoupEquals("

piñata

", expect) self.assertSoupEquals("

piñata

", expect) self.assertSoupEquals("

piñata

", expect) self.assertSoupEquals("

piñata

", expect) self.assertSoupEquals("

piñata

", expect) @@ -522,7 +522,7 @@ @@ -522,7 +522,7 @@ '

I said "good day!"

') '

I said "good day!"

') def test_out_of_range_entity(self): def test_out_of_range_entity(self): - expect = u"\N{REPLACEMENT CHARACTER}" - expect = u"\N{REPLACEMENT CHARACTER}" + expect = "\N{REPLACEMENT CHARACTER}" + expect = "\N{REPLACEMENT CHARACTER}" self.assertSoupEquals("�", expect) self.assertSoupEquals("�", expect) self.assertSoupEquals("�", expect) self.assertSoupEquals("�", expect) self.assertSoupEquals("�", expect) self.assertSoupEquals("�", expect) @@ -600,9 +600,9 @@ @@ -600,9 +600,9 @@ # A seemingly innocuous document... but it's in Unicode! And # A seemingly innocuous document... but it's in Unicode! And # it contains characters that can't be represented in the # it contains characters that can't be represented in the # encoding found in the declaration! The horror! # encoding found in the declaration! The horror! - markup = u'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' - markup = u'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' - soup = self.soup(markup) - soup = self.soup(markup) - self.assertEqual(u'Sacr\xe9 bleu!', soup.body.string) - self.assertEqual(u'Sacr\xe9 bleu!', soup.body.string) + markup = 'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' + markup = 'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' + soup = self.soup(markup) + soup = self.soup(markup) + self.assertEqual('Sacr\xe9 bleu!', soup.body.string) + self.assertEqual('Sacr\xe9 bleu!', soup.body.string) def test_soupstrainer(self): def test_soupstrainer(self): """Parsers should be able to work with SoupStrainers.""" """Parsers should be able to work with SoupStrainers.""" @@ -642,7 +642,7 @@ @@ -642,7 +642,7 @@ # Both XML and HTML entities are converted to Unicode characters # Both XML and HTML entities are converted to Unicode characters # during parsing. # during parsing. text = "

<<sacré bleu!>>

" text = "

<<sacré bleu!>>

" - expected = u"

<<sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>

" - expected = u"

<<sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>

" + expected = "

<<sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>

" + expected = "

<<sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>

" self.assertSoupEquals(text, expected) self.assertSoupEquals(text, expected) def test_smart_quotes_converted_on_the_way_in(self): def test_smart_quotes_converted_on_the_way_in(self): @@ -652,15 +652,15 @@ @@ -652,15 +652,15 @@ soup = self.soup(quote) soup = self.soup(quote) self.assertEqual( self.assertEqual( soup.p.string, soup.p.string, - u"\N{LEFT SINGLE QUOTATION MARK}Foo\N{RIGHT SINGLE QUOTATION MARK}") - u"\N{LEFT SINGLE QUOTATION MARK}Foo\N{RIGHT SINGLE QUOTATION MARK}") + "\N{LEFT SINGLE QUOTATION MARK}Foo\N{RIGHT SINGLE QUOTATION MARK}") + "\N{LEFT SINGLE QUOTATION MARK}Foo\N{RIGHT SINGLE QUOTATION MARK}") def test_non_breaking_spaces_converted_on_the_way_in(self): def test_non_breaking_spaces_converted_on_the_way_in(self): soup = self.soup("  ") soup = self.soup("  ") - self.assertEqual(soup.a.string, u"\N{NO-BREAK SPACE}" * 2) - self.assertEqual(soup.a.string, u"\N{NO-BREAK SPACE}" * 2) + self.assertEqual(soup.a.string, "\N{NO-BREAK SPACE}" * 2) + self.assertEqual(soup.a.string, "\N{NO-BREAK SPACE}" * 2) def test_entities_converted_on_the_way_out(self): def test_entities_converted_on_the_way_out(self): text = "

<<sacré bleu!>>

" text = "

<<sacré bleu!>>

" - expected = u"

<<sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>

".encode("utf-8") - expected = u"

<<sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>

".encode("utf-8") + expected = "

<<sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>

".encode("utf-8") + expected = "

<<sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>

".encode("utf-8") soup = self.soup(text) soup = self.soup(text) self.assertEqual(soup.p.encode("utf-8"), expected) self.assertEqual(soup.p.encode("utf-8"), expected) @@ -669,7 +669,7 @@ @@ -669,7 +669,7 @@ # easy-to-understand document. # easy-to-understand document. # Here it is in Unicode. Note that it claims to be in ISO-Latin-1. # Here it is in Unicode. Note that it claims to be in ISO-Latin-1. - unicode_html = u'

Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!

' - unicode_html = u'

Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!

' + unicode_html = '

Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!

' + unicode_html = '

Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!

' # That's because we're going to encode it into ISO-Latin-1, and use # That's because we're going to encode it into ISO-Latin-1, and use # that to test. # that to test. @@ -847,15 +847,15 @@ @@ -847,15 +847,15 @@ self.assertTrue(b"< < hey > >" in encoded) self.assertTrue(b"< < hey > >" in encoded) def test_can_parse_unicode_document(self): def test_can_parse_unicode_document(self): - markup = u'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' - markup = u'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' - soup = self.soup(markup) - soup = self.soup(markup) - self.assertEqual(u'Sacr\xe9 bleu!', soup.root.string) - self.assertEqual(u'Sacr\xe9 bleu!', soup.root.string) + markup = 'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' + markup = 'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' + soup = self.soup(markup) + soup = self.soup(markup) + self.assertEqual('Sacr\xe9 bleu!', soup.root.string) + self.assertEqual('Sacr\xe9 bleu!', soup.root.string) def test_popping_namespaced_tag(self): def test_popping_namespaced_tag(self): markup = 'b2012-07-02T20:33:42Zcd' markup = 'b2012-07-02T20:33:42Zcd' soup = self.soup(markup) soup = self.soup(markup) self.assertEqual( self.assertEqual( - unicode(soup.rss), markup) - unicode(soup.rss), markup) + str(soup.rss), markup) + str(soup.rss), markup) def test_docstring_includes_correct_encoding(self): def test_docstring_includes_correct_encoding(self): soup = self.soup("") soup = self.soup("") @@ -886,17 +886,17 @@ @@ -886,17 +886,17 @@ def test_closing_namespaced_tag(self): def test_closing_namespaced_tag(self): markup = '

20010504

' markup = '

20010504

' soup = self.soup(markup) soup = self.soup(markup) - self.assertEqual(unicode(soup.p), markup) - self.assertEqual(unicode(soup.p), markup) + self.assertEqual(str(soup.p), markup) + self.assertEqual(str(soup.p), markup) def test_namespaced_attributes(self): def test_namespaced_attributes(self): markup = '' markup = '' soup = self.soup(markup) soup = self.soup(markup) - self.assertEqual(unicode(soup.foo), markup) - self.assertEqual(unicode(soup.foo), markup) + self.assertEqual(str(soup.foo), markup) + self.assertEqual(str(soup.foo), markup) def test_namespaced_attributes_xml_namespace(self): def test_namespaced_attributes_xml_namespace(self): markup = 'bar' markup = 'bar' soup = self.soup(markup) soup = self.soup(markup) - self.assertEqual(unicode(soup.foo), markup) - self.assertEqual(unicode(soup.foo), markup) + self.assertEqual(str(soup.foo), markup) + self.assertEqual(str(soup.foo), markup) def test_find_by_prefixed_name(self): def test_find_by_prefixed_name(self): doc = """ doc = """ --- ./bs4/builder/__init__.py (original) --- ./bs4/builder/__init__.py (original) +++ ./bs4/builder/__init__.py (refactored) +++ ./bs4/builder/__init__.py (refactored) @@ -166,13 +166,13 @@ @@ -166,13 +166,13 @@ universal = self.cdata_list_attributes.get('*', []) universal = self.cdata_list_attributes.get('*', []) tag_specific = self.cdata_list_attributes.get( tag_specific = self.cdata_list_attributes.get( tag_name.lower(), None) tag_name.lower(), None) - for attr in attrs.keys(): - for attr in attrs.keys(): + for attr in list(attrs.keys()): + for attr in list(attrs.keys()): if attr in universal or (tag_specific and attr in tag_specific): if attr in universal or (tag_specific and attr in tag_specific): # We have a "class"-type attribute whose string # We have a "class"-type attribute whose string # value is a whitespace-separated list of # value is a whitespace-separated list of # values. Split it into a list. # values. Split it into a list. value = attrs[attr] value = attrs[attr] - if isinstance(value, basestring): - if isinstance(value, basestring): + if isinstance(value, str): + if isinstance(value, str): values = nonwhitespace_re.findall(value) values = nonwhitespace_re.findall(value) else: else: # html5lib sometimes calls setAttributes twice # html5lib sometimes calls setAttributes twice --- ./bs4/builder/_html5lib.py (original) --- ./bs4/builder/_html5lib.py (original) +++ ./bs4/builder/_html5lib.py (refactored) +++ ./bs4/builder/_html5lib.py (refactored) @@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@ # Pre-0.99999999 # Pre-0.99999999 from html5lib.treebuilders import _base as treebuilder_base from html5lib.treebuilders import _base as treebuilder_base new_html5lib = False new_html5lib = False -except ImportError, e: -except ImportError, e: +except ImportError as e: +except ImportError as e: # 0.99999999 and up # 0.99999999 and up from html5lib.treebuilders import base as treebuilder_base from html5lib.treebuilders import base as treebuilder_base new_html5lib = True new_html5lib = True @@ -64,7 +64,7 @@ @@ -64,7 +64,7 @@ parser = html5lib.HTMLParser(tree=self.create_treebuilder) parser = html5lib.HTMLParser(tree=self.create_treebuilder) extra_kwargs = dict() extra_kwargs = dict() - if not isinstance(markup, unicode): - if not isinstance(markup, unicode): + if not isinstance(markup, str): + if not isinstance(markup, str): if new_html5lib: if new_html5lib: extra_kwargs['override_encoding'] = self.user_specified_encoding extra_kwargs['override_encoding'] = self.user_specified_encoding else: else: @@ -72,13 +72,13 @@ @@ -72,13 +72,13 @@ doc = parser.parse(markup, **extra_kwargs) doc = parser.parse(markup, **extra_kwargs) BUILDSTDERR: # Set the character encoding detected by theRefactoringTool: Refactored ./bs4/builder/_htmlparser.py BUILDSTDERR: # Set the character encoding detected by theRefactoringTool: Refactored ./bs4/builder/_htmlparser.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/builder/_lxml.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/builder/_lxml.py BUILDSTDERR: RefactoringTool: No changes to ./bs4/tests/__init__.py BUILDSTDERR: RefactoringTool: No changes to ./bs4/tests/__init__.py BUILDSTDERR: RefactoringTool: No changes to ./bs4/tests/test_builder_registry.py BUILDSTDERR: RefactoringTool: No changes to ./bs4/tests/test_builder_registry.py BUILDSTDERR: RefactoringTool: No changes to ./bs4/tests/test_docs.py BUILDSTDERR: RefactoringTool: No changes to ./bs4/tests/test_docs.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/tests/test_html5lib.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/tests/test_html5lib.py tokenizer. tokenizer. - if isinstance(markup, unicode): - if isinstance(markup, unicode): + if isinstance(markup, str): + if isinstance(markup, str): # We need to special-case this because html5lib sets # We need to special-case this because html5lib sets # charEncoding to UTF-8 if it gets Unicode input. # charEncoding to UTF-8 if it gets Unicode input. doc.original_encoding = None doc.original_encoding = None else: else: original_encoding = parser.tokenizer.stream.charEncoding[0] original_encoding = parser.tokenizer.stream.charEncoding[0] - if not isinstance(original_encoding, basestring): - if not isinstance(original_encoding, basestring): + if not isinstance(original_encoding, str): + if not isinstance(original_encoding, str): # In 0.99999999 and up, the encoding is an html5lib # In 0.99999999 and up, the encoding is an html5lib # Encoding object. We want to use a string for compatibility # Encoding object. We want to use a string for compatibility # with other tree builders. # with other tree builders. @@ -92,7 +92,7 @@ @@ -92,7 +92,7 @@ def test_fragment_to_document(self, fragment): def test_fragment_to_document(self, fragment): """See `TreeBuilder`.""" """See `TreeBuilder`.""" - return u'%s' % fragment - return u'%s' % fragment + return '%s' % fragment + return '%s' % fragment class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder): class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder): @@ -174,7 +174,7 @@ @@ -174,7 +174,7 @@ rv.append("|%s<%s>" % (' ' * indent, name)) rv.append("|%s<%s>" % (' ' * indent, name)) if element.attrs: if element.attrs: attributes = [] attributes = [] - for name, value in element.attrs.items(): - for name, value in element.attrs.items(): + for name, value in list(element.attrs.items()): + for name, value in list(element.attrs.items()): if isinstance(name, NamespacedAttribute): if isinstance(name, NamespacedAttribute): name = "%s %s" % (prefixes[name.namespace], name.name) name = "%s %s" % (prefixes[name.namespace], name.name) if isinstance(value, list): if isinstance(value, list): @@ -229,7 +229,7 @@ @@ -229,7 +229,7 @@ def appendChild(self, node): def appendChild(self, node): string_child = child = None string_child = child = None - if isinstance(node, basestring): - if isinstance(node, basestring): + if isinstance(node, str): + if isinstance(node, str): # Some other piece of code decided to pass in a string # Some other piece of code decided to pass in a string # instead of creating a TextElement object to contain the # instead of creating a TextElement object to contain the # string. # string. @@ -246,7 +246,7 @@ @@ -246,7 +246,7 @@ child = node.element child = node.element node.parent = self node.parent = self - if not isinstance(child, basestring) and child.parent is not None: - if not isinstance(child, basestring) and child.parent is not None: + if not isinstance(child, str) and child.parent is not None: + if not isinstance(child, str) and child.parent is not None: node.element.extract() node.element.extract() if (string_child is not None and self.element.contents if (string_child is not None and self.element.contents @@ -259,7 +259,7 @@ @@ -259,7 +259,7 @@ old_element.replace_with(new_element) old_element.replace_with(new_element) self.soup._most_recent_element = new_element self.soup._most_recent_element = new_element else: else: - if isinstance(node, basestring): - if isinstance(node, basestring): + if isinstance(node, str): + if isinstance(node, str): # Create a brand new NavigableString from this string. # Create a brand new NavigableString from this string. child = self.soup.new_string(node) child = self.soup.new_string(node) @@ -299,7 +299,7 @@ @@ -299,7 +299,7 @@ self.soup.builder._replace_cdata_list_attribute_values( self.soup.builder._replace_cdata_list_attribute_values( self.name, attributes) self.name, attributes) - for name, value in attributes.items(): - for name, value in attributes.items(): + for name, value in list(attributes.items()): + for name, value in list(attributes.items()): self.element[name] = value self.element[name] = value # The attributes may contain variables that need substitution. # The attributes may contain variables that need substitution. --- ./bs4/builder/_htmlparser.py (original) --- ./bs4/builder/_htmlparser.py (original) +++ ./bs4/builder/_htmlparser.py (refactored) +++ ./bs4/builder/_htmlparser.py (refactored) @@ -8,11 +8,11 @@ @@ -8,11 +8,11 @@ 'HTMLParserTreeBuilder', 'HTMLParserTreeBuilder', ] ] -from HTMLParser import HTMLParser -from HTMLParser import HTMLParser +from html.parser import HTMLParser +from html.parser import HTMLParser try: try: - from HTMLParser import HTMLParseError - from HTMLParser import HTMLParseError -except ImportError, e: -except ImportError, e: + from html.parser import HTMLParseError + from html.parser import HTMLParseError +except ImportError as e: +except ImportError as e: # HTMLParseError is removed in Python 3.5. Since it can never be # HTMLParseError is removed in Python 3.5. Since it can never be # thrown in 3.5, we can just define our own class as a placeholder. # thrown in 3.5, we can just define our own class as a placeholder. class HTMLParseError(Exception): class HTMLParseError(Exception): @@ -153,14 +153,14 @@ @@ -153,14 +153,14 @@ continue continue try: try: data = bytearray([real_name]).decode(encoding) data = bytearray([real_name]).decode(encoding) - except UnicodeDecodeError, e: - except UnicodeDecodeError, e: + except UnicodeDecodeError as e: + except UnicodeDecodeError as e: pass pass if not data: if not data: try: try: - data = unichr(real_name) - data = unichr(real_name) - except (ValueError, OverflowError), e: - except (ValueError, OverflowError), e: + data = chr(real_name) + data = chr(real_name) + except (ValueError, OverflowError) as e: + except (ValueError, OverflowError) as e: pass pass - data = data or u"\N{REPLACEMENT CHARACTER}" - data = data or u"\N{REPLACEMENT CHARACTER}" + data = data or "\N{REPLACEMENT CHARACTER}" + data = data or "\N{REPLACEMENT CHARACTER}" self.handle_data(data) self.handle_data(data) def handle_entityref(self, name): def handle_entityref(self, name): @@ -228,7 +228,7 @@ @@ -228,7 +228,7 @@ declared within markup, whether any characters had to be declared within markup, whether any characters had to be replaced with REPLACEMENT CHARACTER). replaced with REPLACEMENT CHARACTER). """ """ - if isinstance(markup, unicode): - if isinstance(markup, unicode): + if isinstance(markup, str): + if isinstance(markup, str): yield (markup, None, None, False) yield (markup, None, None, False) return return @@ -246,7 +246,7 @@ @@ -246,7 +246,7 @@ try: try: parser.feed(markup) parser.feed(markup) parser.close() parser.close() - except HTMLParseError, e: - except HTMLParseError, e: + except HTMLParseError as e: + except HTMLParseError as e: warnings.warn(RuntimeWarning( warnings.warn(RuntimeWarning( "Python's built-in HTMLParser cannot parse the given document. This is not a bug in Beautiful Soup. The best solution is to install an external parser (lxml or html5lib), and use Beautiful Soup with that parser. See http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser for help.")) "Python's built-in HTMLParser cannot parse the given document. This is not a bug in Beautiful Soup. The best solution is to install an external parser (lxml or html5lib), and use Beautiful Soup with that parser. See http://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-a-parser for help.")) raise e raise e --- ./bs4/builder/_lxml.py (original) --- ./bs4/builder/_lxml.py (original) +++ ./bs4/builder/_lxml.py (refactored) +++ ./bs4/builder/_lxml.py (refactored) @@ -8,11 +8,11 @@ @@ -8,11 +8,11 @@ try: try: from collections.abc import Callable # Python 3.6 from collections.abc import Callable # Python 3.6 -except ImportError , e: -except ImportError , e: +except ImportError as e: +except ImportError as e: from collections import Callable from collections import Callable from io import BytesIO from io import BytesIO -from StringIO import StringIO -from StringIO import StringIO +from io import StringIO +from io import StringIO from lxml import etree from lxml import etree from bs4.element import ( from bs4.element import ( Comment, Comment, @@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@ def _invert(d): def _invert(d): "Invert a dictionary." "Invert a dictionary." - return dict((v,k) for k, v in d.items()) - return dict((v,k) for k, v in d.items()) + return dict((v,k) for k, v in list(d.items())) + return dict((v,k) for k, v in list(d.items())) class LXMLTreeBuilderForXML(TreeBuilder): class LXMLTreeBuilderForXML(TreeBuilder): DEFAULT_PARSER_CLASS = etree.XMLParser DEFAULT_PARSER_CLASS = etree.XMLParser @@ -70,7 +70,7 @@ @@ -70,7 +70,7 @@ This might be useful later on when creating CSS selectors. This might be useful later on when creating CSS selectors. """ """ - for key, value in mapping.items(): - for key, value in mapping.items(): + for key, value in list(mapping.items()): + for key, value in list(mapping.items()): if key and key not in self.soup._namespaces: if key and key not in self.soup._namespaces: # Let the BeautifulSoup object know about a new namespace. # Let the BeautifulSoup object know about a new namespace. # If there are multiple namespaces defined with the same # If there are multiple namespaces defined with the same @@ -132,12 +132,12 @@ @@ -132,12 +132,12 @@ else: else: self.processing_instruction_class = XMLProcessingInstruction self.processing_instruction_class = XMLProcessingInstruction - if isinstance(markup, unicode): - if isinstance(markup, unicode): + if isinstance(markup, str): + if isinstance(markup, str): # We were given Unicode. Maybe lxml can parse Unicode on # We were given Unicode. Maybe lxml can parse Unicode on # this system? # this system? yield markup, None, document_declared_encoding, False yield markup, None, document_declared_encoding, False - if isinstance(markup, unicode): - if isinstance(markup, unicode): + if isinstance(markup, str): + if isinstance(markup, str): # No, apparently not. Convert the Unicode to UTF-8 and # No, apparently not. Convert the Unicode to UTF-8 and # tell lxml to parse it as UTF-8. # tell lxml to parse it as UTF-8. yield (markup.encode("utf8"), "utf8", yield (markup.encode("utf8"), "utf8", @@ -152,7 +152,7 @@ @@ -152,7 +152,7 @@ def feed(self, markup): def feed(self, markup): if isinstance(markup, bytes): if isinstance(markup, bytes): markup = BytesIO(markup) markup = BytesIO(markup) - elif isinstance(markup, unicode): - elif isinstance(markup, unicode): + elif isinstance(markup, str): + elif isinstance(markup, str): markup = StringIO(markup) markup = StringIO(markup) # Call feed() at least once, even if the markup is empty, # Call feed() at least once, even if the markup is empty, @@ -167,7 +167,7 @@ @@ -167,7 +167,7 @@ if len(data) != 0: if len(data) != 0: self.parser.feed(data) self.parser.feed(data) self.parser.close() self.parser.close() - except (UnicodeDecodeError, LookupError, etree.ParserError), e: - except (UnicodeDecodeError, LookupError, etree.ParserError), e: + except (UnicodeDecodeError, LookupError, etree.ParserError) as e: + except (UnicodeDecodeError, LookupError, etree.ParserError) as e: raise ParserRejectedMarkup(str(e)) raise ParserRejectedMarkup(str(e)) def close(self): def close(self): @@ -196,7 +196,7 @@ @@ -196,7 +196,7 @@ # Also treat the namespace mapping as a set of attributes on the # Also treat the namespace mapping as a set of attributes on the # tag, so we can recreate it later. # tag, so we can recreate it later. attrs = attrs.copy() attrs = attrs.copy() - for prefix, namespace in nsmap.items(): - for prefix, namespace in nsmap.items(): + for prefix, namespace in list(nsmap.items()): + for prefix, namespace in list(nsmap.items()): attribute = NamespacedAttribute( attribute = NamespacedAttribute( "xmlns", prefix, "http://www.w3.org/2000/xmlns/") "xmlns", prefix, "http://www.w3.org/2000/xmlns/") attrs[attribute] = namespace attrs[attribute] = namespace @@ -205,7 +205,7 @@ @@ -205,7 +205,7 @@ # from lxml with namespaces attached to their names, and # from lxml with namespaces attached to their names, and # turn then into NamespacedAttribute objects. # turn then into NamespacedAttribute objects. new_attrs = {} new_attrs = {} - for attr, value in attrs.items(): - for attr, value in attrs.items(): + for attr, value in list(attrs.items()): + for attr, value in list(attrs.items()): namespace, attr = self._getNsTag(attr) namespace, attr = self._getNsTag(attr) if namespace is None: if namespace is None: new_attrs[attr] = value new_attrs[attr] = value @@ -265,7 +265,7 @@ @@ -265,7 +265,7 @@ def test_fragment_to_document(self, fragment): def test_fragment_to_document(self, fragment): BUILDSTDERR: """See `TreeBuilRefactoringTool: No changes to ./bs4/tests/test_htmlparser.py BUILDSTDERR: """See `TreeBuilRefactoringTool: No changes to ./bs4/tests/test_htmlparser.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/tests/test_lxml.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/tests/test_lxml.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/tests/test_soup.py BUILDSTDERR: RefactoringTool: Refactored ./bs4/tests/test_soup.py der`.""" der`.""" - return u'\n%s' % fragment - return u'\n%s' % fragment + return '\n%s' % fragment + return '\n%s' % fragment class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML): class LXMLTreeBuilder(HTMLTreeBuilder, LXMLTreeBuilderForXML): @@ -286,10 +286,10 @@ @@ -286,10 +286,10 @@ self.parser = self.parser_for(encoding) self.parser = self.parser_for(encoding) self.parser.feed(markup) self.parser.feed(markup) self.parser.close() self.parser.close() - except (UnicodeDecodeError, LookupError, etree.ParserError), e: - except (UnicodeDecodeError, LookupError, etree.ParserError), e: + except (UnicodeDecodeError, LookupError, etree.ParserError) as e: + except (UnicodeDecodeError, LookupError, etree.ParserError) as e: raise ParserRejectedMarkup(str(e)) raise ParserRejectedMarkup(str(e)) def test_fragment_to_document(self, fragment): def test_fragment_to_document(self, fragment): """See `TreeBuilder`.""" """See `TreeBuilder`.""" - return u'%s' % fragment - return u'%s' % fragment + return '%s' % fragment + return '%s' % fragment --- ./bs4/tests/test_html5lib.py (original) --- ./bs4/tests/test_html5lib.py (original) +++ ./bs4/tests/test_html5lib.py (refactored) +++ ./bs4/tests/test_html5lib.py (refactored) @@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@ try: try: from bs4.builder import HTML5TreeBuilder from bs4.builder import HTML5TreeBuilder HTML5LIB_PRESENT = True HTML5LIB_PRESENT = True -except ImportError, e: -except ImportError, e: +except ImportError as e: +except ImportError as e: HTML5LIB_PRESENT = False HTML5LIB_PRESENT = False from bs4.element import SoupStrainer from bs4.element import SoupStrainer from bs4.testing import ( from bs4.testing import ( @@ -74,14 +74,14 @@ @@ -74,14 +74,14 @@ def test_reparented_markup(self): def test_reparented_markup(self): markup = '

foo

\n

bar

' markup = '

foo

\n

bar

' soup = self.soup(markup) soup = self.soup(markup) - self.assertEqual(u"

foo

\n

bar

", soup.body.decode()) - self.assertEqual(u"

foo

\n

bar

", soup.body.decode()) + self.assertEqual("

foo

\n

bar

", soup.body.decode()) + self.assertEqual("

foo

\n

bar

", soup.body.decode()) self.assertEqual(2, len(soup.find_all('p'))) self.assertEqual(2, len(soup.find_all('p'))) def test_reparented_markup_ends_with_whitespace(self): def test_reparented_markup_ends_with_whitespace(self): markup = '

foo

\n

bar

\n' markup = '

foo

\n

bar

\n' soup = self.soup(markup) soup = self.soup(markup) - self.assertEqual(u"

foo

\n

bar

\n", soup.body.decode()) - self.assertEqual(u"

foo

\n

bar

\n", soup.body.decode()) + self.assertEqual("

foo

\n

bar

\n", soup.body.decode()) + self.assertEqual("

foo

\n

bar

\n", soup.body.decode()) self.assertEqual(2, len(soup.find_all('p'))) self.assertEqual(2, len(soup.find_all('p'))) def test_reparented_markup_containing_identical_whitespace_nodes(self): def test_reparented_markup_containing_identical_whitespace_nodes(self): @@ -127,7 +127,7 @@ @@ -127,7 +127,7 @@ def test_foster_parenting(self): def test_foster_parenting(self): markup = b"""A""" markup = b"""
A""" soup = self.soup(markup) soup = self.soup(markup) - self.assertEqual(u"A
", soup.body.decode()) - self.assertEqual(u"A
", soup.body.decode()) + self.assertEqual("A
", soup.body.decode()) + self.assertEqual("A
", soup.body.decode()) def test_extraction(self): def test_extraction(self): """ """ --- ./bs4/tests/test_lxml.py (original) --- ./bs4/tests/test_lxml.py (original) +++ ./bs4/tests/test_lxml.py (refactored) +++ ./bs4/tests/test_lxml.py (refactored) @@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@ import lxml.etree import lxml.etree LXML_PRESENT = True LXML_PRESENT = True LXML_VERSION = lxml.etree.LXML_VERSION LXML_VERSION = lxml.etree.LXML_VERSION -except ImportError, e: -except ImportError, e: +except ImportError as e: +except ImportError as e: LXML_PRESENT = False LXML_PRESENT = False LXML_VERSION = (0,) LXML_VERSION = (0,) @@ -68,7 +68,7 @@ @@ -68,7 +68,7 @@ # if one is installed. # if one is installed. with warnings.catch_warnings(record=True) as w: with warnings.catch_warnings(record=True) as w: soup = BeautifulStoneSoup("") soup = BeautifulStoneSoup("") - self.assertEqual(u"", unicode(soup.b)) - self.assertEqual(u"", unicode(soup.b)) + self.assertEqual("", str(soup.b)) + self.assertEqual("", str(soup.b)) self.assertTrue("BeautifulStoneSoup class is deprecated" in str(w[0].message)) self.assertTrue("BeautifulStoneSoup class is deprecated" in str(w[0].message)) @skipIf( @skipIf( --- ./bs4/tests/test_soup.py (original) --- ./bs4/tests/test_soup.py (original) +++ ./bs4/tests/test_soup.py (refactored) +++ ./bs4/tests/test_soup.py (refactored) @@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@ try: try: from bs4.builder import LXMLTreeBuilder, LXMLTreeBuilderForXML from bs4.builder import LXMLTreeBuilder, LXMLTreeBuilderForXML LXML_PRESENT = True LXML_PRESENT = True -except ImportError, e: -except ImportError, e: +except ImportError as e: +except ImportError as e: LXML_PRESENT = False LXML_PRESENT = False PYTHON_3_PRE_3_2 = (sys.version_info[0] == 3 and sys.version_info < (3,2)) PYTHON_3_PRE_3_2 = (sys.version_info[0] == 3 and sys.version_info < (3,2)) @@ -40,17 +40,17 @@ @@ -40,17 +40,17 @@ class TestConstructor(SoupTest): class TestConstructor(SoupTest): def test_short_unicode_input(self): def test_short_unicode_input(self): - data = u"

éé

" - data = u"

éé

" + data = "

éé

" + data = "

éé

" soup = self.soup(data) soup = self.soup(data) - self.assertEqual(u"éé", soup.h1.string) - self.assertEqual(u"éé", soup.h1.string) + self.assertEqual("éé", soup.h1.string) + self.assertEqual("éé", soup.h1.string) def test_embedded_null(self): def test_embedded_null(self): - data = u"

foo\0bar

" - data = u"

foo\0bar

" + data = "

foo\0bar

" + data = "

foo\0bar

" soup = self.soup(data) soup = self.soup(data) - self.assertEqual(u"foo\0bar", soup.h1.string) - self.assertEqual(u"foo\0bar", soup.h1.string) + self.assertEqual("foo\0bar", soup.h1.string) + self.assertEqual("foo\0bar", soup.h1.string) def test_exclude_encodings(self): def test_exclude_encodings(self): - utf8_data = u"Räksmörgås".encode("utf-8") - utf8_data = u"Räksmörgås".encode("utf-8") + utf8_data = "Räksmörgås".encode("utf-8") + utf8_data = "Räksmörgås".encode("utf-8") soup = self.soup(utf8_data, exclude_encodings=["utf-8"]) soup = self.soup(utf8_data, exclude_encodings=["utf-8"]) self.assertEqual("windows-1252", soup.original_encoding) self.assertEqual("windows-1252", soup.original_encoding) @@ -129,7 +129,7 @@ @@ -129,7 +129,7 @@ with warnings.catch_warnings(record=True) as warning_list: with warnings.catch_warnings(record=True) as warning_list: # note - this url must differ from the bytes one otherwise # note - this url must differ from the bytes one otherwise # python's warnings system swallows the second warning # python's warnings system swallows the second warning - soup = self.soup(u"http://www.crummyunicode.com/") - soup = self.soup(u"http://www.crummyunicode.com/") + soup = self.soup("http://www.crummyunicode.com/") + soup = self.soup("http://www.crummyunicode.com/") self.assertTrue(any("looks like a URL" in str(w.message) self.assertTrue(any("looks like a URL" in str(w.message) for w in warning_list)) for w in warning_list)) @@ -141,7 +141,7 @@ @@ -141,7 +141,7 @@ def test_url_warning_with_unicode_and_space(self): def test_url_warning_with_unicode_and_space(self): with warnings.catch_warnings(record=True) as warning_list: with warnings.catch_warnings(record=True) as warning_list: - soup = self.soup(u"http://www.crummyuncode.com/ is great") - soup = self.soup(u"http://www.crummyuncode.com/ is great") + soup = self.soup("http://www.crummyuncode.com/ is great") + soup = self.soup("http://www.crummyuncode.com/ is great") self.assertFalse(any("looks like a URL" in str(w.message) self.assertFalse(any("looks like a URL" in str(w.message) for w in warning_list)) for w in warning_list)) @@ -163,9 +163,9 @@ @@ -163,9 +163,9 @@ def test_simple_html_substitution(self): def test_simple_html_substitution(self): # Unicode characters corresponding to named HTML entites # Unicode characters corresponding to named HTML entites # are substituted, and no others. # are substituted, and no others. - s = u"foo\u2200\N{SNOWMAN}\u00f5bar" - s = u"foo\u2200\N{SNOWMAN}\u00f5bar" + s = "foo\u2200\N{SNOWMAN}\u00f5bar" + s = "foo\u2200\N{SNOWMAN}\u00f5bar" self.assertEqual(self.sub.substitute_html(s), self.assertEqual(self.sub.substitute_html(s), - u"foo∀\N{SNOWMAN}õbar") - u"foo∀\N{SNOWMAN}õbar") + "foo∀\N{SNOWMAN}õbar") + "foo∀\N{SNOWMAN}õbar") def test_smart_quote_substitution(self): def test_smart_quote_substitution(self): # MS smart quotes are a common source of frustration, so we # MS smart quotes are a common source of frustration, so we @@ -230,7 +230,7 @@ @@ -230,7 +230,7 @@ def setUp(self): def setUp(self): super(TestEncodingConversion, self).setUp() super(TestEncodingConversion, self).setUp() - self.unicode_data = u'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' - self.unicode_data = u'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' + self.unicode_data = 'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' + self.unicode_data = 'Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!' self.utf8_data = self.unicode_data.encode("utf-8") self.utf8_data = self.unicode_data.encode("utf-8") # Just so you know what it looks like. # Just so you know what it looks like. self.assertEqual( self.assertEqual( @@ -250,7 +250,7 @@ @@ -250,7 +250,7 @@ ascii = b"a" ascii = b"a" soup_from_ascii = self.soup(ascii) soup_from_ascii = self.soup(ascii) unicode_output = soup_from_ascii.decode() unicode_output = soup_from_ascii.decode() - self.assertTrue(isinstance(unicode_output, unicode)) - self.assertTrue(isinstance(unicode_output, unicode)) + self.assertTrue(isinstance(unicode_output, str)) + self.assertTrue(isinstance(unicode_output, str)) self.assertEqual(unicode_output, self.document_for(ascii.decode())) self.assertEqual(unicode_output, self.document_for(ascii.decode())) self.assertEqual(soup_from_ascii.original_encoding.lower(), "utf-8") self.assertEqual(soup_from_ascii.original_encoding.lower(), "utf-8") finally: finally: @@ -262,7 +262,7 @@ @@ -262,7 +262,7 @@ # is not set. # is not set. soup_from_unicode = self.soup(self.unicode_data) soup_from_unicode = self.soup(self.unicode_data) self.assertEqual(soup_from_unicode.decode(), self.unicode_data) self.assertEqual(soup_from_unicode.decode(), self.unicode_data) - self.assertEqual(soup_from_unicode.foo.string, u'Sacr\xe9 bleu!') - self.assertEqual(soup_from_unicode.foo.string, u'Sacr\xe9 bleu!') + self.assertEqual(soup_from_unicode.foo.string, 'Sacr\xe9 bleu!') + self.assertEqual(soup_from_unicode.foo.string, 'Sacr\xe9 bleu!') self.assertEqual(soup_from_unicode.original_encoding, None) self.assertEqual(soup_from_unicode.original_encoding, None) def test_utf8_in_unicode_out(self): def test_utf8_in_unicode_out(self): @@ -270,7 +270,7 @@ @@ -270,7 +270,7 @@ # attribute is set. # attribute is set. soup_from_utf8 = self.soup(self.utf8_data) soup_from_utf8 = self.soup(self.utf8_data) self.assertEqual(soup_from_utf8.decode(), self.unicode_data) self.assertEqual(soup_from_utf8.decode(), self.unicode_data) - self.assertEqual(soup_from_utf8.foo.string, u'Sacr\xe9 bleu!') - self.assertEqual(soup_from_utf8.foo.string, u'Sacr\xe9 bleu!') + self.assertEqual(soup_from_utf8.foo.string, 'Sacr\xe9 bleu!') + self.assertEqual(soup_from_utf8.foo.string, 'Sacr\xe9 bleu!') def test_utf8_out(self): def test_utf8_out(self): # The internal data structures can be encoded as UTF-8. # The internal data structures can be encoded as UTF-8. @@ -281,14 +281,14 @@ @@ -281,14 +281,14 @@ PYTHON_3_PRE_3_2, PYTHON_3_PRE_3_2, "Bad HTMLParser detected; skipping test of non-ASCII characters in attribute name.") "Bad HTMLParser detected; skipping test of non-ASCII characters in attribute name.") def test_attribute_name_containing_unicode_characters(self): def test_attribute_name_containing_unicode_characters(self): - markup = u'
' - markup = u'
' + markup = '
' + markup = '
' self.assertEqual(self.soup(markup).div.encode("utf8"), markup.encode("utf8")) self.assertEqual(self.soup(markup).div.encode("utf8"), markup.encode("utf8")) class TestUnicodeDammit(unittest.TestCase): class TestUnicodeDammit(unittest.TestCase): """Standalone tests of UnicodeDammit.""" """Standalone tests of UnicodeDammit.""" def test_unicode_input(self): def test_unicode_input(self): BUILDSTDERR: - markup = u"I'm already Unicode! \N{SNOWMARefactoringTool: Refactored ./bs4/tests/test_tree.py BUILDSTDERR: - markup = u"I'm already Unicode! \N{SNOWMARefactoringTool: Refactored ./bs4/tests/test_tree.py N}" N}" + markup = "I'm already Unicode! \N{SNOWMAN}" + markup = "I'm already Unicode! \N{SNOWMAN}" dammit = UnicodeDammit(markup) dammit = UnicodeDammit(markup) self.assertEqual(dammit.unicode_markup, markup) self.assertEqual(dammit.unicode_markup, markup) @@ -296,7 +296,7 @@ @@ -296,7 +296,7 @@ markup = b"\x91\x92\x93\x94" markup = b"\x91\x92\x93\x94" dammit = UnicodeDammit(markup) dammit = UnicodeDammit(markup) self.assertEqual( self.assertEqual( - dammit.unicode_markup, u"\u2018\u2019\u201c\u201d") - dammit.unicode_markup, u"\u2018\u2019\u201c\u201d") + dammit.unicode_markup, "\u2018\u2019\u201c\u201d") + dammit.unicode_markup, "\u2018\u2019\u201c\u201d") def test_smart_quotes_to_xml_entities(self): def test_smart_quotes_to_xml_entities(self): markup = b"\x91\x92\x93\x94" markup = b"\x91\x92\x93\x94" @@ -320,14 +320,14 @@ @@ -320,14 +320,14 @@ utf8 = b"Sacr\xc3\xa9 bleu! \xe2\x98\x83" utf8 = b"Sacr\xc3\xa9 bleu! \xe2\x98\x83" dammit = UnicodeDammit(utf8) dammit = UnicodeDammit(utf8) self.assertEqual(dammit.original_encoding.lower(), 'utf-8') self.assertEqual(dammit.original_encoding.lower(), 'utf-8') - self.assertEqual(dammit.unicode_markup, u'Sacr\xe9 bleu! \N{SNOWMAN}') - self.assertEqual(dammit.unicode_markup, u'Sacr\xe9 bleu! \N{SNOWMAN}') + self.assertEqual(dammit.unicode_markup, 'Sacr\xe9 bleu! \N{SNOWMAN}') + self.assertEqual(dammit.unicode_markup, 'Sacr\xe9 bleu! \N{SNOWMAN}') def test_convert_hebrew(self): def test_convert_hebrew(self): hebrew = b"\xed\xe5\xec\xf9" hebrew = b"\xed\xe5\xec\xf9" dammit = UnicodeDammit(hebrew, ["iso-8859-8"]) dammit = UnicodeDammit(hebrew, ["iso-8859-8"]) self.assertEqual(dammit.original_encoding.lower(), 'iso-8859-8') self.assertEqual(dammit.original_encoding.lower(), 'iso-8859-8') - self.assertEqual(dammit.unicode_markup, u'\u05dd\u05d5\u05dc\u05e9') - self.assertEqual(dammit.unicode_markup, u'\u05dd\u05d5\u05dc\u05e9') + self.assertEqual(dammit.unicode_markup, '\u05dd\u05d5\u05dc\u05e9') + self.assertEqual(dammit.unicode_markup, '\u05dd\u05d5\u05dc\u05e9') def test_dont_see_smart_quotes_where_there_are_none(self): def test_dont_see_smart_quotes_where_there_are_none(self): utf_8 = b"\343\202\261\343\203\274\343\202\277\343\202\244 Watch" utf_8 = b"\343\202\261\343\203\274\343\202\277\343\202\244 Watch" @@ -336,19 +336,19 @@ @@ -336,19 +336,19 @@ self.assertEqual(dammit.unicode_markup.encode("utf-8"), utf_8) self.assertEqual(dammit.unicode_markup.encode("utf-8"), utf_8) def test_ignore_inappropriate_codecs(self): def test_ignore_inappropriate_codecs(self): - utf8_data = u"Räksmörgås".encode("utf-8") - utf8_data = u"Räksmörgås".encode("utf-8") + utf8_data = "Räksmörgås".encode("utf-8") + utf8_data = "Räksmörgås".encode("utf-8") dammit = UnicodeDammit(utf8_data, ["iso-8859-8"]) dammit = UnicodeDammit(utf8_data, ["iso-8859-8"]) self.assertEqual(dammit.original_encoding.lower(), 'utf-8') self.assertEqual(dammit.original_encoding.lower(), 'utf-8') def test_ignore_invalid_codecs(self): def test_ignore_invalid_codecs(self): - utf8_data = u"Räksmörgås".encode("utf-8") - utf8_data = u"Räksmörgås".encode("utf-8") + utf8_data = "Räksmörgås".encode("utf-8") + utf8_data = "Räksmörgås".encode("utf-8") for bad_encoding in ['.utf8', '...', 'utF---16.!']: for bad_encoding in ['.utf8', '...', 'utF---16.!']: dammit = UnicodeDammit(utf8_data, [bad_encoding]) dammit = UnicodeDammit(utf8_data, [bad_encoding]) self.assertEqual(dammit.original_encoding.lower(), 'utf-8') self.assertEqual(dammit.original_encoding.lower(), 'utf-8') def test_exclude_encodings(self): def test_exclude_encodings(self): # This is UTF-8. # This is UTF-8. - utf8_data = u"Räksmörgås".encode("utf-8") - utf8_data = u"Räksmörgås".encode("utf-8") + utf8_data = "Räksmörgås".encode("utf-8") + utf8_data = "Räksmörgås".encode("utf-8") # But if we exclude UTF-8 from consideration, the guess is # But if we exclude UTF-8 from consideration, the guess is # Windows-1252. # Windows-1252. @@ -364,7 +364,7 @@ @@ -364,7 +364,7 @@ detected = EncodingDetector( detected = EncodingDetector( b'') b'') encodings = list(detected.encodings) encodings = list(detected.encodings) - assert u'utf-\N{REPLACEMENT CHARACTER}' in encodings - assert u'utf-\N{REPLACEMENT CHARACTER}' in encodings + assert 'utf-\N{REPLACEMENT CHARACTER}' in encodings + assert 'utf-\N{REPLACEMENT CHARACTER}' in encodings def test_detect_html5_style_meta_tag(self): def test_detect_html5_style_meta_tag(self): @@ -404,7 +404,7 @@ @@ -404,7 +404,7 @@ bs4.dammit.chardet_dammit = noop bs4.dammit.chardet_dammit = noop dammit = UnicodeDammit(doc) dammit = UnicodeDammit(doc) self.assertEqual(True, dammit.contains_replacement_characters) self.assertEqual(True, dammit.contains_replacement_characters) - self.assertTrue(u"\ufffd" in dammit.unicode_markup) - self.assertTrue(u"\ufffd" in dammit.unicode_markup) + self.assertTrue("\ufffd" in dammit.unicode_markup) + self.assertTrue("\ufffd" in dammit.unicode_markup) soup = BeautifulSoup(doc, "html.parser") soup = BeautifulSoup(doc, "html.parser") self.assertTrue(soup.contains_replacement_characters) self.assertTrue(soup.contains_replacement_characters) @@ -416,17 +416,17 @@ @@ -416,17 +416,17 @@ # A document written in UTF-16LE will have its byte order marker stripped. # A document written in UTF-16LE will have its byte order marker stripped. data = b'\xff\xfe<\x00a\x00>\x00\xe1\x00\xe9\x00<\x00/\x00a\x00>\x00' data = b'\xff\xfe<\x00a\x00>\x00\xe1\x00\xe9\x00<\x00/\x00a\x00>\x00' dammit = UnicodeDammit(data) dammit = UnicodeDammit(data) - self.assertEqual(u"áé", dammit.unicode_markup) - self.assertEqual(u"áé", dammit.unicode_markup) + self.assertEqual("áé", dammit.unicode_markup) + self.assertEqual("áé", dammit.unicode_markup) self.assertEqual("utf-16le", dammit.original_encoding) self.assertEqual("utf-16le", dammit.original_encoding) def test_detwingle(self): def test_detwingle(self): # Here's a UTF8 document. # Here's a UTF8 document. - utf8 = (u"\N{SNOWMAN}" * 3).encode("utf8") - utf8 = (u"\N{SNOWMAN}" * 3).encode("utf8") + utf8 = ("\N{SNOWMAN}" * 3).encode("utf8") + utf8 = ("\N{SNOWMAN}" * 3).encode("utf8") # Here's a Windows-1252 document. # Here's a Windows-1252 document. windows_1252 = ( windows_1252 = ( - u"\N{LEFT DOUBLE QUOTATION MARK}Hi, I like Windows!" - u"\N{LEFT DOUBLE QUOTATION MARK}Hi, I like Windows!" - u"\N{RIGHT DOUBLE QUOTATION MARK}").encode("windows_1252") - u"\N{RIGHT DOUBLE QUOTATION MARK}").encode("windows_1252") + "\N{LEFT DOUBLE QUOTATION MARK}Hi, I like Windows!" + "\N{LEFT DOUBLE QUOTATION MARK}Hi, I like Windows!" + "\N{RIGHT DOUBLE QUOTATION MARK}").encode("windows_1252") + "\N{RIGHT DOUBLE QUOTATION MARK}").encode("windows_1252") # Through some unholy alchemy, they've been stuck together. # Through some unholy alchemy, they've been stuck together. doc = utf8 + windows_1252 + utf8 doc = utf8 + windows_1252 + utf8 @@ -441,7 +441,7 @@ @@ -441,7 +441,7 @@ fixed = UnicodeDammit.detwingle(doc) fixed = UnicodeDammit.detwingle(doc) self.assertEqual( self.assertEqual( - u"☃☃☃“Hi, I like Windows!”☃☃☃", fixed.decode("utf8")) - u"☃☃☃“Hi, I like Windows!”☃☃☃", fixed.decode("utf8")) + "☃☃☃“Hi, I like Windows!”☃☃☃", fixed.decode("utf8")) + "☃☃☃“Hi, I like Windows!”☃☃☃", fixed.decode("utf8")) def test_detwingle_ignores_multibyte_characters(self): def test_detwingle_ignores_multibyte_characters(self): # Each of these characters has a UTF-8 representation ending # Each of these characters has a UTF-8 representation ending @@ -449,9 +449,9 @@ @@ -449,9 +449,9 @@ # Windows-1252. But our code knows to skip over multibyte # Windows-1252. But our code knows to skip over multibyte # UTF-8 characters, so they'll survive the process unscathed. # UTF-8 characters, so they'll survive the process unscathed. for tricky_unicode_char in ( for tricky_unicode_char in ( - u"\N{LATIN SMALL LIGATURE OE}", # 2-byte char '\xc5\x93' - u"\N{LATIN SMALL LIGATURE OE}", # 2-byte char '\xc5\x93' - u"\N{LATIN SUBSCRIPT SMALL LETTER X}", # 3-byte char '\xe2\x82\x93' - u"\N{LATIN SUBSCRIPT SMALL LETTER X}", # 3-byte char '\xe2\x82\x93' - u"\xf0\x90\x90\x93", # This is a CJK character, not sure which one. - u"\xf0\x90\x90\x93", # This is a CJK character, not sure which one. + "\N{LATIN SMALL LIGATURE OE}", # 2-byte char '\xc5\x93' + "\N{LATIN SMALL LIGATURE OE}", # 2-byte char '\xc5\x93' + "\N{LATIN SUBSCRIPT SMALL LETTER X}", # 3-byte char '\xe2\x82\x93' + "\N{LATIN SUBSCRIPT SMALL LETTER X}", # 3-byte char '\xe2\x82\x93' + "\xf0\x90\x90\x93", # This is a CJK character, not sure which one. + "\xf0\x90\x90\x93", # This is a CJK character, not sure which one. ): ): input = tricky_unicode_char.encode("utf8") input = tricky_unicode_char.encode("utf8") self.assertTrue(input.endswith(b'\x93')) self.assertTrue(input.endswith(b'\x93')) --- ./bs4/tests/test_tree.py (original) --- ./bs4/tests/test_tree.py (original) +++ ./bs4/tests/test_tree.py (refactored) +++ ./bs4/tests/test_tree.py (refactored) @@ -70,13 +70,13 @@ @@ -70,13 +70,13 @@ self.assertEqual(soup.find("b").string, "2") self.assertEqual(soup.find("b").string, "2") def test_unicode_text_find(self): def test_unicode_text_find(self): - soup = self.soup(u'

Räksmörgås

') - soup = self.soup(u'

Räksmörgås

') - self.assertEqual(soup.find(string=u'Räksmörgås'), u'Räksmörgås') - self.assertEqual(soup.find(string=u'Räksmörgås'), u'Räksmörgås') + soup = self.soup('

Räksmörgås

') + soup = self.soup('

Räksmörgås

') + self.assertEqual(soup.find(string='Räksmörgås'), 'Räksmörgås') + self.assertEqual(soup.find(string='Räksmörgås'), 'Räksmörgås') def test_unicode_attribute_find(self): def test_unicode_attribute_find(self): - soup = self.soup(u'

here it is

') - soup = self.soup(u'

here it is

') + soup = self.soup('

here it is

') + soup = self.soup('

here it is

') str(soup) str(soup) - self.assertEqual("here it is", soup.find(id=u'Räksmörgås').text) - self.assertEqual("here it is", soup.find(id=u'Räksmörgås').text) + self.assertEqual("here it is", soup.find(id='Räksmörgås').text) + self.assertEqual("here it is", soup.find(id='Räksmörgås').text) def test_find_everything(self): def test_find_everything(self): @@ -96,17 +96,17 @@ @@ -96,17 +96,17 @@ """You can search the tree for text nodes.""" """You can search the tree for text nodes.""" soup = self.soup("Foobar\xbb") soup = self.soup("Foobar\xbb") # Exact match. # Exact match. - self.assertEqual(soup.find_all(string="bar"), [u"bar"]) - self.assertEqual(soup.find_all(string="bar"), [u"bar"]) - self.assertEqual(soup.find_all(text="bar"), [u"bar"]) - self.assertEqual(soup.find_all(text="bar"), [u"bar"]) + self.assertEqual(soup.find_all(string="bar"), ["bar"]) + self.assertEqual(soup.find_all(string="bar"), ["bar"]) + self.assertEqual(soup.find_all(text="bar"), ["bar"]) + self.assertEqual(soup.find_all(text="bar"), ["bar"]) # Match any of a number of strings. # Match any of a number of strings. self.assertEqual( self.assertEqual( - soup.find_all(text=["Foo", "bar"]), [u"Foo", u"bar"]) - soup.find_all(text=["Foo", "bar"]), [u"Foo", u"bar"]) + soup.find_all(text=["Foo", "bar"]), ["Foo", "bar"]) + soup.find_all(text=["Foo", "bar"]), ["Foo", "bar"]) # Match a regular expression. # Match a regular expression. self.assertEqual(soup.find_all(text=re.compile('.*')), self.assertEqual(soup.find_all(text=re.compile('.*')), - [u"Foo", u"bar", u'\xbb']) - [u"Foo", u"bar", u'\xbb']) + ["Foo", "bar", '\xbb']) + ["Foo", "bar", '\xbb']) # Match anything. # Match anything. self.assertEqual(soup.find_all(text=True), self.assertEqual(soup.find_all(text=True), - [u"Foo", u"bar", u'\xbb']) - [u"Foo", u"bar", u'\xbb']) + ["Foo", "bar", '\xbb']) + ["Foo", "bar", '\xbb']) def test_find_all_limit(self): def test_find_all_limit(self): """You can limit the number of items returned by find_all.""" """You can limit the number of items returned by find_all.""" @@ -249,8 +249,8 @@ @@ -249,8 +249,8 @@ ["Matching a.", "Matching b."]) ["Matching a.", "Matching b."]) def test_find_all_by_utf8_attribute_value(self): def test_find_all_by_utf8_attribute_value(self): - peace = u"םולש".encode("utf8") - peace = u"םולש".encode("utf8") - data = u''.encode("utf8") - data = u''.encode("utf8") + peace = "םולש".encode("utf8") + peace = "םולש".encode("utf8") + data = ''.encode("utf8") + data = ''.encode("utf8") soup = self.soup(data) soup = self.soup(data) self.assertEqual([soup.a], soup.find_all(title=peace)) self.assertEqual([soup.a], soup.find_all(title=peace)) self.assertEqual([soup.a], soup.find_all(title=peace.decode("utf8"))) self.assertEqual([soup.a], soup.find_all(title=peace.decode("utf8"))) @@ -834,10 +834,10 @@ @@ -834,10 +834,10 @@ assert not isinstance(i, BeautifulSoup) assert not isinstance(i, BeautifulSoup) p1, p2, p3, p4 = list(soup.children) p1, p2, p3, p4 = list(soup.children) - self.assertEquals("And now, a word:", p1.string) - self.assertEquals("And now, a word:", p1.string) - self.assertEquals("p2", p2.string) - self.assertEquals("p2", p2.string) - self.assertEquals("p3", p3.string) - self.assertEquals("p3", p3.string) - self.assertEquals("And we're back.", p4.string) - self.assertEquals("And we're back.", p4.string) + self.assertEqual("And now, a word:", p1.string) + self.assertEqual("And now, a word:", p1.string) + self.assertEqual("p2", p2.string) + self.assertEqual("p2", p2.string) + self.assertEqual("p3", p3.string) + self.assertEqual("p3", p3.string) + self.assertEqual("And we're back.", p4.string) + self.assertEqual("And we're back.", p4.string) def test_replace_with_maintains_next_element_throughout(self): def test_replace_with_maintains_next_element_throughout(self): @@ -1182,7 +1182,7 @@ @@ -1182,7 +1182,7 @@ """) """) [soup.script.extract() for i in soup.find_all("script")] [soup.script.extract() for i in soup.find_all("script")] - self.assertEqual("\n\n\n", unicode(soup.body)) - self.assertEqual("\n\n\n", unicode(soup.body)) + self.assertEqual("\n\n\n", str(soup.body)) + self.assertEqual("\n\n\n", str(soup.body)) def test_extract_works_when_element_is_surrounded_by_identical_strings(self): def test_extract_works_when_element_is_surrounded_by_identical_strings(self): @@ -1420,19 +1420,19 @@ @@ -1420,19 +1420,19 @@ soup = BeautifulSoup(b'

 

', 'html.parser') soup = BeautifulSoup(b'

 

', 'html.parser') encoding = soup.original_encoding encoding = soup.original_encoding copy = soup.__copy__() copy = soup.__copy__() - self.assertEqual(u"

 

", unicode(copy)) - self.assertEqual(u"

 

", unicode(copy)) + self.assertEqual("

 

", str(copy)) + self.assertEqual("

 

", str(copy)) self.assertEqual(encoding, copy.original_encoding) self.assertEqual(encoding, copy.original_encoding) def test_unicode_pickle(self): def test_unicode_pickle(self): # A tree containing Unicode characters can be pickled. # A tree containing Unicode characters can be pickled. - html = u"\N{SNOWMAN}" - html = u"\N{SNOWMAN}" + html = "\N{SNOWMAN}" + html = "\N{SNOWMAN}" soup = self.soup(html) soup = self.soup(html) dumped = pickle.dumps(soup, pickle.HIGHEST_PROTOCOL) dumped = pickle.dumps(soup, pickle.HIGHEST_PROTOCOL) loaded = pickle.loads(dumped) loaded = pickle.loads(dumped) self.assertEqual(loaded.decode(), soup.decode()) self.assertEqual(loaded.decode(), soup.decode()) def test_copy_navigablestring_is_not_attached_to_tree(self): def test_copy_navigablestring_is_not_attached_to_tree(self): - html = u"FooBar" - html = u"FooBar" + html = "FooBar" + html = "FooBar" soup = self.soup(html) soup = self.soup(html) s1 = soup.find(string="Foo") s1 = soup.find(string="Foo") s2 = copy.copy(s1) s2 = copy.copy(s1) @@ -1444,7 +1444,7 @@ @@ -1444,7 +1444,7 @@ self.assertEqual(None, s2.previous_element) self.assertEqual(None, s2.previous_element) def test_copy_navigablestring_subclass_has_same_type(self): def test_copy_navigablestring_subclass_has_same_type(self): - html = u"" - html = u"" + html = "" + html = "" soup = self.soup(html) soup = self.soup(html) s1 = soup.string s1 = soup.string s2 = copy.copy(s1) s2 = copy.copy(s1) @@ -1452,19 +1452,19 @@ @@ -1452,19 +1452,19 @@ self.assertTrue(isinstance(s2, Comment)) self.assertTrue(isinstance(s2, Comment)) def test_copy_entire_soup(self): def test_copy_entire_soup(self): - html = u"
FooBar
end" - html = u"
FooBar
end" + html = "
FooBar
end" + html = "
FooBar
end" soup = self.soup(html) soup = self.soup(html) soup_copy = copy.copy(soup) soup_copy = copy.copy(soup) self.assertEqual(soup, soup_copy) self.assertEqual(soup, soup_copy) def test_copy_tag_copies_contents(self): def test_copy_tag_copies_contents(self): - html = u"
FooBar
end" - html = u"
FooBar
end" + html = "
FooBar
end" + html = "
FooBar
end" soup = self.soup(html) soup = self.soup(html) div = soup.div div = soup.div div_copy = copy.copy(div) div_copy = copy.copy(div) # The two tags look the same, and evaluate to equal. # The two tags look the same, and evaluate to equal. - self.assertEqual(unicode(div), unicode(div_copy)) - self.assertEqual(unicode(div), unicode(div_copy)) + self.assertEqual(str(div), str(div_copy)) + self.assertEqual(str(div), str(div_copy)) self.assertEqual(div, div_copy) self.assertEqual(div, div_copy) # But they're not the same object. # But they're not the same object. @@ -1480,17 +1480,17 @@ @@ -1480,17 +1480,17 @@ class TestSubstitutions(SoupTest): class TestSubstitutions(SoupTest): def test_default_formatter_is_minimal(self): def test_default_formatter_is_minimal(self): - markup = u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" - markup = u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" soup = self.soup(markup) soup = self.soup(markup) decoded = soup.decode(formatter="minimal") decoded = soup.decode(formatter="minimal") # The < is converted back into < but the e-with-acute is left alone. # The < is converted back into < but the e-with-acute is left alone. self.assertEqual( self.assertEqual( decoded, decoded, self.document_for( self.document_for( - u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>")) - u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>")) + "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>")) + "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>")) def test_formatter_html(self): def test_formatter_html(self): - markup = u"
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" - markup = u"
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" soup = self.soup(markup) soup = self.soup(markup) decoded = soup.decode(formatter="html") decoded = soup.decode(formatter="html") self.assertEqual( self.assertEqual( @@ -1498,7 +1498,7 @@ @@ -1498,7 +1498,7 @@ self.document_for("
<<Sacré bleu!>>")) self.document_for("
<<Sacré bleu!>>")) def test_formatter_html5(self): def test_formatter_html5(self): - markup = u"
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" - markup = u"
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "
<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" soup = self.soup(markup) soup = self.soup(markup) decoded = soup.decode(formatter="html5") decoded = soup.decode(formatter="html5") self.assertEqual( self.assertEqual( @@ -1506,49 +1506,49 @@ @@ -1506,49 +1506,49 @@ self.document_for("
<<Sacré bleu!>>")) self.document_for("
<<Sacré bleu!>>")) def test_formatter_minimal(self): def test_formatter_minimal(self): - markup = u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" - markup = u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" soup = self.soup(markup) soup = self.soup(markup) decoded = soup.decode(formatter="minimal") decoded = soup.decode(formatter="minimal") # The < is converted back into < but the e-with-acute is left alone. # The < is converted back into < but the e-with-acute is left alone. self.assertEqual( self.assertEqual( decoded, decoded, self.document_for( self.document_for( - u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>")) - u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>")) + "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>")) + "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>")) def test_formatter_null(self): def test_formatter_null(self): - markup = u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" - markup = u"<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" + markup = "<<Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!>>" soup = self.soup(markup) soup = self.soup(markup) decoded = soup.decode(formatter=None) decoded = soup.decode(formatter=None) # Neither the angle brackets nor the e-with-acute are converted. # Neither the angle brackets nor the e-with-acute are converted. # This is not valid HTML, but it's what the user wanted. # This is not valid HTML, but it's what the user wanted. self.assertEqual(decoded, self.assertEqual(decoded, - self.document_for(u"<>")) - self.document_for(u"<>")) + self.document_for("<>")) + self.document_for("<>")) def test_formatter_custom(self): def test_formatter_custom(self): - markup = u"<foo>bar
" - markup = u"<foo>bar
" + markup = "<foo>bar
" + markup = "<foo>bar
" soup = self.soup(markup) soup = self.soup(markup) decoded = soup.decode(formatter = lambda x: x.upper()) decoded = soup.decode(formatter = lambda x: x.upper()) # Instead of normal entity conversion code, the custom # Instead of normal entity conversion code, the custom # callable is called on every string. # callable is called on every string. self.assertEqual( self.assertEqual( decoded, decoded, - self.document_for(u"BAR
")) - self.document_for(u"BAR
")) + self.document_for("BAR
")) + self.document_for("BAR
")) def test_formatter_is_run_on_attribute_values(self): def test_formatter_is_run_on_attribute_values(self): - markup = u'e' - markup = u'e' + markup = 'e' + markup = 'e' soup = self.soup(markup) soup = self.soup(markup) a = soup.a a = soup.a - expect_minimal = u'e' - expect_minimal = u'e' + expect_minimal = 'e' + expect_minimal = 'e' self.assertEqual(expect_minimal, a.decode()) self.assertEqual(expect_minimal, a.decode()) self.assertEqual(expect_minimal, a.decode(formatter="minimal")) self.assertEqual(expect_minimal, a.decode(formatter="minimal")) - expect_html = u'e' - expect_html = u'e' + expect_html = 'e' + expect_html = 'e' self.assertEqual(expect_html, a.decode(formatter="html")) self.assertEqual(expect_html, a.decode(formatter="html")) self.assertEqual(markup, a.decode(formatter=None)) self.assertEqual(markup, a.decode(formatter=None)) - expect_upper = u'E' - expect_upper = u'E' + expect_upper = 'E' + expect_upper = 'E' self.assertEqual(expect_upper, a.decode(formatter=lambda x: x.upper())) self.assertEqual(expect_upper, a.decode(formatter=lambda x: x.upper())) def test_formatter_skips_script_tag_for_html_documents(self): def test_formatter_skips_script_tag_for_html_documents(self): @@ -1574,7 +1574,7 @@ @@ -1574,7 +1574,7 @@ # Everything outside the
 tag is reformatted, but everything
         # Everything outside the 
 tag is reformatted, but everything
         # inside is left alone.
         # inside is left alone.
         self.assertEqual(
         self.assertEqual(
-            u'
\n foo\n
  \tbar\n  \n  
\n baz\n
', - u'
\n foo\n
  \tbar\n  \n  
\n baz\n
', + '
\n foo\n
  \tbar\n  \n  
\n baz\n
', + '
\n foo\n
  \tbar\n  \n  
\n baz\n
', soup.div.prettify()) soup.div.prettify()) def test_prettify_accepts_formatter_function(self): def test_prettify_accepts_formatter_function(self): @@ -1584,14 +1584,14 @@ @@ -1584,14 +1584,14 @@ def test_prettify_outputs_unicode_by_default(self): def test_prettify_outputs_unicode_by_default(self): soup = self.soup("") soup = self.soup("") - self.assertEqual(unicode, type(soup.prettify())) - self.assertEqual(unicode, type(soup.prettify())) + self.assertEqual(str, type(soup.prettify())) + self.assertEqual(str, type(soup.prettify())) def test_prettify_can_encode_data(self): def test_prettify_can_encode_data(self): soup = self.soup("") soup = self.soup("") self.assertEqual(bytes, type(soup.prettify("utf-8"))) self.assertEqual(bytes, type(soup.prettify("utf-8"))) def test_html_entity_substitution_off_by_default(self): def test_html_entity_substitution_off_by_default(self): BUILDSTDERR: - markup = u"Sacr\N{LATIN SMALL LETRefactoringTool: Refactored ./doc/source/conf.py BUILDSTDERR: - markup = u"Sacr\N{LATIN SMALL LETRefactoringTool: Refactored ./doc/source/conf.py BUILDSTDERR: RefactoringTool: Refactored ./doc.zh/source/conf.py BUILDSTDERR: RefactoringTool: Refactored ./doc.zh/source/conf.py BUILDSTDERR: RefactoringTool: Refactored ./scripts/demonstrate_parser_differences.py BUILDSTDERR: RefactoringTool: Refactored ./scripts/demonstrate_parser_differences.py TER E WITH ACUTE} bleu!" TER E WITH ACUTE} bleu!" + markup = "Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!" + markup = "Sacr\N{LATIN SMALL LETTER E WITH ACUTE} bleu!" soup = self.soup(markup) soup = self.soup(markup) encoded = soup.b.encode("utf-8") encoded = soup.b.encode("utf-8") self.assertEqual(encoded, markup.encode('utf-8')) self.assertEqual(encoded, markup.encode('utf-8')) @@ -1635,48 +1635,48 @@ @@ -1635,48 +1635,48 @@ """Test the ability to encode objects into strings.""" """Test the ability to encode objects into strings.""" def test_unicode_string_can_be_encoded(self): def test_unicode_string_can_be_encoded(self): - html = u"\N{SNOWMAN}" - html = u"\N{SNOWMAN}" + html = "\N{SNOWMAN}" + html = "\N{SNOWMAN}" soup = self.soup(html) soup = self.soup(html) self.assertEqual(soup.b.string.encode("utf-8"), self.assertEqual(soup.b.string.encode("utf-8"), - u"\N{SNOWMAN}".encode("utf-8")) - u"\N{SNOWMAN}".encode("utf-8")) + "\N{SNOWMAN}".encode("utf-8")) + "\N{SNOWMAN}".encode("utf-8")) def test_tag_containing_unicode_string_can_be_encoded(self): def test_tag_containing_unicode_string_can_be_encoded(self): - html = u"\N{SNOWMAN}" - html = u"\N{SNOWMAN}" + html = "\N{SNOWMAN}" + html = "\N{SNOWMAN}" soup = self.soup(html) soup = self.soup(html) self.assertEqual( self.assertEqual( soup.b.encode("utf-8"), html.encode("utf-8")) soup.b.encode("utf-8"), html.encode("utf-8")) def test_encoding_substitutes_unrecognized_characters_by_default(self): def test_encoding_substitutes_unrecognized_characters_by_default(self): - html = u"\N{SNOWMAN}" - html = u"\N{SNOWMAN}" + html = "\N{SNOWMAN}" + html = "\N{SNOWMAN}" soup = self.soup(html) soup = self.soup(html) self.assertEqual(soup.b.encode("ascii"), b"") self.assertEqual(soup.b.encode("ascii"), b"") def test_encoding_can_be_made_strict(self): def test_encoding_can_be_made_strict(self): - html = u"\N{SNOWMAN}" - html = u"\N{SNOWMAN}" + html = "\N{SNOWMAN}" + html = "\N{SNOWMAN}" soup = self.soup(html) soup = self.soup(html) self.assertRaises( self.assertRaises( UnicodeEncodeError, soup.encode, "ascii", errors="strict") UnicodeEncodeError, soup.encode, "ascii", errors="strict") def test_decode_contents(self): def test_decode_contents(self): - html = u"\N{SNOWMAN}" - html = u"\N{SNOWMAN}" + html = "\N{SNOWMAN}" + html = "\N{SNOWMAN}" soup = self.soup(html) soup = self.soup(html) - self.assertEqual(u"\N{SNOWMAN}", soup.b.decode_contents()) - self.assertEqual(u"\N{SNOWMAN}", soup.b.decode_contents()) + self.assertEqual("\N{SNOWMAN}", soup.b.decode_contents()) + self.assertEqual("\N{SNOWMAN}", soup.b.decode_contents()) def test_encode_contents(self): def test_encode_contents(self): - html = u"\N{SNOWMAN}" - html = u"\N{SNOWMAN}" + html = "\N{SNOWMAN}" + html = "\N{SNOWMAN}" soup = self.soup(html) soup = self.soup(html) self.assertEqual( self.assertEqual( - u"\N{SNOWMAN}".encode("utf8"), soup.b.encode_contents( - u"\N{SNOWMAN}".encode("utf8"), soup.b.encode_contents( + "\N{SNOWMAN}".encode("utf8"), soup.b.encode_contents( + "\N{SNOWMAN}".encode("utf8"), soup.b.encode_contents( encoding="utf8")) encoding="utf8")) def test_deprecated_renderContents(self): def test_deprecated_renderContents(self): - html = u"\N{SNOWMAN}" - html = u"\N{SNOWMAN}" + html = "\N{SNOWMAN}" + html = "\N{SNOWMAN}" soup = self.soup(html) soup = self.soup(html) self.assertEqual( self.assertEqual( - u"\N{SNOWMAN}".encode("utf8"), soup.b.renderContents()) - u"\N{SNOWMAN}".encode("utf8"), soup.b.renderContents()) + "\N{SNOWMAN}".encode("utf8"), soup.b.renderContents()) + "\N{SNOWMAN}".encode("utf8"), soup.b.renderContents()) def test_repr(self): def test_repr(self): - html = u"\N{SNOWMAN}" - html = u"\N{SNOWMAN}" + html = "\N{SNOWMAN}" + html = "\N{SNOWMAN}" soup = self.soup(html) soup = self.soup(html) if PY3K: if PY3K: self.assertEqual(html, repr(soup)) self.assertEqual(html, repr(soup)) @@ -1799,7 +1799,7 @@ @@ -1799,7 +1799,7 @@ els = self.soup.select('title') els = self.soup.select('title') self.assertEqual(len(els), 1) self.assertEqual(len(els), 1) self.assertEqual(els[0].name, 'title') self.assertEqual(els[0].name, 'title') - self.assertEqual(els[0].contents, [u'The title']) - self.assertEqual(els[0].contents, [u'The title']) + self.assertEqual(els[0].contents, ['The title']) + self.assertEqual(els[0].contents, ['The title']) def test_one_tag_many(self): def test_one_tag_many(self): els = self.soup.select('div') els = self.soup.select('div') @@ -1845,7 +1845,7 @@ @@ -1845,7 +1845,7 @@ self.assertEqual(dashed[0]['id'], 'dash2') self.assertEqual(dashed[0]['id'], 'dash2') def test_dashed_tag_text(self): def test_dashed_tag_text(self): - self.assertEqual(self.soup.select('body > custom-dashed-tag')[0].text, u'Hello there.') - self.assertEqual(self.soup.select('body > custom-dashed-tag')[0].text, u'Hello there.') + self.assertEqual(self.soup.select('body > custom-dashed-tag')[0].text, 'Hello there.') + self.assertEqual(self.soup.select('body > custom-dashed-tag')[0].text, 'Hello there.') def test_select_dashed_matches_find_all(self): def test_select_dashed_matches_find_all(self): self.assertEqual(self.soup.select('custom-dashed-tag'), self.soup.find_all('custom-dashed-tag')) self.assertEqual(self.soup.select('custom-dashed-tag'), self.soup.find_all('custom-dashed-tag')) @@ -2031,12 +2031,12 @@ @@ -2031,12 +2031,12 @@ # Try to select first paragraph # Try to select first paragraph els = self.soup.select('div#inner p:nth-of-type(1)') els = self.soup.select('div#inner p:nth-of-type(1)') self.assertEqual(len(els), 1) self.assertEqual(len(els), 1) - self.assertEqual(els[0].string, u'Some text') - self.assertEqual(els[0].string, u'Some text') + self.assertEqual(els[0].string, 'Some text') + self.assertEqual(els[0].string, 'Some text') # Try to select third paragraph # Try to select third paragraph els = self.soup.select('div#inner p:nth-of-type(3)') els = self.soup.select('div#inner p:nth-of-type(3)') self.assertEqual(len(els), 1) self.assertEqual(len(els), 1) - self.assertEqual(els[0].string, u'Another') - self.assertEqual(els[0].string, u'Another') + self.assertEqual(els[0].string, 'Another') + self.assertEqual(els[0].string, 'Another') # Try to select (non-existent!) fourth paragraph # Try to select (non-existent!) fourth paragraph els = self.soup.select('div#inner p:nth-of-type(4)') els = self.soup.select('div#inner p:nth-of-type(4)') @@ -2049,7 +2049,7 @@ @@ -2049,7 +2049,7 @@ def test_nth_of_type_direct_descendant(self): def test_nth_of_type_direct_descendant(self): els = self.soup.select('div#inner > p:nth-of-type(1)') els = self.soup.select('div#inner > p:nth-of-type(1)') self.assertEqual(len(els), 1) self.assertEqual(len(els), 1) - self.assertEqual(els[0].string, u'Some text') - self.assertEqual(els[0].string, u'Some text') + self.assertEqual(els[0].string, 'Some text') + self.assertEqual(els[0].string, 'Some text') def test_id_child_selector_nth_of_type(self): def test_id_child_selector_nth_of_type(self): self.assertSelects('#inner > p:nth-of-type(2)', ['p1']) self.assertSelects('#inner > p:nth-of-type(2)', ['p1']) @@ -2130,7 +2130,7 @@ @@ -2130,7 +2130,7 @@ markup = '
' markup = '
' soup = BeautifulSoup(markup, 'html.parser') soup = BeautifulSoup(markup, 'html.parser') selected = soup.select(".c1, .c2") selected = soup.select(".c1, .c2") - self.assertEquals(3, len(selected)) - self.assertEquals(3, len(selected)) + self.assertEqual(3, len(selected)) + self.assertEqual(3, len(selected)) # Verify that find_all finds the same elements, though because # Verify that find_all finds the same elements, though because # of an implementation detail it finds them in a different # of an implementation detail it finds them in a different --- ./doc/source/conf.py (original) --- ./doc/source/conf.py (original) +++ ./doc/source/conf.py (refactored) +++ ./doc/source/conf.py (refactored) @@ -40,8 +40,8 @@ @@ -40,8 +40,8 @@ master_doc = 'index' master_doc = 'index' # General information about the project. # General information about the project. -project = u'Beautiful Soup' -project = u'Beautiful Soup' -copyright = u'2004-2015, Leonard Richardson' -copyright = u'2004-2015, Leonard Richardson' +project = 'Beautiful Soup' +project = 'Beautiful Soup' +copyright = '2004-2015, Leonard Richardson' +copyright = '2004-2015, Leonard Richardson' # The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the @@ -178,8 +178,8 @@ @@ -178,8 +178,8 @@ # Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ latex_documents = [ - ('index', 'BeautifulSoup.tex', u'Beautiful Soup Documentation', - ('index', 'BeautifulSoup.tex', u'Beautiful Soup Documentation', - u'Leonard Richardson', 'manual'), - u'Leonard Richardson', 'manual'), + ('index', 'BeautifulSoup.tex', 'Beautiful Soup Documentation', + ('index', 'BeautifulSoup.tex', 'Beautiful Soup Documentation', + 'Leonard Richardson', 'manual'), + 'Leonard Richardson', 'manual'), ] ] # The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of @@ -211,18 +211,18 @@ @@ -211,18 +211,18 @@ # One entry per manual page. List of tuples # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section). man_pages = [ man_pages = [ - ('index', 'beautifulsoup', u'Beautiful Soup Documentation', - ('index', 'beautifulsoup', u'Beautiful Soup Documentation', - [u'Leonard Richardson'], 1) - [u'Leonard Richardson'], 1) + ('index', 'beautifulsoup', 'Beautiful Soup Documentation', + ('index', 'beautifulsoup', 'Beautiful Soup Documentation', + ['Leonard Richardson'], 1) + ['Leonard Richardson'], 1) ] ] # -- Options for Epub output --------------------------------------------------- # -- Options for Epub output --------------------------------------------------- # Bibliographic Dublin Core info. # Bibliographic Dublin Core info. -epub_title = u'Beautiful Soup' -epub_title = u'Beautiful Soup' -epub_author = u'Leonard Richardson' -epub_author = u'Leonard Richardson' -epub_publisher = u'Leonard Richardson' -epub_publisher = u'Leonard Richardson' -epub_copyright = u'2012, Leonard Richardson' -epub_copyright = u'2012, Leonard Richardson' +epub_title = 'Beautiful Soup' +epub_title = 'Beautiful Soup' +epub_author = 'Leonard Richardson' +epub_author = 'Leonard Richardson' +epub_publisher = 'Leonard Richardson' +epub_publisher = 'Leonard Richardson' +epub_copyright = '2012, Leonard Richardson' +epub_copyright = '2012, Leonard Richardson' # The language of the text. It defaults to the language option # The language of the text. It defaults to the language option # or en if the language is not set. # or en if the language is not set. --- ./doc.zh/source/conf.py (original) --- ./doc.zh/source/conf.py (original) +++ ./doc.zh/source/conf.py (refactored) +++ ./doc.zh/source/conf.py (refactored) @@ -40,8 +40,8 @@ @@ -40,8 +40,8 @@ master_doc = 'index' master_doc = 'index' # General information about the project. # General information about the project. -project = u'Beautiful Soup' -project = u'Beautiful Soup' -copyright = u'2012, Leonard Richardson' -copyright = u'2012, Leonard Richardson' +project = 'Beautiful Soup' +project = 'Beautiful Soup' +copyright = '2012, Leonard Richardson' +copyright = '2012, Leonard Richardson' # The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the @@ -178,8 +178,8 @@ @@ -178,8 +178,8 @@ # Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ latex_documents = [ - ('index', 'BeautifulSoup.tex', u'Beautiful Soup Documentation', - ('index', 'BeautifulSoup.tex', u'Beautiful Soup Documentation', - u'Leonard Richardson', 'manual'), - u'Leonard Richardson', 'manual'), + ('index', 'BeautifulSoup.tex', 'Beautiful Soup Documentation', + ('index', 'BeautifulSoup.tex', 'Beautiful Soup Documentation', + 'Leonard Richardson', 'manual'), + 'Leonard Richardson', 'manual'), ] ] # The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of @@ -211,18 +211,18 @@ @@ -211,18 +211,18 @@ # One entry per manual page. List of tuples # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section). man_pages = [ man_pages = [ - ('index', 'beautifulsoup', u'Beautiful Soup Documentation', - ('index', 'beautifulsoup', u'Beautiful Soup Documentation', - [u'Leonard Richardson'], 1) - [u'Leonard Richardson'], 1) + ('index', 'beautifulsoup', 'Beautiful Soup Documentation', + ('index', 'beautifulsoup', 'Beautiful Soup Documentation', + ['Leonard Richardson'], 1) + ['Leonard Richardson'], 1) ] ] # -- Options for Epub output --------------------------------------------------- # -- Options for Epub output --------------------------------------------------- # Bibliographic Dublin Core info. # Bibliographic Dublin Core info. -epub_title = u'Beautiful Soup' -epub_title = u'Beautiful Soup' -epub_author = u'Leonard Richardson' -epub_author = u'Leonard Richardson' BUILDSTDERR: -epub_publisher = u'Leonard RicRefactoringTool: Files that were modified: BUILDSTDERR: -epub_publisher = u'Leonard RicRefactoringTool: Files that were modified: BUILDSTDERR: RefactoringTool: ./setup.py BUILDSTDERR: RefactoringTool: ./setup.py BUILDSTDERR: RefactoringTool: ./bs4/__init__.py BUILDSTDERR: RefactoringTool: ./bs4/__init__.py BUILDSTDERR: RefactoringTool: ./bs4/dammit.py BUILDSTDERR: RefactoringTool: ./bs4/dammit.py BUILDSTDERR: RefactoringTool: ./bs4/diagnose.py BUILDSTDERR: RefactoringTool: ./bs4/diagnose.py BUILDSTDERR: RefactoringTool: ./bs4/element.py BUILDSTDERR: RefactoringTool: ./bs4/element.py BUILDSTDERR: RefactoringTool: ./bs4/testing.py BUILDSTDERR: RefactoringTool: ./bs4/testing.py BUILDSTDERR: RefactoringTool: ./bs4/builder/__init__.py BUILDSTDERR: RefactoringTool: ./bs4/builder/__init__.py BUILDSTDERR: RefactoringTool: ./bs4/builder/_html5lib.py BUILDSTDERR: RefactoringTool: ./bs4/builder/_html5lib.py BUILDSTDERR: RefactoringTool: ./bs4/builder/_htmlparser.py BUILDSTDERR: RefactoringTool: ./bs4/builder/_htmlparser.py BUILDSTDERR: RefactoringTool: ./bs4/builder/_lxml.py BUILDSTDERR: RefactoringTool: ./bs4/builder/_lxml.py BUILDSTDERR: RefactoringTool: ./bs4/tests/__init__.py BUILDSTDERR: RefactoringTool: ./bs4/tests/__init__.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_builder_registry.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_builder_registry.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_docs.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_docs.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_html5lib.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_html5lib.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_htmlparser.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_htmlparser.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_lxml.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_lxml.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_soup.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_soup.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_tree.py BUILDSTDERR: RefactoringTool: ./bs4/tests/test_tree.py BUILDSTDERR: RefactoringTool: ./doc/source/conf.py BUILDSTDERR: RefactoringTool: ./doc/source/conf.py BUILDSTDERR: RefactoringTool: ./doc.zh/source/conf.py BUILDSTDERR: RefactoringTool: ./doc.zh/source/conf.py BUILDSTDERR: RefactoringTool: ./scripts/demonstrate_parser_differences.py BUILDSTDERR: RefactoringTool: ./scripts/demonstrate_parser_differences.py + CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' + CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' + /usr/bin/python3 setup.py build '--executable=/usr/bin/python3 -s' + /usr/bin/python3 setup.py build '--executable=/usr/bin/python3 -s' hardson' hardson' -epub_copyright = u'2012, Leonard Richardson' -epub_copyright = u'2012, Leonard Richardson' +epub_title = 'Beautiful Soup' +epub_title = 'Beautiful Soup' +epub_author = 'Leonard Richardson' +epub_author = 'Leonard Richardson' +epub_publisher = 'Leonard Richardson' +epub_publisher = 'Leonard Richardson' +epub_copyright = '2012, Leonard Richardson' +epub_copyright = '2012, Leonard Richardson' # The language of the text. It defaults to the language option # The language of the text. It defaults to the language option # or en if the language is not set. # or en if the language is not set. --- ./scripts/demonstrate_parser_differences.py (original) --- ./scripts/demonstrate_parser_differences.py (original) +++ ./scripts/demonstrate_parser_differences.py (refactored) +++ ./scripts/demonstrate_parser_differences.py (refactored) @@ -22,13 +22,13 @@ @@ -22,13 +22,13 @@ try: try: from bs4.builder import _lxml from bs4.builder import _lxml parsers.append('lxml') parsers.append('lxml') -except ImportError, e: -except ImportError, e: +except ImportError as e: +except ImportError as e: pass pass try: try: from bs4.builder import _html5lib from bs4.builder import _html5lib parsers.append('html5lib') parsers.append('html5lib') -except ImportError, e: -except ImportError, e: +except ImportError as e: +except ImportError as e: pass pass class Demonstration(object): class Demonstration(object): @@ -47,7 +47,7 @@ @@ -47,7 +47,7 @@ output = soup.div output = soup.div else: else: output = soup output = soup - except Exception, e: - except Exception, e: + except Exception as e: + except Exception as e: output = "[EXCEPTION] %s" % str(e) output = "[EXCEPTION] %s" % str(e) self.results[parser] = output self.results[parser] = output if previous_output is None: if previous_output is None: @@ -57,15 +57,15 @@ @@ -57,15 +57,15 @@ return uniform_results return uniform_results def dump(self): def dump(self): - print "%s: %s" % ("Markup".rjust(13), self.markup.encode("utf8")) - print "%s: %s" % ("Markup".rjust(13), self.markup.encode("utf8")) - for parser, output in self.results.items(): - for parser, output in self.results.items(): - print "%s: %s" % (parser.rjust(13), output.encode("utf8")) - print "%s: %s" % (parser.rjust(13), output.encode("utf8")) + print("%s: %s" % ("Markup".rjust(13), self.markup.encode("utf8"))) + print("%s: %s" % ("Markup".rjust(13), self.markup.encode("utf8"))) + for parser, output in list(self.results.items()): + for parser, output in list(self.results.items()): + print("%s: %s" % (parser.rjust(13), output.encode("utf8"))) + print("%s: %s" % (parser.rjust(13), output.encode("utf8"))) different_results = [] different_results = [] uniform_results = [] uniform_results = [] -print "= Testing the following parsers: %s =" % ", ".join(parsers) -print "= Testing the following parsers: %s =" % ", ".join(parsers) -print -print +print("= Testing the following parsers: %s =" % ", ".join(parsers)) +print("= Testing the following parsers: %s =" % ", ".join(parsers)) +print() +print() input_file = sys.stdin input_file = sys.stdin if sys.stdin.isatty(): if sys.stdin.isatty(): @@ -83,13 +83,13 @@ @@ -83,13 +83,13 @@ else: else: different_results.append(demo) different_results.append(demo) -print "== Markup that's handled the same in every parser ==" -print "== Markup that's handled the same in every parser ==" -print -print +print("== Markup that's handled the same in every parser ==") +print("== Markup that's handled the same in every parser ==") +print() +print() for demo in uniform_results: for demo in uniform_results: demo.dump() demo.dump() - print - print -print "== Markup that's not handled the same in every parser ==" -print "== Markup that's not handled the same in every parser ==" -print -print + print() + print() +print("== Markup that's not handled the same in every parser ==") +print("== Markup that's not handled the same in every parser ==") +print() +print() for demo in different_results: for demo in different_results: demo.dump() demo.dump() - print - print + print() + print() running build running build running build_py running build_py creating build creating build creating build/lib creating build/lib creating build/lib/bs4 creating build/lib/bs4 copying bs4/testing.py -> build/lib/bs4 copying bs4/testing.py -> build/lib/bs4 copying bs4/element.py -> build/lib/bs4 copying bs4/element.py -> build/lib/bs4 copying bs4/diagnose.py -> build/lib/bs4 copying bs4/diagnose.py -> build/lib/bs4 copying bs4/dammit.py -> build/lib/bs4 copying bs4/dammit.py -> build/lib/bs4 copying bs4/__init__.py -> build/lib/bs4 copying bs4/__init__.py -> build/lib/bs4 creating build/lib/bs4/tests creating build/lib/bs4/tests copying bs4/tests/test_tree.py -> build/lib/bs4/tests copying bs4/tests/test_tree.py -> build/lib/bs4/tests copying bs4/tests/test_soup.py -> build/lib/bs4/tests copying bs4/tests/test_soup.py -> build/lib/bs4/tests copying bs4/tests/test_lxml.py -> build/lib/bs4/tests copying bs4/tests/test_lxml.py -> build/lib/bs4/tests copying bs4/tests/test_htmlparser.py -> build/lib/bs4/tests copying bs4/tests/test_htmlparser.py -> build/lib/bs4/tests copying bs4/tests/test_html5lib.py -> build/lib/bs4/tests copying bs4/tests/test_html5lib.py -> build/lib/bs4/tests copying bs4/tests/test_docs.py -> build/lib/bs4/tests copying bs4/tests/test_docs.py -> build/lib/bs4/tests copying bs4/tests/test_builder_registry.py -> build/lib/bs4/tests copying bs4/tests/test_builder_registry.py -> build/lib/bs4/tests copying bs4/tests/__init__.py -> build/lib/bs4/tests copying bs4/tests/__init__.py -> build/lib/bs4/tests creating build/lib/bs4/builder creating build/lib/bs4/builder copying bs4/builder/_lxml.py -> build/lib/bs4/builder copying bs4/builder/_lxml.py -> build/lib/bs4/builder copying bs4/builder/_htmlparser.py -> build/lib/bs4/builder copying bs4/builder/_htmlparser.py -> build/lib/bs4/builder copying bs4/builder/_html5lib.py -> build/lib/bs4/builder copying bs4/builder/_html5lib.py -> build/lib/bs4/builder copying bs4/builder/__init__.py -> build/lib/bs4/builder copying bs4/builder/__init__.py -> build/lib/bs4/builder Fixing build/lib/bs4/testing.py build/lib/bs4/element.py build/lib/bs4/diagnose.py build/lib/bs4/dammit.py build/lib/bs4/__init__.py build/lib/bs4/tests/test_tree.py build/lib/bs4/tests/test_soup.py build/lib/bs4/tests/test_lxml.py build/lib/bs4/tests/test_htmlparser.py build/lib/bs4/tests/test_html5lib.py build/lib/bs4/tests/test_docs.py build/lib/bs4/tests/test_builder_registry.py build/lib/bs4/tests/__init__.py build/lib/bs4/builder/_lxml.py build/lib/bs4/builder/_htmlparser.py build/lib/bs4/builder/_html5lib.py build/lib/bs4/builder/__init__.py Fixing build/lib/bs4/testing.py build/lib/bs4/element.py build/lib/bs4/diagnose.py build/lib/bs4/dammit.py build/lib/bs4/__init__.py build/lib/bs4/tests/test_tree.py build/lib/bs4/tests/test_soup.py build/lib/bs4/tests/test_lxml.py build/lib/bs4/tests/test_htmlparser.py build/lib/bs4/tests/test_html5lib.py build/lib/bs4/tests/test_docs.py build/lib/bs4/tests/test_builder_registry.py build/lib/bs4/tests/__init__.py build/lib/bs4/builder/_lxml.py build/lib/bs4/builder/_htmlparser.py build/lib/bs4/builder/_html5lib.py build/lib/bs4/builder/__init__.py Skipping optional fixer: buffer Skipping optional fixer: buffer Skipping optional fixer: idioms Skipping optional fixer: idioms Skipping optional fixer: set_literal Skipping optional fixer: set_literal Skipping optional fixer: ws_comma Skipping optional fixer: ws_comma BUILDSTDERR: Fixing build/lib/bs4/testing.py build/lib/bs4/element.py build+ RPM_EC=0 BUILDSTDERR: Fixing build/lib/bs4/testing.py build/lib/bs4/element.py build+ RPM_EC=0 BUILDSTDERR: ++ jobs -p BUILDSTDERR: ++ jobs -p + exit 0 + exit 0 /lib/bs4/diagnose.py build/lib/bs4/dammit.py build/lib/bs4/__init__.py build/lib/bs4/tests/test_tree.py build/lib/bs4/tests/test_soup.py build/lib/bs4/tests/test_lxml.py build/lib/bs4/tests/test_htmlparser.py build/lib/bs4/tests/test_html5lib.py build/lib/bs4/tests/test_docs.py build/lib/bs4/tests/test_builder_registry.py build/lib/bs4/tests/__init__.py build/lib/bs4/builder/_lxml.py build/lib/bs4/builder/_htmlparser.py build/lib/bs4/builder/_html5lib.py build/lib/bs4/builder/__init__.py /lib/bs4/diagnose.py build/lib/bs4/dammit.py build/lib/bs4/__init__.py build/lib/bs4/tests/test_tree.py build/lib/bs4/tests/test_soup.py build/lib/bs4/tests/test_lxml.py build/lib/bs4/tests/test_htmlparser.py build/lib/bs4/tests/test_html5lib.py build/lib/bs4/tests/test_docs.py build/lib/bs4/tests/test_builder_registry.py build/lib/bs4/tests/__init__.py build/lib/bs4/builder/_lxml.py build/lib/bs4/builder/_htmlparser.py build/lib/bs4/builder/_html5lib.py build/lib/bs4/builder/__init__.py Skipping optional fixer: buffer Skipping optional fixer: buffer Skipping optional fixer: idioms Skipping optional fixer: idioms Skipping optional fixer: set_literal Skipping optional fixer: set_literal Skipping optional fixer: ws_comma Skipping optional fixer: ws_comma Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.Dvreaw Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.Dvreaw + umask 022 + umask 022 + cd /builddir/build/BUILD + cd /builddir/build/BUILD + '[' /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 '!=' / ']' + '[' /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 '!=' / ']' + rm -rf /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 + rm -rf /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 BUILDSTDERR: ++ dirname /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 BUILDSTDERR: ++ dirname /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 + mkdir -p /builddir/build/BUILDROOT + mkdir -p /builddir/build/BUILDROOT + mkdir /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 + mkdir /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 + cd beautifulsoup4-4.7.1 + cd beautifulsoup4-4.7.1 + CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' + CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' + /usr/bin/python2 setup.py install -O1 --skip-build --root /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 + /usr/bin/python2 setup.py install -O1 --skip-build --root /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 running install running install running install_lib running install_lib creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7 creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7 creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder copying build/lib/bs4/builder/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder copying build/lib/bs4/builder/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder copying build/lib/bs4/builder/_html5lib.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder copying build/lib/bs4/builder/_html5lib.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder copying build/lib/bs4/builder/_htmlparser.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder copying build/lib/bs4/builder/_htmlparser.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder copying build/lib/bs4/builder/_lxml.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder copying build/lib/bs4/builder/_lxml.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_builder_registry.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_builder_registry.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_docs.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_docs.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_html5lib.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_html5lib.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_htmlparser.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_htmlparser.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_lxml.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_lxml.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_soup.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_soup.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_tree.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_tree.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests copying build/lib/bs4/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 copying build/lib/bs4/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 copying build/lib/bs4/dammit.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 copying build/lib/bs4/dammit.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 copying build/lib/bs4/diagnose.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 copying build/lib/bs4/diagnose.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 copying build/lib/bs4/element.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 copying build/lib/bs4/element.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 copying build/lib/bs4/testing.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 copying build/lib/bs4/testing.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4 byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder/__init__.py to __init__.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder/__init__.py to __init__.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder/_html5lib.py to _html5lib.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder/_html5lib.py to _html5lib.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder/_htmlparser.py to _htmlparser.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder/_htmlparser.py to _htmlparser.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder/_lxml.py to _lxml.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/builder/_lxml.py to _lxml.pyc BUILDSTDERR: byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/__init_+ pushd /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 BUILDSTDERR: byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/__init_+ pushd /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 + CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' + CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld' + /usr/bin/python3 setup.py install -O1 --skip-build --root /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 + /usr/bin/python3 setup.py install -O1 --skip-build --root /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 _.py to __init__.pyc _.py to __init__.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_builder_registry.py to test_builder_registry.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_builder_registry.py to test_builder_registry.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_docs.py to test_docs.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_docs.py to test_docs.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_html5lib.py to test_html5lib.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_html5lib.py to test_html5lib.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_htmlparser.py to test_htmlparser.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_htmlparser.py to test_htmlparser.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_lxml.py to test_lxml.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_lxml.py to test_lxml.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_soup.py to test_soup.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_soup.py to test_soup.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_tree.py to test_tree.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/tests/test_tree.py to test_tree.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/__init__.py to __init__.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/__init__.py to __init__.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/dammit.py to dammit.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/dammit.py to dammit.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/diagnose.py to diagnose.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/diagnose.py to diagnose.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/element.py to element.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/element.py to element.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/testing.py to testing.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/bs4/testing.py to testing.pyc writing byte-compilation script '/tmp/tmpP9mMkV.py' writing byte-compilation script '/tmp/tmpP9mMkV.py' /usr/bin/python2 -O /tmp/tmpP9mMkV.py /usr/bin/python2 -O /tmp/tmpP9mMkV.py removing /tmp/tmpP9mMkV.py removing /tmp/tmpP9mMkV.py running install_egg_info running install_egg_info running egg_info running egg_info writing requirements to beautifulsoup4.egg-info/requires.txt writing requirements to beautifulsoup4.egg-info/requires.txt writing beautifulsoup4.egg-info/PKG-INFO writing beautifulsoup4.egg-info/PKG-INFO writing top-level names to beautifulsoup4.egg-info/top_level.txt writing top-level names to beautifulsoup4.egg-info/top_level.txt writing dependency_links to beautifulsoup4.egg-info/dependency_links.txt writing dependency_links to beautifulsoup4.egg-info/dependency_links.txt reading manifest file 'beautifulsoup4.egg-info/SOURCES.txt' reading manifest file 'beautifulsoup4.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' reading manifest template 'MANIFEST.in' writing manifest file 'beautifulsoup4.egg-info/SOURCES.txt' writing manifest file 'beautifulsoup4.egg-info/SOURCES.txt' Copying beautifulsoup4.egg-info to /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/beautifulsoup4-4.7.1-py2.7.egg-info Copying beautifulsoup4.egg-info to /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7/site-packages/beautifulsoup4-4.7.1-py2.7.egg-info running install_scripts running install_scripts ~/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 ~/build/BUILD/beautifulsoup4-4.7.1 ~/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 ~/build/BUILD/beautifulsoup4-4.7.1 running install running install running install_lib running install_lib creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7 creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7 creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder copying build/lib/bs4/builder/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder copying build/lib/bs4/builder/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder copying build/lib/bs4/builder/_html5lib.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder copying build/lib/bs4/builder/_html5lib.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder copying build/lib/bs4/builder/_htmlparser.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder copying build/lib/bs4/builder/_htmlparser.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder copying build/lib/bs4/builder/_lxml.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder copying build/lib/bs4/builder/_lxml.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests creating /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_builder_registry.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_builder_registry.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_docs.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_docs.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_html5lib.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_html5lib.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_htmlparser.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_htmlparser.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_lxml.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_lxml.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_soup.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_soup.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_tree.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/tests/test_tree.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests copying build/lib/bs4/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 copying build/lib/bs4/__init__.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 copying build/lib/bs4/dammit.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 copying build/lib/bs4/dammit.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 copying build/lib/bs4/diagnose.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 copying build/lib/bs4/diagnose.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 copying build/lib/bs4/element.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 copying build/lib/bs4/element.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 copying build/lib/bs4/testing.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 copying build/lib/bs4/testing.py -> /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4 byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder/__init__.py to __init__.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder/__init__.py to __init__.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder/_html5lib.py to _html5lib.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder/_html5lib.py to _html5lib.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder/_htmlparser.py to _htmlparser.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder/_htmlparser.py to _htmlparser.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder/_lxml.py to _lxml.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/builder/_lxml.py to _lxml.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/__init__.py to __init__.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/__init__.py to __init__.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_builder_registry.py to test_builder_registry.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_builder_registry.py to test_builder_registry.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_docs.py to test_docs.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_docs.py to test_docs.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_html5lib.py to test_html5lib.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_html5lib.py to test_html5lib.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_htmlparser.py to test_htmlparser.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_htmlparser.py to test_htmlparser.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_lxml.py to test_lxml.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_lxml.py to test_lxml.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_soup.py to test_soup.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_soup.py to test_soup.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_tree.py to test_tree.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/tests/test_tree.py to test_tree.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/__init__.py to __init__.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/__init__.py to __init__.cpython-37.pyc BUILDSTDERR: byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.+ /usr/lib/rpm/find-debuginfo.sh -j2 --strict-build-id -m -i --build-id-seed 4.7.1-1.fc31 --unique-debug-suffix -4.7.1-1.fc31.x86_64 --unique-debug-src-base python-beautifulsoup4-4.7.1-1.fc31.x86_64 --run-dwz --dwz-low-mem-die-limit 10000000 --dwz-max-die-limit 110000000 -S debugsourcefiles.list /builddir/build/BUILD/beautifulsoup4-4.7.1 BUILDSTDERR: byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.+ /usr/lib/rpm/find-debuginfo.sh -j2 --strict-build-id -m -i --build-id-seed 4.7.1-1.fc31 --unique-debug-suffix -4.7.1-1.fc31.x86_64 --unique-debug-src-base python-beautifulsoup4-4.7.1-1.fc31.x86_64 --run-dwz --dwz-low-mem-die-limit 10000000 --dwz-max-die-limit 110000000 -S debugsourcefiles.list /builddir/build/BUILD/beautifulsoup4-4.7.1 BUILDSTDERR: find: 'debug': No such file or directory BUILDSTDERR: find: 'debug': No such file or directory + /usr/lib/rpm/check-buildroot + /usr/lib/rpm/check-buildroot + /usr/lib/rpm/redhat/brp-ldconfig + /usr/lib/rpm/redhat/brp-ldconfig + /usr/lib/rpm/brp-compress + /usr/lib/rpm/brp-compress + /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip + /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip + /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1 0 + /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1 0 + /usr/lib/rpm/brp-python-hardlink + /usr/lib/rpm/brp-python-hardlink + /usr/lib/rpm/redhat/brp-mangle-shebangs + /usr/lib/rpm/redhat/brp-mangle-shebangs 7/site-packages/bs4/dammit.py to dammit.cpython-37.pyc 7/site-packages/bs4/dammit.py to dammit.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/diagnose.py to diagnose.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/diagnose.py to diagnose.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/element.py to element.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/element.py to element.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/testing.py to testing.cpython-37.pyc byte-compiling /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/bs4/testing.py to testing.cpython-37.pyc writing byte-compilation script '/tmp/tmpskgkltv5.py' writing byte-compilation script '/tmp/tmpskgkltv5.py' /usr/bin/python3 /tmp/tmpskgkltv5.py /usr/bin/python3 /tmp/tmpskgkltv5.py removing /tmp/tmpskgkltv5.py removing /tmp/tmpskgkltv5.py running install_egg_info running install_egg_info running egg_info running egg_info writing beautifulsoup4.egg-info/PKG-INFO writing beautifulsoup4.egg-info/PKG-INFO writing dependency_links to beautifulsoup4.egg-info/dependency_links.txt writing dependency_links to beautifulsoup4.egg-info/dependency_links.txt writing requirements to beautifulsoup4.egg-info/requires.txt writing requirements to beautifulsoup4.egg-info/requires.txt writing top-level names to beautifulsoup4.egg-info/top_level.txt writing top-level names to beautifulsoup4.egg-info/top_level.txt reading manifest file 'beautifulsoup4.egg-info/SOURCES.txt' reading manifest file 'beautifulsoup4.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' reading manifest template 'MANIFEST.in' writing manifest file 'beautifulsoup4.egg-info/SOURCES.txt' writing manifest file 'beautifulsoup4.egg-info/SOURCES.txt' Copying beautifulsoup4.egg-info to /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/beautifulsoup4-4.7.1-py3.7.egg-info Copying beautifulsoup4.egg-info to /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7/site-packages/beautifulsoup4-4.7.1-py3.7.egg-info running install_scripts running install_scripts Bytecompiling .py files below /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7 using /usr/bin/python3.7 Bytecompiling .py files below /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python3.7 using /usr/bin/python3.7 Bytecompiling .py files below /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7 using /usr/bin/python2.7 Bytecompiling .py files below /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/lib/python2.7 using /usr/bin/python2.7 Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.MJYlGu Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.MJYlGu + umask 022 + umask 022 + cd /builddir/build/BUILD + cd /builddir/build/BUILD + cd beautifulsoup4-4.7.1 + cd beautifulsoup4-4.7.1 + /usr/bin/python2 -m unittest discover -s bs4 + /usr/bin/python2 -m unittest discover -s bs4 BUILDSTDERR: .........................................................................................................................................................................................................................................................................................................................................................................................................................bs4/builder/_htmlparser.py:78: UserWarning: don't crash BUILDSTDERR: .........................................................................................................................................................................................................................................................................................................................................................................................................................bs4/builder/_htmlparser.py:78: UserWarning: don't crash BUILDSTDERR: warnings.warn(msg) BUILDSTDERR: warnings.warn(msg) BUILDSTDERR: ................................................................................ BUILDSTDERR: ................................................................................ BUILDSTDERR: ---------------------------------------------------------------------- BUILDSTDERR: ---------------------------------------------------------------------- BUILDSTDERR: Ran 489 tests in 0.777s BUILDSTDERR: Ran 489 tests in 0.777s BUILDSTDERR: OK BUILDSTDERR: OK + pushd /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 + pushd /builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 + /usr/bin/python3 -m unittest discover -s bs4 + /usr/bin/python3 -m unittest discover -s bs4 BUILDSTDERR: ........................................................................................................................................./builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31/bs4/builder/_htmlparser.py:78: UserWarning: don't crash BUILDSTDERR: ........................................................................................................................................./builddir/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31/bs4/builder/_htmlparser.py:78: UserWarning: don't crash BUILDSTDERR: warnings.warn(msg) BUILDSTDERR: warnings.warn(msg) BUILDSTDERR: ................................................................................................................................................................................................................................................................................................................................................................ BUILDSTDERR: ................................................................................................................................................................................................................................................................................................................................................................ BUILDSTDERR: ---------------------------------------------------------------------- BUILDSTDERR: ---------------------------------------------------------------------- BUILDSTDERR: Ran 489 tests in 0.581s BUILDSTDERR: Ran 489 tests in 0.581s BUILDSTDERR: OK BUILDSTDERR: OK + RPM_EC=0 + RPM_EC=0 BUILDSTDERR: ++ jobs -p BUILDSTDERR: ++ jobs -p + exit 0 + exit 0 ~/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 ~/build/BUILD/beautifulsoup4-4.7.1 ~/build/BUILD/python3-python-beautifulsoup4-4.7.1-1.fc31 ~/build/BUILD/beautifulsoup4-4.7.1 Processing files: python2-beautifulsoup4-4.7.1-1.fc31.noarch Processing files: python2-beautifulsoup4-4.7.1-1.fc31.noarch Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.Yf895w Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.Yf895w + umask 022 + umask 022 + cd /builddir/build/BUILD + cd /builddir/build/BUILD + cd beautifulsoup4-4.7.1 + cd beautifulsoup4-4.7.1 + DOCDIR=/builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python2-beautifulsoup4 + DOCDIR=/builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python2-beautifulsoup4 + export LC_ALL=C + export LC_ALL=C + LC_ALL=C + LC_ALL=C + export DOCDIR + export DOCDIR + /usr/bin/mkdir -p /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python2-beautifulsoup4 + /usr/bin/mkdir -p /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python2-beautifulsoup4 + cp -pr NEWS.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python2-beautifulsoup4 + cp -pr NEWS.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python2-beautifulsoup4 + cp -pr TODO.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python2-beautifulsoup4 + cp -pr TODO.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python2-beautifulsoup4 + RPM_EC=0 + RPM_EC=0 BUILDSTDERR: ++ jobs -p BUILDSTDERR: ++ jobs -p + exit 0 + exit 0 Executing(%license): /bin/sh -e /var/tmp/rpm-tmp.QD12Cw Executing(%license): /bin/sh -e /var/tmp/rpm-tmp.QD12Cw + umask 022 + umask 022 + cd /builddir/build/BUILD + cd /builddir/build/BUILD + cd beautifulsoup4-4.7.1 + cd beautifulsoup4-4.7.1 + LICENSEDIR=/builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python2-beautifulsoup4 + LICENSEDIR=/builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python2-beautifulsoup4 + export LC_ALL=C + export LC_ALL=C + LC_ALL=C + LC_ALL=C + export LICENSEDIR + export LICENSEDIR + /usr/bin/mkdir -p /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python2-beautifulsoup4 + /usr/bin/mkdir -p /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python2-beautifulsoup4 + cp -pr COPYING.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python2-beautifulsoup4 + cp -pr COPYING.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python2-beautifulsoup4 + RPM_EC=0 + RPM_EC=0 BUILDSTDERR: ++ jobs -p BUILDSTDERR: ++ jobs -p + exit 0 + exit 0 Provides: python-beautifulsoup4 = 4.7.1-1.fc31 python2-beautifulsoup4 = 4.7.1-1.fc31 python2.7dist(beautifulsoup4) = 4.7.1 python2dist(beautifulsoup4) = 4.7.1 Provides: python-beautifulsoup4 = 4.7.1-1.fc31 python2-beautifulsoup4 = 4.7.1-1.fc31 python2.7dist(beautifulsoup4) = 4.7.1 python2dist(beautifulsoup4) = 4.7.1 Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PartialHardlinkSets) <= 4.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PartialHardlinkSets) <= 4.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 Requires: python(abi) = 2.7 python2.7dist(soupsieve) >= 1.2 Requires: python(abi) = 2.7 python2.7dist(soupsieve) >= 1.2 Obsoletes: python-beautifulsoup4 < 4.7.1-1.fc31 Obsoletes: python-beautifulsoup4 < 4.7.1-1.fc31 Processing files: python3-beautifulsoup4-4.7.1-1.fc31.noarch Processing files: python3-beautifulsoup4-4.7.1-1.fc31.noarch Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.qkwHju Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.qkwHju + umask 022 + umask 022 + cd /builddir/build/BUILD + cd /builddir/build/BUILD + cd beautifulsoup4-4.7.1 + cd beautifulsoup4-4.7.1 + DOCDIR=/builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python3-beautifulsoup4 + DOCDIR=/builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python3-beautifulsoup4 + export LC_ALL=C + export LC_ALL=C + LC_ALL=C + LC_ALL=C + export DOCDIR + export DOCDIR + /usr/bin/mkdir -p /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python3-beautifulsoup4 + /usr/bin/mkdir -p /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python3-beautifulsoup4 + cp -pr NEWS.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python3-beautifulsoup4 + cp -pr NEWS.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python3-beautifulsoup4 + cp -pr TODO.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python3-beautifulsoup4 + cp -pr TODO.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/doc/python3-beautifulsoup4 + RPM_EC=0 + RPM_EC=0 BUILDSTDERR: ++ jobs -p BUILDSTDERR: ++ jobs -p + exit 0 + exit 0 Executing(%license): /bin/sh -e /var/tmp/rpm-tmp.7Ium5s Executing(%license): /bin/sh -e /var/tmp/rpm-tmp.7Ium5s + umask 022 + umask 022 + cd /builddir/build/BUILD + cd /builddir/build/BUILD + cd beautifulsoup4-4.7.1 + cd beautifulsoup4-4.7.1 + LICENSEDIR=/builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python3-beautifulsoup4 + LICENSEDIR=/builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python3-beautifulsoup4 + export LC_ALL=C + export LC_ALL=C + LC_ALL=C + LC_ALL=C + export LICENSEDIR + export LICENSEDIR + /usr/bin/mkdir -p /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python3-beautifulsoup4 + /usr/bin/mkdir -p /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python3-beautifulsoup4 + cp -pr COPYING.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python3-beautifulsoup4 + cp -pr COPYING.txt /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64/usr/share/licenses/python3-beautifulsoup4 + RPM_EC=0 + RPM_EC=0 BUILDSTDERR: ++ jobs -p BUILDSTDERR: ++ jobs -p + exit 0 + exit 0 Provides: python3-beautifulsoup4 = 4.7.1-1.fc31 python3.7dist(beautifulsoup4) = 4.7.1 python3dist(beautifulsoup4) = 4.7.1 Provides: python3-beautifulsoup4 = 4.7.1-1.fc31 python3.7dist(beautifulsoup4) = 4.7.1 python3dist(beautifulsoup4) = 4.7.1 Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PartialHardlinkSets) <= 4.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PartialHardlinkSets) <= 4.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 Requires: python(abi) = 3.7 python3.7dist(soupsieve) >= 1.2 Requires: python(abi) = 3.7 python3.7dist(soupsieve) >= 1.2 Obsoletes: python3-BeautifulSoup < 1:3.2.1-2 Obsoletes: python3-BeautifulSoup < 1:3.2.1-2 Checking for unpackaged file(s): /usr/lib/rpm/check-files /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 Checking for unpackaged file(s): /usr/lib/rpm/check-files /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 Wrote: /builddir/build/RPMS/python3-beautifulsoup4-4.7.1-1.fc31.noarch.rpm Wrote: /builddir/build/RPMS/python3-beautifulsoup4-4.7.1-1.fc31.noarch.rpm Wrote: /builddir/build/RPMS/python2-beautifulsoup4-4.7.1-1.fc31.noarch.rpm Wrote: /builddir/build/RPMS/python2-beautifulsoup4-4.7.1-1.fc31.noarch.rpm Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.5EHVXt Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.5EHVXt + umask 022 + umask 022 + cd /builddir/build/BUILD + cd /builddir/build/BUILD + cd beautifulsoup4-4.7.1 + cd beautifulsoup4-4.7.1 + /usr/bin/rm -rf /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 + /usr/bin/rm -rf /builddir/build/BUILDROOT/python-beautifulsoup4-4.7.1-1.fc31.x86_64 + RPM_EC=0 + RPM_EC=0 BUILDSTDERR: ++ jobs -p BUILDSTDERR: ++ jobs -p + exit 0 + exit 0 Child return code was: 0 Child return code was: 0