Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
Weblate
gajim
Commits
a4bab043
Commit
a4bab043
authored
16 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
[avm] Gzip don't support unicode strings. Fixes #4254
parent
9adc632d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/logger.py
+13
-4
13 additions, 4 deletions
src/common/logger.py
with
13 additions
and
4 deletions
src/common/logger.py
+
13
−
4
View file @
a4bab043
...
...
@@ -707,21 +707,26 @@ class Logger:
# get data from table
# the data field contains binary object (gzipped data), this is a hack
# to get that data without trying to convert it to unicode
#tmp, self.con.text_factory = self.con.text_factory, str
try
:
self
.
cur
.
execute
(
'
SELECT hash_method, hash, data FROM caps_cache;
'
);
except
sqlite
.
OperationalError
:
# might happen when there's no caps_cache table yet
# -- there's no data to read anyway then
#self.con.text_factory = tmp
return
#self.con.text_factory = tmp
# list of corrupted entries that will be removed
to_be_removed
=
[]
for
hash_method
,
hash
,
data
in
self
.
cur
:
# for each row: unpack the data field
# (format: (category, type, name, category, type, name, ...
# ..., 'FEAT', feature1, feature2, ...).join(' '))
# NOTE: if there's a need to do more gzip, put that to a function
data
=
GzipFile
(
fileobj
=
StringIO
(
str
(
data
))).
read
().
split
(
'
\0
'
)
try
:
data
=
GzipFile
(
fileobj
=
StringIO
(
str
(
data
))).
read
().
split
(
'
\0
'
)
except
IOError
:
# This data is corrupted. It probably contains non-ascii chars
to_be_removed
.
append
((
hash_method
,
hash
))
continue
i
=
0
identities
=
list
()
features
=
list
()
...
...
@@ -740,6 +745,9 @@ class Logger:
# yield the row
yield
hash_method
,
hash
,
identities
,
features
for
hash_method
,
hash
in
to_be_removed
:
sql
=
'
DELETE FROM caps_cache WHERE hash_method =
"
%s
"
AND hash =
"
%s
"'
%
(
hash_method
,
hash
)
self
.
simple_commit
(
sql
)
def
add_caps_entry
(
self
,
hash_method
,
hash
,
identities
,
features
):
data
=
[]
...
...
@@ -755,6 +763,7 @@ class Logger:
# if there's a need to do more gzip, put that to a function
string
=
StringIO
()
gzip
=
GzipFile
(
fileobj
=
string
,
mode
=
'
w
'
)
data
=
str
(
data
)
# the gzip module can't handle unicode objects
gzip
.
write
(
data
)
gzip
.
close
()
data
=
string
.
getvalue
()
...
...
This diff is collapsed.
Click to expand it.
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