This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Error initialising BaseManager class with 'authkey' argument of string type.
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Drauger, asksol, jnoller, python-dev, r.david.murray, sbt
Priority: normal Keywords:

Created on 2012-04-05 06:45 by Drauger, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (5)
msg157539 - (view) Author: Максим Цыпкин (Drauger) Date: 2012-04-05 06:45
The following code:

    class TestServer(BaseManager):pass
    Server_1=TestServer(address=("127.0.0.1",55555),authkey="passkey")

produces following error in python 3.2 :

"TypeError: string argument without an encoding"

The cause is in BaseManager constructor implementation (Python32\Lib\multiprocessing\managers.py):

self._authkey = AuthenticationString(authkey)

The "AuthenticationString" class is a substitute of "bytes" class, and 
"bytes" class requires second encoding argument, if first argument is a string.

I've solved this problem, changing the code in "Python32\Lib\multiprocessing\managers.py" to following:

        if isinstance(authkey,str):
            self._authkey = AuthenticationString(authkey,'utf-8')
        else:
            self._authkey = AuthenticationString(authkey)

This works for me. Please consider to fix this issue in release.
msg157577 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-04-05 12:52
Thanks for the report.

I'm not familiar with multiprocessing, so I'll have to leave it to someone else to judge the fix.

We use 'crash' to indicate a segfault in the Python interpreter, so I'm changing the type to 'behavior' (that is, a normal bug).
msg166480 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-07-26 12:59
You could just do

    Server_1=TestServer(address=("127.0.0.1",55555),authkey=b"passkey")

so this is probably a documentation issue.  The examples in the documentation should at least be updated.
msg168443 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-08-17 13:43
New changeset 636f75da4b9e by Richard Oudkerk in branch '3.2':
Issue #14501: Clarify that authentication keys are byte strings
http://hg.python.org/cpython/rev/636f75da4b9e
msg168444 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-08-17 13:52
I have fixed the documentation and examples to say that authentication keys are byte strings.
History
Date User Action Args
2022-04-11 14:57:28adminsetgithub: 58706
2012-08-17 13:52:24sbtsetstatus: open -> closed
resolution: fixed
messages: + msg168444

stage: needs patch -> resolved
2012-08-17 13:43:35python-devsetnosy: + python-dev
messages: + msg168443
2012-07-26 12:59:39sbtsetmessages: + msg166480
2012-07-26 00:23:11sbtsetnosy: + sbt
2012-07-25 22:51:26ezio.melottisetnosy: + jnoller

stage: needs patch
2012-04-05 12:52:36r.david.murraysetversions: + Python 3.3
nosy: + r.david.murray, asksol

messages: + msg157577

type: crash -> behavior
2012-04-05 06:45:54Draugercreate