Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
7dc4bce4
Commit
7dc4bce4
authored
Feb 04, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 2.6 compat
parent
937ef008
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
rest_framework/compat.py
+9
-0
rest_framework/parsers.py
+2
-2
rest_framework/serializers.py
+5
-0
No files found.
rest_framework/compat.py
View file @
7dc4bce4
...
...
@@ -426,3 +426,12 @@ try:
from
xml.etree
import
ParseError
as
ETParseError
except
ImportError
:
# python < 2.7
ETParseError
=
None
# XMLParser only takes an encoding arg from >= 2.7
def
ET_XMLParser
(
encoding
=
None
):
from
xml.etree
import
ElementTree
as
ET
try
:
return
ET
.
XMLParser
(
encoding
=
encoding
)
except
TypeError
:
return
ET
.
XMLParser
()
rest_framework/parsers.py
View file @
7dc4bce4
...
...
@@ -9,7 +9,7 @@ from django.conf import settings
from
django.http
import
QueryDict
from
django.http.multipartparser
import
MultiPartParser
as
DjangoMultiPartParser
from
django.http.multipartparser
import
MultiPartParserError
from
rest_framework.compat
import
yaml
,
ETParseError
from
rest_framework.compat
import
yaml
,
ETParseError
,
ET_XMLParser
from
rest_framework.exceptions
import
ParseError
from
rest_framework.compat
import
six
from
xml.etree
import
ElementTree
as
ET
...
...
@@ -148,7 +148,7 @@ class XMLParser(BaseParser):
def
parse
(
self
,
stream
,
media_type
=
None
,
parser_context
=
None
):
parser_context
=
parser_context
or
{}
encoding
=
parser_context
.
get
(
'encoding'
,
settings
.
DEFAULT_CHARSET
)
parser
=
ET
.
XMLParser
(
encoding
=
encoding
)
parser
=
ET
_
XMLParser
(
encoding
=
encoding
)
try
:
tree
=
ET
.
parse
(
stream
,
parser
=
parser
)
except
(
ExpatError
,
ETParseError
,
ValueError
)
as
exc
:
...
...
rest_framework/serializers.py
View file @
7dc4bce4
...
...
@@ -165,6 +165,11 @@ class BaseSerializer(Field):
# Remove anything in 'exclude'
if
self
.
opts
.
exclude
:
# Note: To be deprecated in line with Django's ModelForm change.
# https://code.djangoproject.com/ticket/19733
warnings
.
warn
(
'`exclude` option on serializers is due to be deprecated. '
'Use the `fields` option instead.'
,
PendingDeprecationWarning
,
stacklevel
=
2
)
for
key
in
self
.
opts
.
exclude
:
ret
.
pop
(
key
,
None
)
...
...
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