Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

refextract importing issues: syntax error

Does anyone have any experience using the python library Refextract, package index here. I'm using python 3.4 in Spyder 3.0.0. Pip install went fine, it said the installation was succesfull, in the correct folder (in the Libs/Site packages/ folder). But when I try to load it, it throws in a error message, and I can't really figure out what it means.

Here is my code snippet: from refextract import extract_journal_reference (as displayed in the manual), which gives the following error:

  from refextract import extract_journal_reference
  File "C:\path\to\python-3.4.3.amd64\lib\site-packages\refextract\references\api.py", line 96
  raise FullTextNotAvailableError("URL not found: '{0}'".format(url)), None, sys.exc_info()[2]
                                                                       ^
SyntaxError: invalid syntax

This is just the importing, not yet the specifying of the link. Does anyone know what to do with this error?

like image 980
CMorgan Avatar asked Oct 30 '22 06:10

CMorgan


1 Answers

The code that raises the exception is using syntax which is valid in Python2, but not in Python3.

In Python2, it is possible to associate an arbitrary traceback with an exception with this variation of the raise statement.

raise FooError, 'A foo has happened', a_traceback_object

or as in this case:

raise FooError('A foo has happened'), None, a_traceback_object.

In Python3, the traceback object must be explicitly assigned to the exception's __traceback__ attribute:

ex = FooError('A foo has happened')
ex.__traceback__ = a_traceback_object
raise ex

See PEP 3109 for discussion of this change (summary: reduce the number of different ways of using raise).

As far as I can see, the package does not claim to be python3-compliant, so you need to run it with Python2 (specifically, 2.7).

like image 189
snakecharmerb Avatar answered Nov 15 '22 06:11

snakecharmerb