Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support assignment #1

Open
Arinerron opened this issue Apr 4, 2020 · 2 comments
Open

support assignment #1

Arinerron opened this issue Apr 4, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@Arinerron
Copy link
Owner

>>> a = smartbytes('asdf')
>>> a[2] = 's'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'smartbytes' object does not support item assignment
@Arinerron Arinerron added the enhancement New feature or request label Apr 4, 2020
@Arinerron Arinerron self-assigned this Apr 4, 2020
@Arinerron
Copy link
Owner Author

>>> list(smartbytes('asfd'))
[b'a', b's', b'f', b'd']
>>> a=list(smartbytes('asfd'))
>>> a[2]=b'asdf'
>>> smartbytes(a)
b'asasdfd'

@Arinerron
Copy link
Owner Author

>>> a[3:4]='d'
warning: cannot convert value slice(0, slic
e(3, 4, None), None) of type <class 'slice'> to bytes
Traceback (most recent call last):
  File "/home/aaron/github/smartbytes/smartbytes/smartbytes.py", line 422, in __getitem__
    return smartbytes(self.get_contents().__getitem__(key, *args, **kwargs))
TypeError: slice indices must be integers or None or have an __index__ method

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/aaron/github/smartbytes/smartbytes/smartbytes.py", line 429, in __setitem__
    self.contents = bytes(self[0:key] + smartbytes(value) + self[key+1+(0 if length == None else length):len(self)])
  File "/home/aaron/github/smartbytes/smartbytes/smartbytes.py", line 425, in __getitem__
    return self.find(key, *args, **kwargs)
  File "/home/aaron/github/smartbytes/smartbytes/smartbytes.py", line 412, in find
    key = smartbytes(key)
  File "/home/aaron/github/smartbytes/smartbytes/smartbytes.py", line 198, in __init__
    self.contents = self._to_bytes(contents)
  File "/home/aaron/github/smartbytes/smartbytes/smartbytes.py", line 224, in _to_bytes
    return to_bytes(value, endian = endian, encoding = encoding)
  File "/home/aaron/github/smartbytes/smartbytes/smartbytes.py", line 72, in to_bytes
    raise TypeError
TypeError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/aaron/github/smartbytes/smartbytes/smartbytes.py", line 432, in __setitem__
    self.__setitem__(self[key], value, length = (len(key) if length == None else length))
TypeError: object of type 'slice' has no len()

Arinerron added a commit that referenced this issue Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant