Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
38eef02a
Commit
38eef02a
authored
Aug 22, 2015
by
Dan O'Reilly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix metaclass issue on Python 3. Get text handling tests passing on Python 3.
Signed-off-by:
Dan O'Reilly
<
oreilldf@gmail.com
>
parent
fc80874a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
13 deletions
+9
-13
descriptor.py
python/google/protobuf/descriptor.py
+3
-2
text_format.py
python/google/protobuf/text_format.py
+3
-8
tox.ini
python/tox.ini
+3
-3
No files found.
python/google/protobuf/descriptor.py
View file @
38eef02a
...
...
@@ -36,6 +36,8 @@ file, in types that make this information accessible in Python.
__author__
=
'robinson@google.com (Will Robinson)'
import
six
from
google.protobuf.internal
import
api_implementation
...
...
@@ -73,7 +75,7 @@ else:
DescriptorMetaclass
=
type
class
DescriptorBase
(
object
):
class
DescriptorBase
(
six
.
with_metaclass
(
DescriptorMetaclass
)
):
"""Descriptors base class.
...
...
@@ -88,7 +90,6 @@ class DescriptorBase(object):
avoid some bootstrapping issues.
"""
__metaclass__
=
DescriptorMetaclass
if
_USE_C_DESCRIPTORS
:
# The class, or tuple of classes, that are considered as "virtual
# subclasses" of this descriptor class.
...
...
python/google/protobuf/text_format.py
View file @
38eef02a
...
...
@@ -69,19 +69,15 @@ class ParseError(Error):
class
TextWriter
(
object
):
def
__init__
(
self
,
as_utf8
):
self
.
_utf8
=
as_utf8
if
as_utf8
:
if
six
.
PY2
:
self
.
_writer
=
io
.
BytesIO
()
else
:
self
.
_writer
=
io
.
StringIO
()
def
write
(
self
,
val
):
if
s
elf
.
_utf8
:
if
s
ix
.
PY2
:
if
isinstance
(
val
,
six
.
text_type
):
val
=
val
.
encode
(
'utf-8'
)
else
:
if
isinstance
(
val
,
bytes
):
val
=
val
.
decode
(
'utf-8'
)
return
self
.
_writer
.
write
(
val
)
def
close
(
self
):
...
...
@@ -245,8 +241,7 @@ def PrintFieldValue(field, value, out, indent=0, as_utf8=False,
out_as_utf8
=
False
else
:
out_as_utf8
=
as_utf8
out_text
=
text_encoding
.
CEscape
(
out_value
,
out_as_utf8
)
out
.
write
(
out_text
)
out
.
write
(
text_encoding
.
CEscape
(
out_value
,
out_as_utf8
))
out
.
write
(
'
\"
'
)
elif
field
.
cpp_type
==
descriptor
.
FieldDescriptor
.
CPPTYPE_BOOL
:
if
value
:
...
...
python/tox.ini
View file @
38eef02a
[tox]
envlist
=
#
Py3 tests currently fail because of text handling issues,
#
So only test py26/py27 for now
.
#
cpp implementation on py34 is currently broken due to
#
changes introduced by http://bugs.python.org/issue22079
.
#py{26,27,33,34}-{cpp,python}
py{26,27
}-{cpp,
python}
py{26,27
,33}-{cpp,python},
py34-{
python}
[testenv]
usedevelop
=
true
...
...
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