Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
simplejson
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
OpenVMS
Python
Modules
simplejson
Commits
979944bff9b8
Commit
979944bff9b8
authored
11 years ago
by
Bob Ippolito
Browse files
Options
Downloads
Plain Diff
Merge pull request #78 from idank/master
fix pickle breakage with JSONDecodeError
parents
5ab712184623
e54b47446611
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
simplejson/scanner.py
+3
-0
3 additions, 0 deletions
simplejson/scanner.py
simplejson/tests/test_errors.py
+17
-1
17 additions, 1 deletion
simplejson/tests/test_errors.py
with
20 additions
and
1 deletion
simplejson/scanner.py
+
3
−
0
View file @
979944bf
...
...
@@ -41,6 +41,9 @@
else
:
self
.
endlineno
,
self
.
endcolno
=
None
,
None
def
__reduce__
(
self
):
return
self
.
__class__
,
(
self
.
msg
,
self
.
doc
,
self
.
pos
,
self
.
end
)
def
linecol
(
doc
,
pos
):
lineno
=
doc
.
count
(
'
\n
'
,
0
,
pos
)
+
1
...
...
This diff is collapsed.
Click to expand it.
simplejson/tests/test_errors.py
+
17
−
1
View file @
979944bf
import
sys
import
sys
,
pickle
from
unittest
import
TestCase
import
simplejson
as
json
...
...
@@ -33,3 +33,19 @@
self
.
fail
(
'
Expected JSONDecodeError
'
)
self
.
assertEqual
(
err
.
lineno
,
1
)
self
.
assertEqual
(
err
.
colno
,
10
)
def
test_error_is_pickable
(
self
):
err
=
None
try
:
json
.
loads
(
'
{}
\n
a
\n
b
'
)
except
json
.
JSONDecodeError
:
err
=
sys
.
exc_info
()[
1
]
else
:
self
.
fail
(
'
Expected JSONDecodeError
'
)
s
=
pickle
.
dumps
(
err
)
e
=
pickle
.
loads
(
s
)
self
.
assertEquals
(
err
.
msg
,
e
.
msg
)
self
.
assertEquals
(
err
.
doc
,
e
.
doc
)
self
.
assertEquals
(
err
.
pos
,
e
.
pos
)
self
.
assertEquals
(
err
.
end
,
e
.
end
)
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