graham / python_xid

Python Xid Implementation
MIT License
65 stars 25 forks source link

TypeError: 'map' object is not subscriptable #11

Open AdiechaHK opened 3 years ago

AdiechaHK commented 3 years ago

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.

bobby-weifu commented 3 years ago

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

jpf commented 3 years ago

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

ahasha commented 2 years ago

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

silkentrance commented 2 years ago

please publish 1.0.5 on pypi