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

Python 3.9 has removed the deprecated base64.encodestring methods breaking px #116

Closed
szaniec opened this issue Jan 14, 2021 · 6 comments
Closed

Comments

@szaniec
Copy link

szaniec commented Jan 14, 2021

px fails to run using Python 3.9 due to the use of base64.encodestring in lines 317 and 329 of px.py.

Changing these to base64.encodebytes(string) fixes the issue.

@Smixi
Copy link
Contributor

Smixi commented Feb 24, 2021

This PR fix those line: #118

@datadu-de
Copy link

datadu-de commented Jun 24, 2021

Hey, the PR seems to be merged, however I still have the same problem

PS C:\Python39\Scripts> .\px.exe
Serving at :3128 proc MainProcess
Serving at :3128 proc Process-1
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 60455)
Traceback (most recent call last):
  File "c:\python39\lib\site-packages\px.py", line 327, in get_response_sspi
    response_msg = base64.encodebytes(response_msg.encode("utf-8"))
AttributeError: 'bytes' object has no attribute 'encode'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python39\lib\socketserver.py", line 683, in process_request_thread
    self.finish_request(request, client_address)
  File "c:\python39\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "c:\python39\lib\http\server.py", line 653, in __init__
    super().__init__(*args, **kwargs)
  File "c:\python39\lib\socketserver.py", line 747, in __init__
    self.handle()
  File "c:\python39\lib\http\server.py", line 427, in handle
    self.handle_one_request()
  File "c:\python39\lib\site-packages\px.py", line 356, in handle_one_request
    httpserver.SimpleHTTPRequestHandler.handle_one_request(self)
  File "c:\python39\lib\http\server.py", line 415, in handle_one_request
    method()
  File "c:\python39\lib\site-packages\px.py", line 680, in do_GET
    resp = self.do_transaction()
  File "c:\python39\lib\site-packages\px.py", line 601, in do_transaction
    ntlm_resp = ntlm.get_response()
  File "c:\python39\lib\site-packages\px.py", line 329, in get_response_sspi
    response_msg = base64.encodestring(response_msg)
AttributeError: module 'base64' has no attribute 'encodestring'
----------------------------------------

@minecrawler
Copy link

minecrawler commented Jan 25, 2022

Hi, same problem as above. Tested with stable Px (px-proxy-0.4.0) and npm, and npm did not throw any errors, so I am not sure about the severity. It would be great if it did get fixed, though, since I am fed up with CNTLM always crashing and becoming unresponsive and aborting. At least Px works through one npm update with just a few errors popping up...

> px                                                                                                 
Serving at 127.0.0.1:3128 proc MainProcess
Serving at 127.0.0.1:3128 proc Process-1
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 65010)
Traceback (most recent call last):
  File "c:\python39\lib\site-packages\px.py", line 327, in get_response_sspi
    response_msg = base64.encodebytes(response_msg.encode("utf-8"))
AttributeError: 'bytes' object has no attribute 'encode'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python39\lib\socketserver.py", line 683, in process_request_thread
    self.finish_request(request, client_address)
  File "c:\python39\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "c:\python39\lib\http\server.py", line 653, in __init__
    super().__init__(*args, **kwargs)
  File "c:\python39\lib\socketserver.py", line 747, in __init__
    self.handle()
  File "c:\python39\lib\http\server.py", line 427, in handle
    self.handle_one_request()
  File "c:\python39\lib\site-packages\px.py", line 356, in handle_one_request
    httpserver.SimpleHTTPRequestHandler.handle_one_request(self)
  File "c:\python39\lib\http\server.py", line 415, in handle_one_request
    method()
  File "c:\python39\lib\site-packages\px.py", line 723, in do_CONNECT
    resp = self.do_transaction()
  File "c:\python39\lib\site-packages\px.py", line 601, in do_transaction
    ntlm_resp = ntlm.get_response()
  File "c:\python39\lib\site-packages\px.py", line 329, in get_response_sspi
    response_msg = base64.encodestring(response_msg)
AttributeError: module 'base64' has no attribute 'encodestring'
----------------------------------------

This error just keeps spamming in the console, but Px stays responsive...

@genotrance
Copy link
Owner

Are you using a release binary downloaded from here? They are super old (2019) and recent PRs are not present. Can you retry with #head?

@minecrawler
Copy link

@genotrance

Are you using a release binary downloaded from here?

Yes, I followed the instructions for a stable installation using pip. I want to use Px for my work PC, hence prefer stable builds to get the job done. If it's so old and fixes are just waiting/waisting, maybe it's time for a new release? :)

Can you retry with #head?

I installed from git, and this time there are no errors when running npm. Thank you for your fast response!

@Smixi
Copy link
Contributor

Smixi commented Jan 25, 2022

Well yeah, it seems binary are from 2019

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

5 participants