On 24/02/2021 18:00, Chris Angelico wrote:
On Thu, Feb 25, 2021 at 2:02 AM lucas <lu...@bourneuf.net> wrote:

Hi everyone,

(Sorry for the double-send if any, i'm not sure the first send was
performed, maybe because of bounce errors according to mailman.)


I'm currently trying to understand an error when using the
dokuwikixmlrpc python module, allowing to easily work with DokuWiki RPC
interface.

Another description of the problem :
         https://github.com/kynan/dokuwikixmlrpc/issues/8

Here is the code, tailored to work with the DokuWiki RPC interface:

      from urllib.parse import urlencode
      import xmlrpc.client as xmlrpclib

      URL = 'wiki.example.net'
      USER = 'user'
      PASSWD = 'password'
      USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'

      script = '/lib/exe/xmlrpc.php'
      url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
      xmlrpclib.Transport.user_agent = USER_AGENT
      xmlrpclib.SafeTransport.user_agent = USER_AGENT
      proxy = xmlrpclib.ServerProxy(url)

      v = proxy.dokuwiki.getVersion()
      print(v)

When ran with Python 3.7 (a personnal debian server, or a personal
windows computer), i obtain the expected 'Release 2018-04-22a "Greebo"'
as ouput.
When ran with Python 3.9 (my personnal, manjaro machine), i obtain the
following stacktrace:

      Traceback (most recent call last):
        File "/home/project/read.py", line 32, in <module>
          v = proxy.dokuwiki.getVersion()
        File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
          return self.__send(self.__name, args)
        File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
          response = self.__transport.request(
        File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
          return self.single_request(host, handler, request_body, verbose)
        File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in
single_request
          raise ProtocolError(
      xmlrpc.client.ProtocolError: <ProtocolError for
wiki.example.net/lib/exe/xmlrpc.php: 401 Unauthorized>


A properly-formed URL will start with a protocol. I don't know
specifically what changed, but it's looking like something started
rejecting malformed URLs. Try adding "http://"; or "https://"; to your
URL (whichever is appropriate) and see if both versions will accept
it.

ChrisA


I did that, obtaining the following URL

https://wiki.[…]/lib/exe/xmlrpc.php?u=[…]&p=[…]

on my two currently available computer (laptop on 3.9, remote on 3.7), and the results is the same.

For information, i'm uploading the same python program to my remote server (debian, 3.7), and running it with the same parameters as my laptop (manjaro, 3.9). My laptop is getting the 401, my server is getting the expected dokuwiki version.

--lucas
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to