Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 0.5.1, no exception but break the string line when dump some special data #22

Open
WangLei1993 opened this issue Jan 16, 2018 · 0 comments

Comments

@WangLei1993
Copy link

when I use this lib to dumps some data, it make a puzzled question, sample.log is the minimized data to show it. my python version is 2.7.13 .

  1. pyrapidjson 0.5 + not encode with utf-8
# -*- coding:utf-8 -*-
import codecs
import rapidjson
if __name__ == '__main__':
    with codecs.open('sample.log', 'rb', 'utf-8') as f_read:
        report_data = [f_read.read(),]
        print report_data
        report_json = rapidjson.dumps(report_data)
        print report_json

it raise a crash about python like:

image

  1. pyrapidjson 0.5 + encode with utf-8
# -*- coding:utf-8 -*-
import codecs
import rapidjson
if __name__ == '__main__':
    with codecs.open('sample.log', 'rb', 'utf-8') as f_read:
        report_data = [f_read.read().encode('utf-8'),]
        print report_data
        report_json = rapidjson.dumps(report_data)
        print report_json

it may right like:

image

  1. pyrapidjson 0.5.1 + not encode with utf-8
# -*- coding:utf-8 -*-
import codecs
import rapidjson
if __name__ == '__main__':
    with codecs.open('sample.log', 'rb', 'utf-8') as f_read:
        report_data = [f_read.read(),]
        print report_data
        report_json = rapidjson.dumps(report_data)
        print report_json

it like the following picture, no exception but break the string line:

image

  1. pyrapidjson 0.5.1 + encode with utf-8
# -*- coding:utf-8 -*-
import codecs
import rapidjson
if __name__ == '__main__':
    with codecs.open('sample.log', 'rb', 'utf-8') as f_read:
        report_data = [f_read.read().encode('utf-8'),]
        print report_data
        report_json = rapidjson.dumps(report_data)
        print report_json

it like the following picture, also no exception but break the string line:

image

with this condition, I can't know right or not about dumps result. I think it may raise an exception when meet this condition or another way to let user know about this error.

@WangLei1993 WangLei1993 changed the title 5.0.1 version, no exception but break the string line when dump some special data 0.5.1 version, no exception but break the string line when dump some special data Jan 16, 2018
@WangLei1993 WangLei1993 changed the title 0.5.1 version, no exception but break the string line when dump some special data version 0.5.1, no exception but break the string line when dump some special data Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant