You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by te...@apache.org on 2022/05/14 01:59:44 UTC

[pulsar] branch master updated: [fix][doc] Adjust python example in cpp client directory to fix string interpolation (#15458)

This is an automated email from the ASF dual-hosted git repository.

technoboy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 5ecd5f3d2d3 [fix][doc] Adjust python example in cpp client directory to fix string interpolation (#15458)
5ecd5f3d2d3 is described below

commit 5ecd5f3d2d351ab880f57f0d8063b2b27938336c
Author: Samuel Redai <43...@users.noreply.github.com>
AuthorDate: Fri May 13 21:59:38 2022 -0400

    [fix][doc] Adjust python example in cpp client directory to fix string interpolation (#15458)
---
 pulsar-client-cpp/python/pulsar/__init__.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/pulsar-client-cpp/python/pulsar/__init__.py b/pulsar-client-cpp/python/pulsar/__init__.py
index 3721e62df2e..e79955b57dd 100644
--- a/pulsar-client-cpp/python/pulsar/__init__.py
+++ b/pulsar-client-cpp/python/pulsar/__init__.py
@@ -64,14 +64,15 @@ To install the Python bindings:
     import pulsar
 
     client = pulsar.Client('pulsar://localhost:6650')
+
     consumer = client.subscribe('my-topic', 'my-subscription')
 
     while True:
         msg = consumer.receive()
         try:
-            print("Received message '%s' id='%s'", msg.data().decode('utf-8'), msg.message_id())
+            print("Received message '{}' id='{}'".format(msg.data(), msg.message_id()))
             consumer.acknowledge(msg)
-        except:
+        except Exception:
             consumer.negative_acknowledge(msg)
 
     client.close()