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

unsupported operand type(s) for &: 'str' and 'int' #4

Open
alex2304 opened this issue Mar 25, 2019 · 7 comments
Open

unsupported operand type(s) for &: 'str' and 'int' #4

alex2304 opened this issue Mar 25, 2019 · 7 comments

Comments

@alex2304
Copy link

Hi!
I've tried to run example from the README file, but it fails with the following:

  File "../lib/python3.6/site-packages/twisted/python/log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "../lib/python3.6/site-packages/twisted/python/log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "../lib/python3.6/site-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "../lib/python3.6/site-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "../lib/python3.6/site-packages/twisted/internet/selectreactor.py", line 149, in _doReadOrWrite
    why = getattr(selectable, method)()
  File "../lib/python3.6/site-packages/twisted/internet/tcp.py", line 243, in doRead
    return self._dataReceived(data)
  File "../lib/python3.6/site-packages/twisted/internet/tcp.py", line 249, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "../recognition/pyVNC/rfb.py", line 494, in dataReceived
    self._handler()
  File "../recognition/pyVNC/rfb.py", line 504, in _handle_expected
    self._expected_handler(block, *self._expected_args, **self._expected_kwargs)
  File "../recognition/pyVNC/rfb.py", line 163, in _handle_vnc_auth
    self.vnc_request_password()
  File "../recognition/pyVNC/RFBToGUI.py", line 45, in vnc_request_password
    self.send_password(self.factory.password)
  File "../recognition/pyVNC/rfb.py", line 169, in send_password
    des = RFBDes(pw)
  File "../recognition/pyVNC/pyDes.py", line 410, in __init__
    self.setKey(key)
  File "../recognition/pyVNC/rfb.py", line 649, in setKey
    super(RFBDes, self).setKey(newkey)
  File "../recognition/pyVNC/pyDes.py", line 415, in setKey
    self.__create_sub_keys()
  File "../recognition/pyVNC/pyDes.py", line 463, in __create_sub_keys
    key = self.__permutate(des.__pc1, self.__String_to_BitList(self.getKey()))
  File "../recognition/pyVNC/pyDes.py", line 429, in __String_to_BitList
    if ch & (1 << i) != 0:
builtins.TypeError: unsupported operand type(s) for &: 'str' and 'int'```

Are you going to support the library furthermore?
@nubonics
Copy link

nubonics commented May 1, 2020

ye...still does it...idk whats causing it tho...

@perara
Copy link
Member

perara commented May 5, 2020

I'll check this out. Sorry for the delay.

@perara
Copy link
Member

perara commented May 5, 2020

Could you paste me a bit of code of your example @alex2304 ?
pref the function at: File "../recognition/pyVNC/rfb.py", line 494, i

@DaneelOlivaw1
Copy link

Same question

1 similar comment
@luoruofeng
Copy link

Same question

@victorlapshev
Copy link

Same

@scomari
Copy link

scomari commented Nov 27, 2023

In my case, I solved it by adding following line at line 429 in pyDes.py:
ch = ch if isinstance(ch, int) else ord(ch)
ch sometimes is an int and sometimes is a str, with this instruction you correctly cast it for the logical operation in the next line.

scomari added a commit to scomari/pyVNC that referenced this issue Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants