Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos
Commits
dfe79c77
Commit
dfe79c77
authored
Dec 27, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7e9771cc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
software/ors-amarisoft/ru/xbuildout.py
software/ors-amarisoft/ru/xbuildout.py
+27
-5
No files found.
software/ors-amarisoft/ru/xbuildout.py
View file @
dfe79c77
...
@@ -56,7 +56,7 @@ def decode(s: str): # -> str | ValueError
...
@@ -56,7 +56,7 @@ def decode(s: str): # -> str | ValueError
try
:
try
:
return
_decode
(
s
)
return
_decode
(
s
)
except
Exception
as
e
:
except
Exception
as
e
:
raise
ValueError
(
"
decoding
%r"
%
s
)
from
e
raise
ValueError
(
"
invalid encoding:
%r"
%
s
)
from
e
def
_decode
(
s
):
def
_decode
(
s
):
s
=
s
.
encode
(
'utf-8'
)
s
=
s
.
encode
(
'utf-8'
)
...
@@ -127,7 +127,29 @@ def test_encode():
...
@@ -127,7 +127,29 @@ def test_encode():
assert
encode
(
s
)
==
encok
assert
encode
(
s
)
==
encok
assert
decode
(
encok
)
==
s
assert
decode
(
encok
)
==
s
# decode errors
# XXX decode error
from
pytest
import
raises
# XXX UTF-8 error
def
checkbad
(
x
,
f
):
with
raises
(
ValueError
,
match
=
"invalid encoding"
)
as
exci
:
decode
(
x
)
cause
=
exci
.
value
.
__cause__
f
(
cause
)
for
x
in
(
'_'
,
'_1'
,
'a_2'
):
def
_
(
cause
):
assert
isinstance
(
cause
,
ValueError
)
assert
cause
.
args
==
(
"truncated escape sequence"
,)
checkbad
(
x
,
_
)
for
x
in
(
'_1r'
,
'_r1'
,
'a_xy'
):
def
_
(
cause
):
assert
isinstance
(
cause
,
ValueError
)
assert
len
(
cause
.
args
)
==
1
assert
cause
.
args
[
0
]
.
startswith
(
"invalid literal for int() with base 16:"
)
checkbad
(
x
,
_
)
for
x
in
(
'_c3_28'
,
'_e2_28_a1'
):
def
_
(
cause
):
assert
isinstance
(
cause
,
UnicodeDecodeError
)
checkbad
(
x
,
_
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment