Skip to content
Snippets Groups Projects
  1. May 31, 2022
  2. May 29, 2022
  3. May 31, 2022
    • Manuel Jacob's avatar
      zeroconf: constant-fold a `pycompat.ispy3` · e3143ab9
      Manuel Jacob authored
      I’ve checked that both bytes and str gets passed as the `name` parameter, so
      the rest of the condition is still required. Because there aren’t really any
      tests for the extensions, I didn’t want to refactor it to pass a single type.
      e3143ab9
  4. May 30, 2022
  5. May 29, 2022
  6. May 30, 2022
  7. May 29, 2022
  8. May 28, 2022
    • Manuel Jacob's avatar
      thirdparty: remove Python 2-specific selectors2 copy · 311fcc5a
      Manuel Jacob authored
      The selectors module was added in Python 3.4. Because we require Python 3.6, it
      will always be available. Therefore the selectors2 module is not imported.
      
      I’ve verified that the selectors2-specific workaround in commandserver.py is not
      necessary with the selectors module from the standard library. It returns an
      empty list if timeout was exceeded.
      
      The pytype directive was needed to silence the following error:
      
      File "/tmp/mercurial-ci/mercurial/worker.py", line 299, in _posixworker: No attribute 'close' on int [attribute-error]
        In Union[_typeshed.HasFileno, int]
      File "/tmp/mercurial-ci/mercurial/worker.py", line 299, in _posixworker: No attribute 'close' on _typeshed.HasFileno [attribute-error]
        In Union[_typeshed.HasFileno, int]
      311fcc5a
  9. Jun 08, 2022
  10. Jun 04, 2022
    • Manuel Jacob's avatar
      url: raise error if CONNECT request to proxy was unsuccessful · 51b07ac1
      Manuel Jacob authored
      The deleted code didn’t work on Python 3. On Python 2 (or Python 3 after
      adapting it), the function returned in the error case. The subsequent creation
      of SSL socket fails during handshake with a nonsense error.
      
      Instead, the user should get an error of what went wrong.
      
      I don’t see how the deleted code would be useful in the error case. The new
      code is also closer of what the standard library is doing nowadays that it has
      proxy support (which we don’t use in the moment).
      
      In the test, I use port 0 because all the HGPORTs were already taken. In
      practice, there should not be any server listening on port 0.
      51b07ac1
  11. Jun 03, 2022
  12. Jun 02, 2022
    • Manuel Jacob's avatar
      chg: replace mercurial.util.recvfds() by simpler pure Python implementation · c6a32435
      Manuel Jacob authored
      On Python 3, we have socket.socket.recvmsg(). This makes it possible to receive
      FDs in pure Python code. The new code behaves like the previous
      implementations, except that it’s more strict about the format of the ancillary
      data. This works because we know in which format the FDs are passed.
      
      Because the code is (and always has been) specific to chg (payload is 1 byte,
      number of passed FDs is limited) and we now have only one implementation and
      the code is very short, I decided to stop exposing a function in
      mercurial.util.
      
      Note on terminology: The SCM_RIGHTS mechanism is used to share open file
      descriptions to another process over a socket. The sending side passes an array
      of file descriptors and the receiving side receives an array of file
      descriptors. The file descriptors are different in general on both sides but
      refer to the same open file descriptions. The two terms are often conflated,
      even in the official documentation. That’s why I used “FD” above, which could
      mean both “file descriptor” and “file description”.
      c6a32435
    • Manuel Jacob's avatar
      py3: don’t subscript socket.error · b5fe10b3
      Manuel Jacob authored
      On Python 2, socket.error was subscriptable. On Python 3, socket.error is an
      alias to OSError and is not subscriptable. The except block passes the
      exception to self.send_error(). This fails on both Python 2 (if it was
      executed) and Python 3, as it expects a string.
      
      Getting the attribute .strerror works on Python 2 and Python 3, and has the
      same effect as the previous code on Python 2.
      b5fe10b3
  13. Jun 06, 2022
    • Anton Shestakov's avatar
      parsers: drop one extra argument to PyErr_Format · 34020d1f
      Anton Shestakov authored
      GCC gave the following warning during `make local`:
      
      mercurial/cext/parsers.c: In function 'dirstate_item_from_v1_data':
      mercurial/cext/parsers.c:413:30: warning: too many arguments for format [-Wformat-extra-args]
        413 |                              "unknown state: `%c` (%d, %d, %d)", state, mode,
            |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      To reproduce, you might need to add the -Wformat-extra-args flag, because it
      isn't present for me when building for the default python3. But I can see this
      warning while simply building 6.1 with `make PYTHON=python2 clean local`.
      
      I don't think this NULL was useful, because other instances of PyErr_Format()
      don't have any NULLs as the final argument, but keep in mind that I don't know
      python's C API.
      34020d1f
  14. Jun 02, 2022
  15. Jun 03, 2022
  16. May 22, 2022
    • Manuel Jacob's avatar
      worker: avoid potential partial write of pickled data · 395f2806
      Manuel Jacob authored
      Previously, the code wrote the pickled data using os.write(). However,
      os.write() can write less bytes than passed to it. To trigger the problem, the
      pickled data had to be larger than 2147479552 bytes on my system.
      
      Instead, open a file object and pass it to pickle.dump(). This also has the
      advantage that it doesn’t buffer the whole pickled data in memory.
      
      Note that the opened file must be buffered because pickle doesn’t support
      unbuffered streams because unbuffered streams’ write() method might write less
      bytes than passed to it (like os.write()) but pickle.dump() relies on that all
      bytes are written (see https://github.com/python/cpython/issues/93050).
      
      The side effect of using a file object and a with statement is that wfd is
      explicitly closed now while it seems like before it was implicitly closed by
      process exit.
      395f2806
  17. Jun 01, 2022
  18. May 31, 2022
Loading