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.12 support #56

Closed
DX37 opened this issue May 9, 2024 · 8 comments
Closed

Python 3.12 support #56

DX37 opened this issue May 9, 2024 · 8 comments
Assignees
Labels

Comments

@DX37
Copy link
Contributor

DX37 commented May 9, 2024

I'm getting error below with Python 3.12 when running even ydcmd ls command:

/usr/bin/ydcmd:888: SyntaxWarning: invalid escape sequence '\/'
  if re.match('^https:\/\/[a-z0-9\.\-]+\.yandex\.(net|ru|com|ua|by|kz|az|ee|fr|kg|lt|lv|md|tj|tm|com\.tr|co\.il|com\.am)(:443){,1}\/', url, re.IGNORECASE) == None:
/usr/bin/ydcmd:2638: SyntaxWarning: invalid escape sequence '\S'
  regexp = re.compile("^--(\S+?)(=(.*)){,1}$")
Traceback (most recent call last):
  File "/usr/bin/ydcmd", line 2670, in <module>
    yd_ls_cmd(options, args)
  File "/usr/bin/ydcmd", line 1990, in yd_ls_cmd
    result = listvalues(yd_list(options, yd_remote_path(path)))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/ydcmd", line 1107, in yd_list
    part = yd_query(options, method, url, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/ydcmd", line 969, in yd_query
    return yd_query_retry(options, method, url, args, headers, target, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/ydcmd", line 905, in yd_query_retry
    result = opener.open(request, timeout = options.timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 515, in open
    response = self._open(req, data)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 532, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 492, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/bin/ydcmd", line 414, in https_open
    return self.do_open(self._get_connection, req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/urllib/request.py", line 1344, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/usr/bin/ydcmd", line 315, in request
    self._send_request(method, url, body, headers, **kwargs)
  File "/usr/lib/python3.12/http/client.py", line 1382, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.12/http/client.py", line 1331, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/bin/ydcmd", line 371, in _send_output
    self.send(msg)
  File "/usr/bin/ydcmd", line 383, in send
    self.connect()
  File "/usr/bin/ydcmd", line 276, in connect
    if self.cert_file is not None:
       ^^^^^^^^^^^^^^
AttributeError: 'ydHTTPSConnection' object has no attribute 'cert_file'

Please add 3.12 support.

@mal19992
Copy link

same thing, it is broken with python 3.13
ydcmd ls

/usr/bin/ydcmd:888: SyntaxWarning: invalid escape sequence '\/'
  if re.match('^https:\/\/[a-z0-9\.\-]+\.yandex\.(net|ru|com|ua|by|kz|az|ee|fr|kg|lt|lv|md|tj|tm|com\.tr|co\.il|com\.am)(:443){,1}\/', url, re.IGNORECASE) == None:
/usr/bin/ydcmd:2638: SyntaxWarning: invalid escape sequence '\S'
  regexp = re.compile("^--(\S+?)(=(.*)){,1}$")
Traceback (most recent call last):
  File "/usr/bin/ydcmd", line 2670, in <module>
    yd_ls_cmd(options, args)
    ~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/bin/ydcmd", line 1990, in yd_ls_cmd
    result = listvalues(yd_list(options, yd_remote_path(path)))
                        ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/ydcmd", line 1107, in yd_list
    part = yd_query(options, method, url, args)
  File "/usr/bin/ydcmd", line 969, in yd_query
    return yd_query_retry(options, method, url, args, headers, target, data)
  File "/usr/bin/ydcmd", line 905, in yd_query_retry
    result = opener.open(request, timeout = options.timeout)
  File "/usr/lib64/python3.13/urllib/request.py", line 489, in open
    response = self._open(req, data)
  File "/usr/lib64/python3.13/urllib/request.py", line 506, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File "/usr/lib64/python3.13/urllib/request.py", line 466, in _call_chain
    result = func(*args)
  File "/usr/bin/ydcmd", line 414, in https_open
    return self.do_open(self._get_connection, req)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/urllib/request.py", line 1319, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              encode_chunked=req.has_header('Transfer-encoding'))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/ydcmd", line 315, in request
    self._send_request(method, url, body, headers, **kwargs)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/http/client.py", line 1382, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/http/client.py", line 1331, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/bin/ydcmd", line 371, in _send_output
    self.send(msg)
    ~~~~~~~~~^^^^^
  File "/usr/bin/ydcmd", line 383, in send
    self.connect()
    ~~~~~~~~~~~~^^
  File "/usr/bin/ydcmd", line 276, in connect
    if self.cert_file is not None:
       ^^^^^^^^^^^^^^
AttributeError: 'ydHTTPSConnection' object has no attribute 'cert_file'

@mal19992
Copy link

The regex is not a raw string r'\S' and the field cert_file was removed from python ssl API

abbat added a commit that referenced this issue Sep 23, 2024
@abbat
Copy link
Owner

abbat commented Sep 23, 2024

Further reading: https://docs.python.org/3.12/library/http.client.html#http.client.HTTPSConnection

Changed in version 3.4.3: This class now performs all the necessary certificate and hostname checks by default.
Changed in version 3.12: The deprecated key_file, cert_file and check_hostname parameters have been removed.

@abbat abbat added the bug label Sep 23, 2024
@abbat abbat self-assigned this Sep 23, 2024
@mal19992
Copy link

mal19992 commented Sep 23, 2024

наверное лучше написать
re.compile(r"^--(\S+?)(=(.*)){,1}$")
а не \\S
там много такого -- \. и пр. Иначе будет очень много \\. \\Sи пр.

abbat added a commit that referenced this issue Sep 23, 2024
abbat added a commit that referenced this issue Sep 23, 2024
@abbat
Copy link
Owner

abbat commented Sep 23, 2024

@mal19992 Должно заработать (к сожалению python 3.12 под рукой нет, чтобы проверить).

@mal19992
Copy link

виснет, не знаю у меня это проблема с auth или в ydcmd ; подаю
ydcmd --debug --verbose ls
далее очень медленно и долго

--> GET https://cloud-api.yandex.net/v1/disk/resources?path=disk%3A%2F&offset=0&limit=100
--> Connected to cloud-api.yandex.net:443 (TLSv1.3 TLS_AES_256_GCM_SHA384)
--> Retry 1/3: HTTP-401: Unauthorized
--> GET https://cloud-api.yandex.net/v1/disk/resources?path=disk%3A%2F&offset=0&limit=100
--> Connected to cloud-api.yandex.net:443 (TLSv1.3 TLS_AES_256_GCM_SHA384)
--> Retry 2/3: HTTP-401: Unauthorized
--> GET https://cloud-api.yandex.net/v1/disk/resources?path=disk%3A%2F&offset=0&limit=100
--> Connected to cloud-api.yandex.net:443 (TLSv1.3 TLS_AES_256_GCM_SHA384)
--> Retry 3/3: HTTP-401: Unauthorized
HTTP-401: Unauthorized

работает безумно медленно. И ещё то же самое с
ydcmd --debug --verbose info

--> GET https://cloud-api.yandex.net/v1/disk/
--> Connected to cloud-api.yandex.net:443 (TLSv1.3 TLS_AES_256_GCM_SHA384)
--> Retry 1/3: HTTP-401: Unauthorized
--> GET https://cloud-api.yandex.net/v1/disk/
--> Connected to cloud-api.yandex.net:443 (TLSv1.3 TLS_AES_256_GCM_SHA384)
--> Retry 2/3: HTTP-401: Unauthorized
--> GET https://cloud-api.yandex.net/v1/disk/
--> Connected to cloud-api.yandex.net:443 (TLSv1.3 TLS_AES_256_GCM_SHA384)
--> Retry 3/3: HTTP-401: Unauthorized
HTTP-401: Unauthorized

пробовал на двух account-ах, всё то же самое

@abbat
Copy link
Owner

abbat commented Sep 23, 2024

Unauthorized скорее всего говорит о том, что нужно перевыпустить OAuth токен.

@mal19992
Copy link

да, сейчас работает

@abbat abbat closed this as completed Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants