Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError on fresh install with python 7 #100

Open
johns10 opened this issue Jul 23, 2018 · 5 comments
Open

SyntaxError on fresh install with python 7 #100

johns10 opened this issue Jul 23, 2018 · 5 comments

Comments

@johns10
Copy link

johns10 commented Jul 23, 2018

After installing haigha with pip I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\johns10\AppData\Local\Programs\Python\Python37\lib\site-packages\haigha\connection.py", line 7, in <module>
    from haigha.channel import Channel
  File "C:\Users\johns10\AppData\Local\Programs\Python\Python37\lib\site-packages\haigha\channel.py", line 10, in <module>
    from haigha.frames.frame import Frame
  File "C:\Users\johns10\AppData\Local\Programs\Python\Python37\lib\site-packages\haigha\frames\frame.py", line 74
    raise Frame.FormatError, str(e), sys.exc_info()[-1]
                           ^
SyntaxError: invalid syntax

I tested this on my local machine (win 10/python 3.7), and on a python:3.7-alpine docker build:

webserver_1  |   File "code/webserver.py", line 9, in <module>
webserver_1  |     from haigha.connection import Connection
webserver_1  |   File "/usr/local/lib/python3.7/site-packages/haigha/connection.py", line 7, in <module>
webserver_1  |     from haigha.channel import Channel
webserver_1  |   File "/usr/local/lib/python3.7/site-packages/haigha/channel.py", line 10, in <module>
webserver_1  |     from haigha.frames.frame import Frame
webserver_1  |   File "/usr/local/lib/python3.7/site-packages/haigha/frames/frame.py", line 74
webserver_1  |     raise Frame.FormatError, str(e), sys.exc_info()[-1]
webserver_1  |                            ^
webserver_1  | SyntaxError: invalid syntax```
@johns10
Copy link
Author

johns10 commented Jul 23, 2018

The offending line is:

from haigha.connection import Connection

Changed lines 72-76 in frame.py:

            except Reader.ReaderError as e:
                # Some other format error
                raise (Frame.FormatError, str(e), sys.exc_info()[-1])
            except struct.error as e:
                raise (Frame.FormatError, str(e), sys.exc_info()[-1])

Commented line 280 and 283 in writer.py (I think these types are depreciated in python 3)

Commented line 19 in connection.py (I think exceptions is rolled in to core)

After that the import statement worked - gonna go see if I can get the thing rolling. Sorry I'm not sharp enough to do a diff or anything like that for you guys.

@johns10
Copy link
Author

johns10 commented Jul 23, 2018

Also changed iteritems to items in writer.py (line 188) and channel.py (line 65).

@johns10
Copy link
Author

johns10 commented Jul 23, 2018

Changed line 144 to:

if isinstance(s, str):

in writer.py

@johns10
Copy link
Author

johns10 commented Jul 23, 2018

The next error was:

  File "code/webserver.py", line 21, in <module>
    connection = Connection(user='user',password='pass',vhost='/vhost', host='rabbitmq:5672', hearbeat=None, debug=True)
  File "/usr/local/lib/python3.7/site-packages/haigha/connection.py", line 107, in __init__
    {'LOGIN': self._user, 'PASSWORD': self._password})
  File "/usr/local/lib/python3.7/site-packages/haigha/writer.py", line 189, in write_table
    self._write_item(key, value)
  File "/usr/local/lib/python3.7/site-packages/haigha/writer.py", line 198, in _write_item
    self.write_shortstr(key)
  File "/usr/local/lib/python3.7/site-packages/haigha/writer.py", line 146, in write_shortstr
    self.write_octet(len(s))
  File "/usr/local/lib/python3.7/site-packages/haigha/writer.py", line 81, in write_octet
    self._output_buffer.append(pack(n))
TypeError: an integer is required

@johns10
Copy link
Author

johns10 commented Jul 23, 2018

I'm assuming this isn't fully converted to python 3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant