Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
diffoscope
Manage
Activity
Members
Labels
Plan
Issues
174
Issue boards
Milestones
Wiki
Code
Merge requests
15
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reproducible Builds
diffoscope
Commits
8202dac7
Verified
Commit
8202dac7
authored
6 years ago
by
Mattia Rizzolo
Browse files
Options
Downloads
Patches
Plain Diff
comparators/utils/file: fix handling of filesnames with non-unicode chars
Closes: #898022 Signed-off-by:
Mattia Rizzolo
<
mattia@debian.org
>
parent
45bcf708
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
diffoscope/comparators/utils/file.py
+3
-1
3 additions, 1 deletion
diffoscope/comparators/utils/file.py
tests/test_main.py
+16
-0
16 additions, 0 deletions
tests/test_main.py
with
19 additions
and
1 deletion
diffoscope/comparators/utils/file.py
+
3
−
1
View file @
8202dac7
...
...
@@ -68,7 +68,9 @@ class File(object, metaclass=abc.ABCMeta):
if
not
hasattr
(
self
,
'
_mimedb
'
):
self
.
_mimedb
=
magic
.
open
(
magic
.
NONE
)
self
.
_mimedb
.
load
()
return
self
.
_mimedb
.
file
(
path
)
return
self
.
_mimedb
.
file
(
path
.
encode
(
'
utf-8
'
,
errors
=
'
surrogateescape
'
)
)
@classmethod
def
guess_encoding
(
self
,
path
):
...
...
This diff is collapsed.
Click to expand it.
tests/test_main.py
+
16
−
0
View file @
8202dac7
...
...
@@ -143,3 +143,19 @@ def test_profiling(capsys):
assert
ret
==
0
assert
"
Profiling output for
"
in
out
assert
err
==
''
def
test_non_unicode_filename
(
capsys
,
tmpdir
):
# Bug reference: https://bugs.debian.org/898022
path
=
str
(
tmpdir
.
dirpath
()).
encode
(
'
utf-8
'
)
a
=
os
.
path
.
join
(
path
,
b
'
\xf0\x28\x8c\x28
'
)
b
=
os
.
path
.
join
(
path
,
b
'
\xf0\x28\x8c\x29
'
)
with
open
(
a
,
'
w
'
),
open
(
b
,
'
w
'
):
pass
# sys.argv does pretty much this decoding to arguments
files
=
[
x
.
decode
(
'
utf-8
'
,
errors
=
'
surrogateescape
'
)
for
x
in
(
a
,
b
)]
ret
,
out
,
err
=
run
(
capsys
,
*
files
)
assert
ret
==
0
assert
out
==
err
==
''
This diff is collapsed.
Click to expand it.
Chris Lamb
@lamby
mentioned in issue
#231 (closed)
·
3 years ago
mentioned in issue
#231 (closed)
mentioned in issue #231
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment