mirror of https://github.com/vee1e/flatbuffers - FlatBuffers: Memory Efficient Serialization Library
Find a file
Alex Kerfoot 1e7310e6cd Fix CreateString with already-encoded string or bytearray in Python 2.7.
There was no way to pass an already-encoded string to 
`builder.CreateString` in Python 2.7:

- Passing a `bytearray` raised a TypeError because `bytearray` was not
  recognized as an instance of `compat.binary_type`.
- Passing a utf-8 encoded `str` would cause the string to be
  double-encoded, because `compat.string_types = (basestring,)` and
  `basestring` is the base class of `str` and `unicode`, so the logic
  would never reach the `elif isinstance(s, compat.binary_type)` case.
- Converting a utf-8 encoded bytearray to `bytes` like
  `builder.CreateString(bytes(encoded_string))` does not work because
  in Python 2.7, bytes is just an alias for `str` so it behaves as
  above.

This change allows either `bytes` or `bytearray` as an already-encoded
string to be passed to `CreateString` in versions of Python that support
`bytearray`, and falls back to `str` in older versions.

In Python 2, it restricts unencoded string types to `unicode`, so `str`
can be used as an encoded, binary representaiton.
2016-03-08 16:05:02 -08:00
android Added android static library target for text parsing/generation etc. 2016-01-06 17:48:19 -08:00
biicode
build_ide Moved the build dir to build_ide to not clash with BUILD files. 2016-03-07 12:58:36 -08:00
CMake
docs Merge branch 'master' of https://github.com/google/flatbuffers 2016-03-07 15:04:18 -08:00
go
include/flatbuffers Added support for easy string pooling. 2016-03-07 12:58:36 -08:00
java Fixed Java pom.xml file still having wrong version number. 2016-03-07 14:15:01 -08:00
js Fix #3773: Generated JS now avoids the flatbuffers object 2016-02-25 01:06:16 -08:00
net/FlatBuffers Implemented ForceDefaults option on C# FlatBufferBuilder. 2016-01-20 17:25:58 +00:00
php Revamping the FlatBuffers docs. 2016-01-19 14:31:17 -08:00
python Fix CreateString with already-encoded string or bytearray in Python 2.7. 2016-03-08 16:05:02 -08:00
reflection
samples Re-Added accidentally deleted sample generated file. 2016-01-20 18:09:53 -08:00
src Merge branch 'master' of https://github.com/google/flatbuffers 2016-03-07 15:04:18 -08:00
tests Merge branch 'master' of https://github.com/google/flatbuffers 2016-03-07 15:04:18 -08:00
.gitattributes
.gitignore Added Visual Studio transient files to .gitignore 2016-01-18 20:54:22 +00:00
.travis.yml Disabled broken biicode builds on Travis for the moment. 2016-02-22 11:33:14 -08:00
biicode.conf
CMakeLists.txt Fixed missing -lc++abi on FreeBSD. 2016-03-02 17:15:42 -08:00
composer.json
CONTRIBUTING Revamping the FlatBuffers docs. 2016-01-19 14:31:17 -08:00
LICENSE.txt
readme.md Updated text in section "Supported programming languages" 2016-02-02 00:18:00 +05:30

logo FlatBuffers Build Status

FlatBuffers is an efficient cross platform serialization library for games and other memory constrained apps. It allows you to directly access serialized data without unpacking/parsing it first, while still having great forwards/backwards compatibility.

Go to our landing page to browse our documentation.

Supported operating systems

  • Android
  • Windows
  • MacOS X
  • Linux

Supported programming languages

  • C++
  • C#
  • Go
  • Java
  • JavaScript
  • PHP
  • Python

and many more in progress...

Contribution

To contribute to this project, see CONTRIBUTING.

Integration

For applications on Google Play that integrate this tool, usage is tracked. This tracking is done automatically using the embedded version string (flatbuffer_version_string), and helps us continue to optimize it. Aside from consuming a few extra bytes in your application binary, it shouldn't affect your application at all. We use this information to let us know if FlatBuffers is useful and if we should continue to invest in it. Since this is open source, you are free to remove the version string but we would appreciate if you would leave it in.

Licensing

Flatbuffers is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.