Closed Bug 1738943 Opened 3 years ago Closed 2 years ago

Python 3.10 "PY_SSIZE_T_CLEAN macro must be defined for '#' formats"

Categories

(Developer Services :: General, defect)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mhentges, Unassigned)

References

(Blocks 1 open bug)

Details

To reproduce

  1. Use Python 3.10 (this may be Linux-specific)
  2. Have fsmonitor enabled
  3. hg up central
~/d/firefox % hg up central
** Unknown exception encountered with possibly-broken third-party extension "clang-format" (version N/A)
** which supports versions 5.3 of Mercurial.
** Please disable "clang-format" and try your action again.
** If that fixes the bug please report it to https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox%20Build%20System&component=Lint%20and%20Formatting
** Python 3.10.0 (default, Oct  4 2021, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]
** Mercurial Distributed SCM (version 5.9.3)
** Extensions loaded: absorb, blackbox, clang-format, evolve 10.4.0, firefoxtree, fsmonitor, histedit, js-format, push-to-try, rebase, show
Traceback (most recent call last):
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/__init__.py", line 830, in _state
    self.repo._watchmanclient.command(
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/watchmanclient.py", line 119, in command
    return self._command(*args)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/watchmanclient.py", line 106, in _command
    return self._watchmanclient.query(*watchmanargs)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/pywatchman/__init__.py", line 1156, in query
    self._connect()
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/pywatchman/__init__.py", line 1024, in _connect
    self.sockpath = self._resolvesockname()
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/pywatchman/__init__.py", line 1007, in _resolvesockname
    result = bser.loads(stdout)
SystemError: PY_SSIZE_T_CLEAN macro must be defined for '#' formats

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/commandserver.py", line 499, in _serverequest
    sv.serve()
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/commandserver.py", line 403, in serve
    while self.serveone():
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/commandserver.py", line 377, in serveone
    handler(self)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/chgserver.py", line 583, in runcommand
    return super(chgcmdserver, self).runcommand()
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/commandserver.py", line 358, in runcommand
    ret = self._dispatchcommand(req) & 255
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/commandserver.py", line 297, in _dispatchcommand
    return dispatch.dispatch(req)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/dispatch.py", line 250, in dispatch
    status = _rundispatch(req)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/dispatch.py", line 294, in _rundispatch
    ret = _runcatch(req) or 0
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/dispatch.py", line 470, in _runcatch
    return _callcatch(ui, _runcatchfunc)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/dispatch.py", line 480, in _callcatch
    return scmutil.callcatch(ui, func)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/scmutil.py", line 153, in callcatch
    return func()
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/dispatch.py", line 460, in _runcatchfunc
    return _dispatch(req)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/dispatch.py", line 1273, in _dispatch
    return runcommand(
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/dispatch.py", line 918, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/dispatch.py", line 1285, in _runcommand
    return cmdfunc()
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/dispatch.py", line 1271, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/util.py", line 1886, in check
    return func(*args, **kwargs)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/util.py", line 1886, in check
    return func(*args, **kwargs)
  File "/home/mitch/.mozbuild/evolve/hgext3rd/evolve/__init__.py", line 554, in wrapmayobsoletewc
    res = origfn(ui, repo, *args, **opts)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/util.py", line 1886, in check
    return func(*args, **kwargs)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/commands.py", line 7848, in update
    ret = hg.updatetotally(
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/hg.py", line 1180, in updatetotally
    ret = _update(repo, checkout, updatecheck=updatecheck)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/hg.py", line 1099, in update
    stats = mergemod.update(repo[node], updatecheck=updatecheck)
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/merge.py", line 2196, in update
    return _update(
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/__init__.py", line 890, in wrapupdate
    with state_update(
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/__init__.py", line 788, in __enter__
    self.enter()
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/__init__.py", line 803, in enter
    self.need_leave = self._state(b'state-enter', hex(self.oldnode))
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/hgext/fsmonitor/__init__.py", line 849, in _state
    self.repo.ui.log(
  File "/home/mitch/.local/pipx/venvs/mercurial/lib64/python3.10/site-packages/mercurial/ui.py", line 2126, in log
    msg = msgfmt % msgargs
TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'SystemError'

Workaround

Edit ~/.hgrc and comment-out (#) the fsmonitor = line.

Other details

  • This affects Python 3.10+
  • Mercurial issue is here
  • Root issue is over here

Use Python 3.10 (this may be Linux-specific)

I reproduced this on macOS 11.6.1 today with hg 6.0 and python 3.9.9. The workaround worked for me.

Adding to mach-busted to make it easier to find. It looks like the Mercurial fix has landed but is not currently released.

Blocks: mach-busted

Also, I'm seeing this bustage on Mac across all of our custom extensions. I ended up downgrading Mercurial in homebrew to work around it:

  1. Download an older version of the mercurial definition
  2. Then run:
$ brew uninstall --ignore-dependencies mercurial
$ brew install mercurial.rb
$ brew pin mercurial

The 'pin' stops brew updating mercurial, so don't forget to unpin it once the new version is out.

Seen on Fedora 35 today; Fedora 34 was OK.

This should be solved on Mercurial 6.0.1+, which is working correctly on my machines

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.