python_xid icon indicating copy to clipboard operation
python_xid copied to clipboard

TypeError: 'map' object is not subscriptable

Open AdiechaHK opened this issue 4 years ago • 4 comments

I've simply install xid using command pip install xid then created a simple file to check if it's working fine or not. first.py

from xid import Xid
guid = Xid()
print(guid.string())

and then run it as below, but could not run and getting the exception as below.

root@f0b2d7f8a449:/demo# python first.py 
Traceback (most recent call last):
  File "first.py", line 2, in <module>
    guid = Xid()
  File "/usr/local/lib/python3.8/site-packages/xid.py", line 92, in __init__
    id = generate_new_xid()
  File "/usr/local/lib/python3.8/site-packages/xid.py", line 71, in generate_new_xid
    id[4] = machineID[0]
TypeError: 'map' object is not subscriptable
root@f0b2d7f8a449:/demo# 

If any one can check and help me to fix this issue would be great. tx.

AdiechaHK avatar Dec 14 '20 08:12 AdiechaHK

Sorry, I used Python3.6.8, I also get map error in my project, maybe this package doesn't support Py3 very well ?

bobby-weifu avatar Jan 26 '21 04:01 bobby-weifu

This is an issue related to Python3. It seems to stem from some differences in how map() behaves in Python3, for example, I was able to make some progress getting the code working by replacing map(ord, buf) with [i for i in buf] ... though it does look like the version here in GitHub uses list(map(ord, buf))

In any event, I gave up trying to get a patch working and ended up using this instead: https://github.com/alexferl/xid

jpf avatar Mar 12 '21 06:03 jpf

This is fixed in 1.0.5 here on GitHub, but the version in pypi (1.0.4) still has the issue.

ahasha avatar Sep 29 '21 15:09 ahasha

please publish 1.0.5 on pypi

silkentrance avatar Jan 21 '22 23:01 silkentrance