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 in xmlrpc.client examples #50329

Closed
thijs mannequin opened this issue May 21, 2009 · 4 comments
Closed

SyntaxError in xmlrpc.client examples #50329

thijs mannequin opened this issue May 21, 2009 · 4 comments
Assignees
Labels
build The build process and cross-build docs Documentation in the Doc dir

Comments

@thijs
Copy link
Mannequin

thijs mannequin commented May 21, 2009

BPO 6079
Nosy @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/birkenfeld'
closed_at = <Date 2009-05-22.16:44:15.521>
created_at = <Date 2009-05-21.16:11:58.611>
labels = ['build', 'docs']
title = 'SyntaxError in xmlrpc.client examples'
updated_at = <Date 2009-05-22.16:44:15.519>
user = 'https://bugs.python.org/thijs'

bugs.python.org fields:

activity = <Date 2009-05-22.16:44:15.519>
actor = 'georg.brandl'
assignee = 'georg.brandl'
closed = True
closed_date = <Date 2009-05-22.16:44:15.521>
closer = 'georg.brandl'
components = ['Documentation']
creation = <Date 2009-05-21.16:11:58.611>
creator = 'thijs'
dependencies = []
files = []
hgrepos = []
issue_num = 6079
keywords = []
message_count = 4.0
messages = ['88162', '88163', '88164', '88200']
nosy_count = 2.0
nosy_names = ['georg.brandl', 'thijs']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = 'compile error'
url = 'https://bugs.python.org/issue6079'
versions = ['Python 3.0']

@thijs
Copy link
Mannequin Author

thijs mannequin commented May 21, 2009

The example is defined as:

import xmlrpc.client

proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")
try:
    proxy.add(2, 5)
except xmlrpc.client.Fault, err:
    print("A fault occurred")
    print("Fault code: %d" % err.faultCode)
    print("Fault string: %s" % err.faultString)

Which throws the following error:

File "test.py", line 6
except xmlrpc.client.Fault, err:
^
SyntaxError: invalid syntax

I think it should be defined instead as:

import xmlrpc.client

proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")
try:
    proxy.add(2, 5)
except xmlrpc.client.Fault as err:
    print("A fault occurred")
    print("Fault code: %d" % err.faultCode)
    print("Fault string: %s" % err.faultString)

@thijs thijs mannequin assigned birkenfeld May 21, 2009
@thijs thijs mannequin added docs Documentation in the Doc dir build The build process and cross-build labels May 21, 2009
@thijs
Copy link
Mannequin Author

thijs mannequin commented May 21, 2009

On the same documentation page for Python 3.1b1 it shows a similar error
for the ProtocolError example:

import xmlrpc.client

# create a ServerProxy with an invalid URI
proxy = xmlrpc.client.ServerProxy("http://invalidaddress/")

try:
proxy.some_method()
except xmlrpc.client.ProtocolError, err:
print("A protocol error occurred")
print("URL: %s" % err.url)
print("HTTP/HTTPS headers: %s" % err.headers)
print("Error code: %d" % err.errcode)
print("Error message: %s" % err.errmsg)

Throws this error:

File "proto.py", line 8
except xmlrpc.client.ProtocolError, err:
^
SyntaxError: invalid syntax

Which should be fixed with:

import xmlrpc.client

# create a ServerProxy with an invalid URI
proxy = xmlrpc.client.ServerProxy("http://invalidaddress/")

try:
proxy.some_method()
except xmlrpc.client.ProtocolError as err:
print("A protocol error occurred")
print("URL: %s" % err.url)
print("HTTP/HTTPS headers: %s" % err.headers)
print("Error code: %d" % err.errcode)
print("Error message: %s" % err.errmsg)

@thijs
Copy link
Mannequin Author

thijs mannequin commented May 21, 2009

Updated ticket title since it's for multiple sections in the
documentation, not just the Fault example.

@thijs thijs mannequin changed the title SyntaxError in xmlrpc.client Fault example SyntaxError in xmlrpc.client examples May 21, 2009
@birkenfeld
Copy link
Member

Thanks, fixed in r72832.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

1 participant