Skip to content

Commit cec853d

Browse files
*.md: Fix errors parsing the Markdown README/documentation files
Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent 5c90c00 commit cec853d

File tree

2 files changed

+15
-48
lines changed

2 files changed

+15
-48
lines changed

README-Unicode.md

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Python3 Unicode migration in the XCP package
1+
# Unicode migration
22

33
## Problem
44

@@ -79,7 +79,7 @@ When this is known to be the case, `encoding="iso-8859-1` could be tried (not te
7979
With the locale set to C (XAPI plugins have that), Python's default mode changes
8080
between 3.6 and 3.7:
8181

82-
```py
82+
```sh
8383
for i in 3.{6,7,10,11};do echo -n "3.$i: ";
8484
LC_ALL=C python3.$i -c 'import locale,sys;print(locale.getpreferredencoding())';done
8585
3.6: ANSI_X3.4-1968
@@ -90,9 +90,12 @@ for i in 3.{6,7,10,11};do echo -n "3.$i: ";
9090

9191
This has the effect that in Python 3.6, the default codec for XAPI plugins is `ascii`:
9292

93-
```py
93+
```sh
9494
for i in 2.7 3.{6,7};do echo "$i:";
9595
LC_ALL=C python$i -c 'open("/usr/share/hwdata/pci.ids").read()';done
96+
```
97+
98+
```
9699
2.7:
97100
3.6:
98101
Traceback (most recent call last):
@@ -111,54 +114,18 @@ While Python 3.7 and newer use UTF-8 mode by default, it does not set up an erro
111114

112115
As it happens, some older tools output ISO-8859-1 characters hard-coded and these aren't valid UTF-8 sequences, and even newer Python versions need error handlers to not fail:
113116

114-
```py
117+
```sh
115118
echo -e "\0262" # ISO-8859-1 for: "²"
116119
python3 -c 'open(".text").read()'
120+
```
121+
122+
```
117123
Traceback (most recent call last):
118124
File "<string>", line 1, in <module>
119125
File "<frozen codecs>", line 322, in decode
120126
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 0: invalid start byte
121127
```
122128

123-
```py
124-
pylint -d all -e unspecified-encoding --msg-template="{path} line {line} in {obj}()" xcp/ tests/
125-
************* Module xcp.accessor
126-
xcp/accessor.py line 165 in MountingAccessor.writeFile()
127-
xcp/accessor.py line 240 in FileAccessor.writeFile()
128-
************* Module xcp.bootloader
129-
xcp/bootloader.py line 111 in Bootloader.readExtLinux()
130-
xcp/bootloader.py line 219 in Bootloader.readGrub()
131-
xcp/bootloader.py line 335 in Bootloader.readGrub2()
132-
xcp/bootloader.py line 465 in Bootloader.writeExtLinux()
133-
xcp/bootloader.py line 507 in Bootloader.writeGrub()
134-
xcp/bootloader.py line 541 in Bootloader.writeGrub2()
135-
************* Module xcp.cmd
136-
xcp/cmd.py line 67 in OutputCache.fileContents()
137-
************* Module xcp.dom0
138-
xcp/dom0.py line 85 in default_memory()
139-
************* Module xcp.environ
140-
xcp/environ.py line 48 in readInventory()
141-
************* Module xcp.logger
142-
xcp/logger.py line 51 in openLog()
143-
************* Module xcp.net.ifrename.dynamic
144-
xcp/net/ifrename/dynamic.py line 95 in DynamicRules.load_and_parse()
145-
xcp/net/ifrename/dynamic.py line 292 in DynamicRules.save()
146-
************* Module xcp.net.ifrename.static
147-
xcp/net/ifrename/static.py line 118 in StaticRules.load_and_parse()
148-
xcp/net/ifrename/static.py line 330 in StaticRules.save()
149-
************* Module tests.test_biosdevname
150-
tests/test_biosdevname.py line 30 in TestDeviceNames.test()
151-
tests/test_biosdevname.py line 32 in TestDeviceNames.test()
152-
************* Module tests.test_bootloader
153-
tests/test_bootloader.py line 32 in TestLinuxBootloader.setUp()
154-
tests/test_bootloader.py line 34 in TestLinuxBootloader.setUp()
155-
tests/test_bootloader.py line 36 in TestLinuxBootloader.setUp()
156-
tests/test_bootloader.py line 38 in TestLinuxBootloader.setUp()
157-
************* Module tests.test_pci
158-
tests/test_pci.py line 96 in TestPCIIds.test_videoclass_by_mock_calls()
159-
tests/test_pci.py line 110 in TestPCIIds.mock_lspci_using_open_testfile()
160-
```
161-
162129
Of course, `xcp/net/ifrename` won't be affected but it would be good to fix the
163130
warning for them as well in an intelligent way. See the proposal for that below.
164131

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ open a recent workflow run the latest and scroll down until you see the tables!
5454

5555
## Installation and setup of the development environment
5656

57-
For the installation of the general development dependencies, visit [CONTRIBUTING.md](CONTRIBUTING.md)
57+
For the installation of the general development dependencies, visit [CONTRIBUTING.md]
5858

5959
## Static analysis using mypy, pylint, pyright and pytype
6060

@@ -106,15 +106,15 @@ As proof, these examples show how the comment below triggers the checks:
106106

107107
mypy:
108108

109-
```py
109+
```sh
110110
$ mypy xcp/xmlunwrap.py
111111
xcp/xmlunwrap.py:31: error: Name "Element" is not defined
112112
xcp/xmlunwrap.py:38: error: Incompatible return value type (got "bytes", expected "str")
113113
```
114114

115115
pyright (used by VS Code by default):
116116

117-
```py
117+
```sh
118118
$ pyright xcp/xmlunwrap.py|sed "s|$PWD/||"
119119
...
120120
pyright 1.1.295
@@ -135,7 +135,7 @@ See <https://github.com/xenserver/python-libs/pull/23> for the context of this e
135135
## Guidelines
136136

137137
Charset encoding/string handling:
138-
See [README-Unicode.md](README-Unicode.md) for details on Unicode support.
138+
See [README-Unicode.md] for details on Unicode support.
139139

140140
## Users
141141

@@ -168,7 +168,7 @@ See [README-Unicode.md](README-Unicode.md) for details on Unicode support.
168168

169169
Verification:
170170

171-
```ps
171+
```py
172172
# rpm -qf $(grep -r import /usr/libexec/ /usr/bin /etc/xapi.d/ /opt/xensource/|grep xcp|cut -d: -f1|grep -v Binary) --qf '%{name}\n'|sort -u|tee xcp-python-libs-importers.txt
173173
host-upgrade-plugin
174174
interface-rename

0 commit comments

Comments
 (0)