From dfcae65e81b1bdf889fa12d1895f1c0b0c5dc21d Mon Sep 17 00:00:00 2001 From: Jerry James Date: Dec 23 2016 16:38:36 +0000 Subject: Fix syntax that became invalid with python 3.6. --- diff --git a/python-pybtex-python36.patch b/python-pybtex-python36.patch new file mode 100644 index 0000000..7125766 --- /dev/null +++ b/python-pybtex-python36.patch @@ -0,0 +1,228 @@ +--- docs/pybtex_doctools/pygments.py.orig 2016-03-10 04:34:54.000000000 -0700 ++++ docs/pybtex_doctools/pygments.py 2016-12-23 09:03:53.157804950 -0700 +@@ -93,7 +93,7 @@ class BibTeXLexer(ExtendedRegexLexer): + filenames = ['*.bib'] + flags = re.IGNORECASE + +- IDENTIFIER = ur'[{0}][{1}]*'.format(re.escape(NAME_CHARS), re.escape(NAME_CHARS + digits)) ++ IDENTIFIER = r'[{0}][{1}]*'.format(re.escape(NAME_CHARS), re.escape(NAME_CHARS + digits)) + + def open_brace_callback(self, match, ctx): + opening_brace = match.group() +@@ -200,7 +200,7 @@ class BSTLexer(RegexLexer): + (r'[^#\"\{\}\s]+\$', Name.Builtin), + (r'[^#\"\{\}\s]+', Name.Variable), + (r'"[^\"]*"', String), +- (ur'#-?\d+', Number), ++ (r'#-?\d+', Number), + ('{', Text.Punctuation, ('group-end', 'body')), + default('#pop'), + ], +--- pybtex/backends/html.py.orig 2016-03-10 04:34:54.000000000 -0700 ++++ pybtex/backends/html.py 2016-12-23 09:06:01.045944626 -0700 +@@ -72,10 +72,10 @@ class Backend(BaseBackend): + return escape(text) + + def format_tag(self, tag, text): +- return ur'<{0}>{1}'.format(tag, text) if text else u'' ++ return r'<{0}>{1}'.format(tag, text) if text else u'' + + def format_href(self, url, text): +- return ur'{1}'.format(url, text) if text else u'' ++ return r'{1}'.format(url, text) if text else u'' + + def write_prologue(self): + encoding = self.encoding or pybtex.io.get_default_encoding() +--- pybtex/backends/latex.py.orig 2016-03-17 09:20:19.000000000 -0600 ++++ pybtex/backends/latex.py 2016-12-23 09:05:16.894241642 -0700 +@@ -72,7 +72,7 @@ class Backend(BaseBackend): + if tag is None: + return u'{%s}' % text if text else u'' + else: +- return ur'\%s{%s}' % (tag, text) if text else u'' ++ return r'\%s{%s}' % (tag, text) if text else u'' + + def format_href(self, url, text): + if not text: +@@ -80,7 +80,7 @@ class Backend(BaseBackend): + elif text == url: + return u'\\url{%s}' % url + else: +- return ur'\href{%s}{%s}' % (url, text) if text else u'' ++ return r'\href{%s}{%s}' % (url, text) if text else u'' + + def format_protected(self, text): + """ +--- pybtex/backends/markdown.py.orig 2016-03-10 04:34:54.000000000 -0700 ++++ pybtex/backends/markdown.py 2016-12-23 09:05:39.069092468 -0700 +@@ -109,10 +109,10 @@ class Backend(BaseBackend): + if tag is None: + return text + else: +- return ur'{0}{1}{0}'.format(tag, text) if text else u'' ++ return r'{0}{1}{0}'.format(tag, text) if text else u'' + + def format_href(self, url, text): +- return ur'[%s](%s)' % (text, url) if text else u'' ++ return r'[%s](%s)' % (text, url) if text else u'' + + def write_entry(self, key, label, text): + # Support http://www.michelf.com/projects/php-markdown/extra/#def-list +--- pybtex/bibtex/bst.py.orig 2016-03-11 01:33:56.000000000 -0700 ++++ pybtex/bibtex/bst.py 2016-12-23 09:07:06.428504788 -0700 +@@ -44,7 +44,7 @@ def process_function(toks): + return FunctionLiteral(toks[0]) + + +-quote_or_comment = re.compile(ur'[%"]') ++quote_or_comment = re.compile(r'[%"]') + def strip_comment(line): + """Strip the commented part of the line." + +@@ -88,9 +88,9 @@ from pybtex.scanner import ( + class BstParser(Scanner): + LBRACE = Literal(u'{') + RBRACE = Literal(u'}') +- STRING = Pattern(ur'"[^\"]*"', 'string') +- INTEGER = Pattern(ur'#-?\d+', 'integer') +- NAME = Pattern(ur'[^#\"\{\}\s]+', 'name') ++ STRING = Pattern(r'"[^\"]*"', 'string') ++ INTEGER = Pattern(r'#-?\d+', 'integer') ++ NAME = Pattern(r'[^#\"\{\}\s]+', 'name') + + COMMANDS = { + 'ENTRY': 3, +--- pybtex/bibtex/names.py.orig 2016-03-11 01:22:03.000000000 -0700 ++++ pybtex/bibtex/names.py 2016-12-23 09:07:25.997373145 -0700 +@@ -286,9 +286,9 @@ class UnbalancedBraceError(PybtexSyntaxE + class NameFormatParser(Scanner): + LBRACE = Literal(u'{') + RBRACE = Literal(u'}') +- TEXT = Pattern(ur'[^{}]+', 'text') +- NON_LETTERS = Pattern(ur'[^{}\w]|\d+', 'non-letter characters', flags=re.IGNORECASE | re.UNICODE) +- FORMAT_CHARS = Pattern(ur'[^\W\d_]+', 'format chars', flags=re.IGNORECASE | re.UNICODE) ++ TEXT = Pattern(r'[^{}]+', 'text') ++ NON_LETTERS = Pattern(r'[^{}\w]|\d+', 'non-letter characters', flags=re.IGNORECASE | re.UNICODE) ++ FORMAT_CHARS = Pattern(r'[^\W\d_]+', 'format chars', flags=re.IGNORECASE | re.UNICODE) + + lineno = None + +--- pybtex/cmdline.py.orig 2016-03-11 01:18:18.000000000 -0700 ++++ pybtex/cmdline.py 2016-12-23 09:30:57.908272676 -0700 +@@ -175,7 +175,7 @@ class CommandLine(object): + from pybtex.exceptions import PybtexError + try: + self.main() +- except PybtexError, error: ++ except PybtexError as error: + errors.print_error(error) + sys.exit(1) + +--- pybtex/database/input/bibtex.py.orig 2016-03-10 04:34:54.000000000 -0700 ++++ pybtex/database/input/bibtex.py 2016-12-23 09:32:35.139655643 -0700 +@@ -110,10 +110,10 @@ class UndefinedMacro(PybtexSyntaxError): + + + class BibTeXEntryIterator(Scanner): +- NAME = Pattern(ur'[{0}][{1}]*'.format(re.escape(NAME_CHARS), re.escape(NAME_CHARS + digits)), 'a valid name') +- KEY_PAREN = Pattern(ur'[^\s\,]+', 'entry key') +- KEY_BRACE = Pattern(ur'[^\s\,}]+', 'entry key') +- NUMBER = Pattern(ur'[{0}]+'.format(digits), 'a number') ++ NAME = Pattern(r'[{0}][{1}]*'.format(re.escape(NAME_CHARS), re.escape(NAME_CHARS + digits)), 'a valid name') ++ KEY_PAREN = Pattern(r'[^\s\,]+', 'entry key') ++ KEY_BRACE = Pattern(r'[^\s\,}]+', 'entry key') ++ NUMBER = Pattern(r'[{0}]+'.format(digits), 'a number') + LBRACE = Literal(u'{') + RBRACE = Literal(u'}') + LPAREN = Literal(u'(') +@@ -212,7 +212,7 @@ class BibTeXEntryIterator(Scanner): + try: + parse_body(body_end) + self.required([body_end]) +- except PybtexSyntaxError, error: ++ except PybtexSyntaxError as error: + self.handle_error(error) + return make_result() + +--- pybtex/database/input/bibyaml.py.orig 2016-03-10 04:34:54.000000000 -0700 ++++ pybtex/database/input/bibyaml.py 2016-12-23 09:32:12.091801906 -0700 +@@ -50,7 +50,7 @@ class OrderedDictSafeLoader(yaml.SafeLoa + key = self.construct_object(key_node, deep=deep) + try: + hash(key) +- except TypeError, exc: ++ except TypeError as exc: + raise yaml.constructor.ConstructorError('while constructing a mapping', + node.start_mark, 'found unacceptable key (%s)' % exc, key_node.start_mark) + value = self.construct_object(value_node, deep=deep) +--- pybtex/database/input/__init__.py.orig 2016-03-10 04:34:54.000000000 -0700 ++++ pybtex/database/input/__init__.py 2016-12-23 09:32:55.690525227 -0700 +@@ -49,7 +49,7 @@ class BaseParser(Plugin): + with open_file(filename, encoding=self.encoding) as f: + try: + self.parse_stream(f) +- except UnicodeDecodeError, e: ++ except UnicodeDecodeError as e: + raise PybtexError(unicode(e), filename=self.filename) + return self.data + +--- pybtex/database/output/bibtex.py.orig 2016-03-10 04:34:54.000000000 -0700 ++++ pybtex/database/output/bibtex.py 2016-12-23 09:31:39.044011628 -0700 +@@ -40,7 +40,7 @@ class Writer(BaseWriter): + {The "World"} + >>> try: + ... print w.quote(r'The {World') +- ... except BibTeXError, error: ++ ... except BibTeXError as error: + ... print error + String has unmatched braces: The {World + """ +@@ -63,13 +63,13 @@ class Writer(BaseWriter): + >>> w.check_braces('end}') + >>> try: + ... w.check_braces('{') +- ... except BibTeXError, error: ++ ... except BibTeXError as error: + ... print error + String has unmatched braces: { + >>> w.check_braces('{test}}') + >>> try: + ... w.check_braces('{{test}') +- ... except BibTeXError, error: ++ ... except BibTeXError as error: + ... print error + String has unmatched braces: {{test} + +--- pybtex/io.py.orig 2016-03-10 04:34:54.000000000 -0700 ++++ pybtex/io.py 2016-12-23 09:29:58.755648061 -0700 +@@ -52,7 +52,7 @@ def _open_existing(opener, filename, mod + def _open_or_create(opener, filename, mode, environ, **kwargs): + try: + return opener(filename, mode, **kwargs) +- except EnvironmentError, error: ++ except EnvironmentError as error: + if 'TEXMFOUTPUT' in environ: + new_filename = path.join(environ['TEXMFOUTPUT'], filename) + try: +@@ -73,7 +73,7 @@ def _open(opener, filename_or_file, mode + return _open_or_create(opener, filename, mode, environ, **kwargs) + else: + return _open_existing(opener, filename, mode, locate=kpsewhich, **kwargs) +- except EnvironmentError, error: ++ except EnvironmentError as error: + raise PybtexError("unable to open %s. %s" % (filename, error.strerror)) + + +--- pybtex/scanner.py.orig 2016-03-10 04:34:54.000000000 -0700 ++++ pybtex/scanner.py 2016-12-23 09:07:48.293223158 -0700 +@@ -56,8 +56,8 @@ class Scanner(object): + text = None + lineno = 1 + pos = 0 +- WHITESPACE = Pattern(ur'\s+', 'whitespace') +- NEWLINE = Pattern(ur'\n|(\r\n)|\r', 'newline') ++ WHITESPACE = Pattern(r'\s+', 'whitespace') ++ NEWLINE = Pattern(r'\n|(\r\n)|\r', 'newline') + + def __init__(self, text, filename=None): + self.text = text diff --git a/python-pybtex.spec b/python-pybtex.spec index a529617..ed3090b 100644 --- a/python-pybtex.spec +++ b/python-pybtex.spec @@ -11,7 +11,9 @@ Summary: BibTeX-compatible bibliography processor written in Python License: MIT URL: http://pybtex.org/ -Source0: https://pypi.python.org/packages/source/p/%{srcname}/%{srcname}-%{version}.tar.bz2 +Source0: https://files.pythonhosted.org/packages/source/p/%{srcname}/%{srcname}-%{version}.tar.bz2 +# Fix syntax that became invalid with python 3.6 +Patch0: %{name}-python36.patch BuildArch: noarch BuildRequires: python2-devel @@ -103,6 +105,7 @@ popd %if 0%{?with_python3} # Fix the python3 shebangs to not use env pushd python3-%{srcname}-%{version} +%patch0 for fil in pybtex/charwidths/make_charwidths.py \ pybtex/database/{convert,format}/__main__.py pybtex/__main__.py; do sed -i 's/env python/python3/' $fil @@ -127,10 +130,11 @@ popd %if 0%{?with_python3} pushd python3-%{srcname}-%{version} PYTHONPATH=$PWD:$PWD/build/lib make -C docs html \ - SPHINXBUILD=%{_bindir}/sphinx-build-3.* + SPHINXBUILD=%{_bindir}/sphinx-build-%{python3_version} %else pushd %{srcname}-%{version} -PYTHONPATH=$PWD:$PWD/build/lib make -C docs html +PYTHONPATH=$PWD:$PWD/build/lib make -C docs html \ + SPHINXBUILD=%{_bindir}/sphinx-build-%{python2_version} %endif rm -f docs/build/html/.buildinfo popd