Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
orjson
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
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
orjson
Commits
f862b8a9a814
Commit
f862b8a9a814
authored
4 years ago
by
ijl
Browse files
Options
Downloads
Patches
Plain Diff
Simplify default fallthrough
parent
eeefbc0e7566
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/serialize/default.rs
+1
-6
1 addition, 6 deletions
src/serialize/default.rs
src/serialize/uuid.rs
+1
-1
1 addition, 1 deletion
src/serialize/uuid.rs
test/requirements.txt
+1
-1
1 addition, 1 deletion
test/requirements.txt
test/test_default.py
+13
-0
13 additions, 0 deletions
test/test_default.py
with
16 additions
and
8 deletions
src/serialize/default.rs
+
1
−
6
View file @
f862b8a9
...
...
@@ -56,8 +56,8 @@
self
.ptr
,
std
::
ptr
::
null_mut
()
as
*
mut
pyo3
::
ffi
::
PyObject
));
if
default_obj
.is_null
()
{
if
unlikely!
(
default_obj
.is_null
()
)
{
err!
(
format_args!
(
"Type is not JSON serializable: {}"
,
obj_name!
(
ob_type!
(
self
.ptr
))
))
...
...
@@ -60,12 +60,7 @@
err!
(
format_args!
(
"Type is not JSON serializable: {}"
,
obj_name!
(
ob_type!
(
self
.ptr
))
))
}
else
if
!
ffi!
(
PyErr_Occurred
())
.is_null
()
{
err!
(
format_args!
(
"Type raised exception in default function: {}"
,
obj_name!
(
ob_type!
(
self
.ptr
))
))
}
else
{
let
res
=
SerializePyObject
::
new
(
default_obj
,
...
...
This diff is collapsed.
Click to expand it.
src/serialize/uuid.rs
+
1
−
1
View file @
f862b8a9
...
...
@@ -27,7 +27,7 @@
// test_uuid_overflow
pyo3
::
ffi
::
_PyLong_AsByteArray
(
py_int
as
*
mut
pyo3
::
ffi
::
PyLongObject
,
buffer
.as_ptr
()
as
*
cons
t
c_uchar
,
buffer
.as_ptr
()
as
*
mu
t
c_uchar
,
16
,
1
,
// little_endian
0
,
// is_signed
...
...
This diff is collapsed.
Click to expand it.
test/requirements.txt
+
1
−
1
View file @
f862b8a9
arrow
dataclasses;python_version<"3.7"
numpy;platform_machine=="x86_64" and python_version<"3.9"
pendulum;sys_platform=="linux" and
python_version<"3.9" and
platform_machine=="x86_64"
pendulum;sys_platform=="linux" and platform_machine=="x86_64"
psutil
pytest
pytz
...
...
This diff is collapsed.
Click to expand it.
test/test_default.py
+
13
−
0
View file @
f862b8a9
...
...
@@ -26,6 +26,10 @@
return
obj
.
cur
def
default_raises
(
obj
):
raise
TypeError
class
TypeTests
(
unittest
.
TestCase
):
def
test_default_not_callable
(
self
):
"""
...
...
@@ -95,6 +99,15 @@
ran
=
True
self
.
assertTrue
(
ran
)
def
test_default_exception_type
(
self
):
"""
dumps() TypeError in default() raises orjson.JSONEncodeError
"""
ref
=
Custom
()
with
self
.
assertRaises
(
orjson
.
JSONEncodeError
):
orjson
.
dumps
(
ref
,
default
=
default_raises
)
def
test_default_func_nested_str
(
self
):
"""
dumps() default function nested str
...
...
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