0

I'm using libais, a very simple library to process marine AIS messages. I've used this a lot and I'm sure my code is ok. Using REPL:

import ais
msg = '177KQJ5000G?tO`K>RA1wUbN0TKH'   # a valid AIS encoded string
ais.decode(msg)  # this will succeed
ais.decode(msg)  # this will fail
ais.decode(msg)  # this will succeed
ais.decode(msg)  # this will fail, etc

by fail I mean I will get the error: TypeError: Function takes exactly 2 arguments (1 given)

This is such weird behavior I'm thinking it's related to my environment. I think this started happening right after I installed (then removed) Anaconda. My platform is RHEL7. I've deleted and reinstalled libais. Short of rebuilding this server, I'm not sure what else to do. Any thoughts on how to troubleshoot a "works every other time" error?

zvone
  • 18,045
  • 3
  • 49
  • 77
simusid
  • 1,854
  • 3
  • 18
  • 26
  • 7
    What is the **full traceback** of the exception? – Martijn Pieters Dec 14 '17 at 21:16
  • 1
    @MartijnPieters: I can reproduce the error in Python 2.7, and that literally _is_ the only output. There's no traceback (they're wrapping a c++ library, I think.) Everything seems to work in both 2 and 3 if we use the correct signature. – DSM Dec 14 '17 at 21:28
  • What context are you calling this in? Python 2 or 3? I can't reproduce it in Py2, for whatever it's worth. – a p Dec 14 '17 at 21:28
  • all the examples I can find show `ais.decode()` taking a message and an additional integer value... – Aaron Dec 14 '17 at 21:30
  • I don't think it's in the library. I've done exactly this a few times and when you call the `decode` method with 0 arguments you get a `DecodeError`, not a `TypeError`. Might be related to the Anaconda (un)install? It defnitely looks like a situation where something expects a `self` argument but isn't getting it. – a p Dec 14 '17 at 21:31
  • @DSM: but the traceback would include the `ais.decode(msg)` line, surely? That would already make it clearer there is no more detail to the traceback. – Martijn Pieters Dec 14 '17 at 21:31
  • 4
    @MartijnPieters: I [meant what I said](http://dpaste.com/1KR009G). ;-) – DSM Dec 14 '17 at 21:33
  • 2
    @DSM: wow. That's one messed up library. It could well be printing the message directly. I'm assuming now that trying to catch the `TypeError` won't even work? – Martijn Pieters Dec 14 '17 at 21:34
  • @MartijnPieters: nope, just tried, and it's not caught, which means it was probably not really raised. – DSM Dec 14 '17 at 21:36
  • It is not being raised. It is just printing "TypeError: function takes exactly 2 arguments (1 given)". It does not look as a traceback to me. – Elis Byberi Dec 14 '17 at 21:37
  • What version of the library did you get? I can't repro in Python 2.7.14. – a p Dec 14 '17 at 21:38
  • http://dpaste.com/2MBFSXE <-- what I see. Really strange. – a p Dec 14 '17 at 21:41

1 Answers1

0

Thanks folks. I consider this "solved" so I'm accepting the answer that the library is to blame, when I originally thought it was a corrupt python installation. I was not using the (allegedly optional) second parameter. I am now, and everything works fine.

simusid
  • 1,854
  • 3
  • 18
  • 26