Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
69fb6219
authored
Oct 20, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-338' into 'master'
Fix UnicodeDecodeError in activitycontextimpl() See merge request !252
parents
228a7316
14ea8857
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletions
+29
-1
circle/common/models.py
+9
-1
circle/common/tests/test_models.py
+20
-0
No files found.
circle/common/models.py
View file @
69fb6219
...
@@ -49,7 +49,15 @@ class WorkerNotFound(Exception):
...
@@ -49,7 +49,15 @@ class WorkerNotFound(Exception):
pass
pass
def
get_error_msg
(
exception
):
try
:
return
unicode
(
exception
)
except
UnicodeDecodeError
:
return
unicode
(
str
(
exception
),
encoding
=
'utf-8'
,
errors
=
'replace'
)
def
activitycontextimpl
(
act
,
on_abort
=
None
,
on_commit
=
None
):
def
activitycontextimpl
(
act
,
on_abort
=
None
,
on_commit
=
None
):
result
=
None
try
:
try
:
try
:
try
:
yield
act
yield
act
...
@@ -62,7 +70,7 @@ def activitycontextimpl(act, on_abort=None, on_commit=None):
...
@@ -62,7 +70,7 @@ def activitycontextimpl(act, on_abort=None, on_commit=None):
result
=
create_readable
(
result
=
create_readable
(
ugettext_noop
(
"Failure."
),
ugettext_noop
(
"Failure."
),
ugettext_noop
(
"Unhandled exception:
%(error)
s"
),
ugettext_noop
(
"Unhandled exception:
%(error)
s"
),
error
=
unicode
(
e
))
error
=
get_error_msg
(
e
))
raise
raise
except
:
except
:
logger
.
exception
(
"Failed activity
%
s"
%
unicode
(
act
))
logger
.
exception
(
"Failed activity
%
s"
%
unicode
(
act
))
...
...
circle/common/tests/test_models.py
View file @
69fb6219
...
@@ -22,6 +22,7 @@ from mock import MagicMock
...
@@ -22,6 +22,7 @@ from mock import MagicMock
from
.models
import
TestClass
from
.models
import
TestClass
from
..models
import
HumanSortField
from
..models
import
HumanSortField
from
..models
import
activitycontextimpl
class
MethodCacheTestCase
(
TestCase
):
class
MethodCacheTestCase
(
TestCase
):
...
@@ -80,3 +81,22 @@ class TestHumanSortField(TestCase):
...
@@ -80,3 +81,22 @@ class TestHumanSortField(TestCase):
test_result
=
HumanSortField
.
get_normalized_value
(
obj
,
val
)
test_result
=
HumanSortField
.
get_normalized_value
(
obj
,
val
)
self
.
assertEquals
(
test_result
,
result
)
self
.
assertEquals
(
test_result
,
result
)
class
ActivityContextTestCase
(
TestCase
):
class
MyException
(
Exception
):
pass
def
test_unicode
(
self
):
act
=
MagicMock
()
gen
=
activitycontextimpl
(
act
)
gen
.
next
()
with
self
.
assertRaises
(
self
.
MyException
):
gen
.
throw
(
self
.
MyException
(
u'test
\xe1
'
))
def
test_str
(
self
):
act
=
MagicMock
()
gen
=
activitycontextimpl
(
act
)
gen
.
next
()
with
self
.
assertRaises
(
self
.
MyException
):
gen
.
throw
(
self
.
MyException
(
'test
\xbe
'
))
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