[New-bugs-announce] [issue34250] import xmlrpclib not works in file named "xml.py"

Fekete György report at bugs.python.org
Fri Jul 27 12:17:54 EDT 2018


New submission from Fekete György <gyuri at feketegyuri.hu>:

Big magic in python 2.7.15 win version:

Create file: "xml.py" containing 2 code lines:

import xmlrpclib

proxy = xmlrpclib.ServerProxy("http://localhost:8000/")

run it, and it gives u a nice error:
C:\work\mitre>\Python27\python.exe xml.py
Traceback (most recent call last):
  File "xml.py", line 1, in <module>
    import xmlrpclib
  File "C:\Python27\lib\xmlrpclib.py", line 538, in <module>
    from xml.parsers import expat
  File "C:\work\mitre\xml.py", line 3, in <module>
    proxy = xmlrpclib.ServerProxy("http://localhost:8000/")
AttributeError: 'module' object has no attribute 'ServerProxy'


U also get this error, when this file present in the directory where u want to import xmlrpclib in another py. ANd if only the compiled xml.pyc exist, the bug comes.  But if you rename it to xm.py, it works!

Maybe a bad import from wrong directory in xmlrpclib. Not tested on another version or platform.

----------
components: Windows
files: xml.py
messages: 322505
nosy: fgyuri, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: import xmlrpclib not works in file named "xml.py"
type: compile error
versions: Python 2.7
Added file: https://bugs.python.org/file47718/xml.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34250>
_______________________________________


More information about the New-bugs-announce mailing list