( )⚙ D12557 windows: fix stdio with py2exe and py3

This is an archive of the discontinued Mercurial Phabricator instance.

windows: fix stdio with py2exe and py3
Needs ReviewPublic

Authored by mharbison72 on Wed, Apr 13, 6:48 PM.

Details

Reviewers
None
Group Reviewers
hg-reviewers
Summary
  • DO NOT QUEUE THIS **

I have no idea how this is supposed to be fixed for real, but it's likely
related to the comment above where stdout is set about maybe needing a silly
wrapper. PEP 528[1] talks about not assuming the encoding of sys.stdout.buffer,
but I thought the whole point of always using bytes was to avoid encoding.

This hack allows TortoiseHg to work when built with py2exe on py3, by avoiding
this:

#!python
** Mercurial version (6.1.1+hg216.d8b5fd0ab640local20220412).  TortoiseHg version (6.1.1+26-204092cabbee)
** Command: --nofork workbench
** CWD: C:\Users\Administrator\Desktop
** Encoding: cp1252
** Extensions loaded: absorb, strip, tortoisehg.util.configitems
** Python version: 3.9.12 (tags/v3.9.12:b28265d, Mar 23 2022, 23:52:46) [MSC v.1929 64 bit (AMD64)]
** Windows version: sys.getwindowsversion(major=6, minor=2, build=9200, platform=2, service_pack='')
** Processor architecture: x64
** Qt-5.15.2 PyQt-5.15.6 QScintilla-2.13.1
Traceback (most recent call last):
  File "tortoisehg\hgqt\repotab.pyc", line 355, in _onCurrentTabChanged
  File "tortoisehg\hgqt\repotab.pyc", line 406, in _createRepoWidget
  File "tortoisehg\hgqt\repowidget.pyc", line 228, in __init__
  File "tortoisehg\hgqt\repowidget.pyc", line 260, in setupUi
  File "tortoisehg\hgqt\repofilter.pyc", line 264, in __init__
  File "tortoisehg\hgqt\repofilter.pyc", line 554, in refresh
  File "tortoisehg\hgqt\repofilter.pyc", line 491, in _updateBranchFilter
  File "tortoisehg\util\hglib.pyc", line 237, in namedbranches
  File "mercurial\localrepo.pyc", line 2154, in branchmap
  File "mercurial\branchmap.pyc", line 72, in __getitem__
  File "mercurial\branchmap.pyc", line 81, in updatecache
  File "mercurial\repoview.pyc", line 421, in changelog
  File "mercurial\repoview.pyc", line 248, in filterrevs
  File "mercurial\repoview.pyc", line 104, in computehidden
  File "mercurial\repoview.pyc", line 43, in hideablerevs
  File "mercurial\obsolete.pyc", line 911, in getrevs
  File "mercurial\localrepo.pyc", line 118, in __get__
  File "mercurial\scmutil.pyc", line 1709, in __get__
  File "mercurial\localrepo.pyc", line 1723, in obsstore
  File "mercurial\obsolete.pyc", line 817, in makestore
  File "mercurial\ui.pyc", line 1855, in warn
  File "mercurial\ui.pyc", line 1330, in _writemsg
  File "mercurial\ui.pyc", line 2282, in _writemsgwith
  File "mercurial\ui.pyc", line 1273, in _write
  File "mercurial\ui.pyc", line 1298, in _writenobuf
  File "mercurial\windows.pyc", line 240, in write
  File "mercurial\utils\procutil.pyc", line 114, in write
  File "boot_common.py", line 74, in write
TypeError: write() argument must be str, not memoryview

[1] https://peps.python.org/pep-0528/

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage