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

TypeError: startswith first arg must be bytes or a tuple of bytes, not str #23

Closed
manwe-pl opened this issue Oct 17, 2017 · 4 comments
Closed

Comments

@manwe-pl
Copy link

Traceback (most recent call last):
  File "./roca-detect", line 11, in <module>
    load_entry_point('roca-detect==1.0.5', 'console_scripts', 'roca-detect')()
  File "/home/xxxxx/.local/lib64/python3.4/site-packages/roca/detect.py", line 1782, in main
    app.mainxxxxx
  File "/home/xxxxx/.local/lib64/python3.4/site-packages/roca/detect.py", line 1777, in main
    self.work()
  File "/home/xxxxx/.local/lib64/python3.4/site-packages/roca/detect.py", line 1675, in work
    ret = self.process_inputs()
  File "/home/xxxxx/.local/lib64/python3.4/site-packages/roca/detect.py", line 691, in process_inputs
    sub = self.process_file(data, fname)
  File "/home/xxxxx/.local/lib64/python3.4/site-packages/roca/detect.py", line 779, in process_file
    ret.append(self.process_pkcs7(data, name))
  File "/home/xxxxx/.local/lib64/python3.4/site-packages/roca/detect.py", line 1605, in process_pkcs7
    is_pem = data.startswith('-----')
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

I've tried changing data.startswith('-----') to data.startswith(b'-----'), but got another error:

  File "/home/xxxxx/.local/lib64/python3.4/site-packages/roca/detect.py", line 1606, in process_pkcs7
    if re.match(r'^[a-zA-Z0-9-\s+=/]+$', data):
  File "/usr/lib64/python3.4/re.py", line 160, in match
    return _compile(pattern, flags).match(string)
TypeError: can't use a string pattern on a bytes-like object
@nealmcb
Copy link

nealmcb commented Oct 17, 2017

The current code works with Python 2.7.13. Not with 2.7.6, or with Python 3.
The README.md shows how to use Docker, or pyenv to get 2.7.13 (or any other Python version).

Getting it working with Python 3 is an important enhancement request.

@manwe-pl
Copy link
Author

manwe-pl commented Oct 17, 2017

README.md states It won't work with lower Python version., so I've used my system's default 3.4. But OK, I've changed it to pip2.7 install and it works fine now. Thank you.

@ph4r05
Copy link
Member

ph4r05 commented Oct 17, 2017

I agree py3 compatibility is imporant feature request! :)

@eli-schwartz
Copy link

What.

Why does the setup.py list the classifiers:

        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.3',
        'Programming Language :: Python :: 3.4',
        'Programming Language :: Python :: 3.5',

If none of that is actually true?

It is the easiest way to quickly check which version of python something is meant for. 😞

Also setuptools allows you to mark which versions of python are compatible...

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

4 participants