question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug in PaymentRequest class in lib/paymentrequest.py

See original GitHub issue

From lib/paymentrequest.py at line 187:

class PaymentRequest:

    def __init__(self, data, error=None):
        self.raw = data
        self.error = error
        self.parse(data)
        self.requestor = None # known after verify
        self.tx = None

    def __str__(self):
        return self.raw

^ self.raw above is sometimes a bytes object. This causes python runtime to throw an exception when doing str(request) on a PaymentRequest object (see #770).

I would like to fix this – (perhaps if isinstance(self.raw, bytes)… bla). Or some other approach.

So… what’s the deal here? Suggestions? Should I just fix it by detecting bytes and encoding to string?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
cculianucommented, Jul 2, 2018

Right you are. The paymentrequest.raw field is actually a bunch of google protocol buffer bytes so … the ‘str’ isn’t meaningful. It’s just for debugging. But – you know – might as well fix it since it’s clearly not to spec… even for debugging. 😃

0reactions
marceloneilcommented, Jul 2, 2018

It does make sense that self.raw is bytes, but why implement __str__ in the first place? I’m assuming it was just for debugging

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Pay API PaymentRequest Tutorial
Step 1: Create a PaymentDataRequest object · Step 2: Declare Google Pay API support · Putting it all together · Payment method parameter...
Read more >
Payment Request API - W3C
The working group maintains a list of all bug reports that the group has not yet addressed. Pull requests with proposed specification text ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found