Python 2 support in 1.4.7.14
NickG123 opened this issue · comments
Hi there,
I noticed a recent change to the library broke the creation of Secrets in Python 2.7
When I run the following code:
from kubernetes import K8sConfig, K8sSecret
cfg_cert = K8sConfig(kubeconfig=None, api_host="<redacted>", cert=("apiserver.pem", "apiserver-key.pem"))
secret = K8sSecret(config=cfg_cert, name="test")
secret.data = {"test": "test"}
secret.create()
I get the stack trace
Traceback (most recent call last):
File "test.py", line 6, in <module>
secret.create()
File "<redacted>/env/lib/python2.7/site-packages/kubernetes/K8sSecret.py", line 32, in create
super(K8sSecret, self).create()
File "<redacted>/env/lib/python2.7/site-packages/kubernetes/K8sObject.py", line 257, in create
post_data = self.serialize()
File "<redacted>/env/lib/python2.7/site-packages/kubernetes/K8sObject.py", line 160, in serialize
return self.model.serialize()
File "<redacted>/env/lib/python2.7/site-packages/kubernetes/models/v1/Secret.py", line 242, in serialize
v = bytes(v, 'UTF-8')
TypeError: str() takes at most 1 argument (2 given)
The same code works fine in 1.4.7.13.
Are you continuing to support Python 2.7?
Thanks,
Nick
This looks like a regression. Which version of python 2.7 are you using? We've tested on recent versions, 2.7.13 and I think 2.7.10.
Thanks for the quick response.
I am currently running python 2.7.5.
Though I do still see the issue when running Python 2.7.13 in a docker container
Alright, I'm going to try a quick-fix :)
I've tried a fix and added tests mimicking your use case. Seems like it works now. Can you try version 1.4.7.16
please?
Looks great!
Thanks for the quick turnaround.