-
Notifications
You must be signed in to change notification settings - Fork 120
SMPP needs to have a pluggable codec class. #836
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
Conversation
|
This would solve #338 for SMPP. |
|
@rudigiesler @justinvdm @hodgestar can I get a review? |
|
👍, but I don't know the Vumi code-base well enough to know if this might mess with something else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We implemented a ucs2 codec in this PR that proxies to the utf-16be codec. Should we maybe refer to it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, my thinking was to have the map in the DeliveryShortMessageProcessor be only codecs that already exist in the standard python distribution. The configurable codec_class can override some of these if it wants, which it does with the ucs2 implementation it provides.
I'm ±0 on this really, it seemed a sensible thing to do yesterday but happy to stick in a custom codec here as well.
@hodgestar thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok, that works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think sticking to the built-in codecs by default makes sense for now -- we can shift things around easily later.
|
Minor comment, otherwise looks good. |
|
👍 |
|
@rudigiesler thanks for the review, I don't expect you to know everything or be catching problems. The best way to learn is by reading PRs (which is why we're constantly asking you to review stuff). |
vumi/codecs/vumi_codecs.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seem like performance on this would be terrible. Should we construct a reverse mapping?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, let me start on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\o/
|
I left a bunch of questions but they're mostly just to check my understanding of the changes. |
|
I'm wondering whether we should land this and then sort out the 7-bit packing in a separate PR? We should start that PR by adding an integration test that sends in a 7-bit packed PDU and checks that we handle it correctly? 👍 on this PR landing once we have the ticket for the new one. |
|
@hodgestar GSM7Bit now returns bytestrings, I'm reasonably convinced that I saw that that is what we were receiving anyway. Also added handling of |
vumi/codecs/vumi_codecs.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this perhaps need to be return self.gsm_basic_charset_map.get('?')?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should have tests for the error cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
|
@hodgestar ready for rereview |
|
@rudigiesler @justinvdm also again ready for re-revieww |
vumi/codecs/vumi_codecs.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed another issue here -- we call the same error handlers for both encoding and decoding, but I don't think that makes sense:
- For decoding,
handle_replace_errorneeds to returnu'?'. - For decoding and encoding,
handle_strict_errorshould raiseUnicodeDecodeErrororUnicodeEncodeErroras appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a feeling this was a bad idea to begin with.
|
@hodgestar ok, again :) Not entirely happy with some of the duplication but it's not too bad. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should check that UnicodeEncodeError is raised (and the equivalent decode test should have a similar change).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, done.
|
Other than one small comment, looking good. |
|
👍 as soon as a Travis build passes (looks like they're building now). |
It is possible for MNOs to give us messages that are in an encoding that aren't in the standard encodings that Python ships with.
We have two options:
We've chosen to go with option 2 because adding a codec to the registry introduces all sorts of potential code loading race conditions.