Mercurial stopped working after migrating from Python 2 to Python 3 (Note)

Mercurial stopped working after migrating from Python 2 to Python 3 (Note)

Mercurial's Python 2 support is likely to drop too soon, so I built Python 3.8 and then migrated to it, and it got stuck and fixed.

The original index.cgi looks like this, and if I rewrite this python to python3, 500: Internal Server Error.

#!/home/xxxx/local/bin/python

from mercurial import hgweb
from cgitb import enable
enable()
hgweb.hgweb("/home/xxxx/hg", "xxxx-hg").run()

Looking at the Apache error log, Response header name'<!-' Contains invalid characters, aborting request. It seems that cgitb is bad, so if you drop it, a stack trace will be output to the Apache error log. The error message for Mercurial only supports encoded strings is no, and hgweb.hgweb ("/ home / xxxx / hg" .encode ('utf-8'), "xxxx-hg" Rewrite to ".encode ('utf-8')). run () and check the operation.

If you think about it, you don't need to encode it, and the final source code is settled below.

#!/home/xxxx/local/bin/python3

from mercurial.hgweb import hgweb

hgweb(b"/home/xxxx/hg", b"xxxx-hg").run()

Related: Python 3 was strayly built on Sakura's rental server (memorial)

Recommended Posts

Mercurial stopped working after migrating from Python 2 to Python 3 (Note)
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Note to daemonize python
Post from Python to Slack
Migrating from Chainer v1 to Chainer v2
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Connect to sqlite from python
Call Matlab from Python to optimize
Create folders from '01' to '12' with python
Post from python to facebook timeline
[Lambda] [Python] Post to Twitter from Lambda!
Things to note when running Python on EC2 from AWS Lambda
Python (from first time to execution)
Post images from Python to Tumblr
Selenium stopped working after updating Firefox
How to access wikipedia from python
Python to switch from another language
[Note] AI / machine learning / python related websites [updated from time to time]
Did not change from Python 2 to 3
Update Python on Mac from 2 to 3
[Note] Get data from PostgreSQL with Python
[Note] [PyTorch] From installation to easy usage
How to update Google Sheets from Python
Send a message from Python to Slack
Private Python handbook (updated from time to time)
Note for Pyjulia calling Julia from Python
I want to use jar from python
Convert from katakana to vowel kana [python]
Push notification from Python server to Android
Working with Azure CosmosDB from Python Part.2
Connecting from python to MySQL on CentOS 6.4
Porting and modifying doublet-solver from python2 to python3.
Trying to handle SQLite3 with Python [Note]
Python> Output numbers from 1 to 100, 501 to 600> For csv
Convert from Markdown to HTML in Python
[Amazon Linux] Switching from Python 2 series to Python 3 series
[Note] Execute Python code from Excel (xlwings)
API explanation to touch mastodon from python
Connect to coincheck's Websocket API from Python
Organize the flow from granting permissions to python users to make migrations and migrating
Note: Python
Python note
Send a message from Slack to a Python server
Edit Excel from Python to create a PivotTable
How to open a web browser from python
Study from Python Hour7: How to use classes
[Python] Convert from DICOM to PNG or CSV
Import Excel file from Python (register to DB)
I want to email from Gmail using Python.
[Python] I want to manage 7DaysToDie from Discord! 1/3
From file to graph drawing in Python. Elementary elementary
[Python] How to read data from CIFAR-10 and CIFAR-100
Points to note when switching from NAOqi OS 2.4.3 to 2.5.5
[python] Create table from pandas DataFrame to postgres
[Bash] Use here-documents to get python power from bash
How to generate a Python object from JSON
How to handle Linux commands well from Python
Python Note: When assigning a value to a string
I want to use ceres solver from python
What I did when updating from Python 2.6 to 2.7