-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add the encoding='utf-8' to ensure that it won't cause Chinese disorderly code during the template files are read or wrote #400
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
Closed
+8
−7
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…erly code during the template files are read or wrote
Looks good to me. I think you accidentally added a VCS.xml file. Could you
please remove that?
…On 5:49PM, Wed, Feb 15, 2017 Maynard ***@***.***> wrote:
Today I found a problem when use web.py to develop a web app. The
Exception is like this:
File "E:\软件安装\Python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\application.py", line 257, in process
return self.handle()
File "E:\软件安装\Python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\application.py", line 248, in handle
return self._delegate(fn, self.fvars, args)
File "E:\软件安装\Python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\application.py", line 488, in _delegate
return handle_class(cls)
File "E:\软件安装\Python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\application.py", line 466, in handle_class
return tocall(*args)
File "F:\liuming\PyWorkspace\WeChat\QuickStart.py", line 56, in GET
return render.form(name)
File "E:\软件安装\Python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\template.py", line 1034, in __getattr__
t = self._template(name)
File "E:\软件安装\Python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\template.py", line 1031, in _template
return self._load_template(name)
File "E:\软件安装\Python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\template.py", line 1016, in _load_template
return Template(open(path).read(), filename=path, **self._keywords)
UnicodeDecodeError: 'gbk' codec can't decode byte 0xbd in position 139: illegal multibyte sequence
And this exception happens because the following code:
File "E:\软件安装\Python\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\template.py", line 1016, in _load_template
return Template(open(path).read(), filename=path, **self._keywords)
So, I change return Template(open(path).read(), filename=path,
**self._keywords) to return Template(open(path,encoding='utf-8').read(),
filename=path, **self._keywords), then the problem was sovled.
And the Chinese disorderly code problem was also solved:
Before>>
[image: Chinese disorderly code]
<https://camo.githubusercontent.com/a52a056c0e8d0086c81481a889feb0b8b52ae37b/687474703a2f2f696d672e626c6f672e6373646e2e6e65742f32303137303231353139353530383139383f77617465726d61726b2f322f746578742f6148523063446f764c324a736232637559334e6b626935755a58517663326c75595852664d6a49344e4441354d7a633d2f666f6e742f3561364c354c32542f666f6e7473697a652f3430302f66696c6c2f49304a42516b46434d413d3d2f646973736f6c76652f37302f677261766974792f43656e746572>
[image: After>>]
<https://camo.githubusercontent.com/3ce68d4419a1b5485e05f39f0669fbfc07d080a1/687474703a2f2f696d672e626c6f672e6373646e2e6e65742f32303137303231353230303331353833333f77617465726d61726b2f322f746578742f6148523063446f764c324a736232637559334e6b626935755a58517663326c75595852664d6a49344e4441354d7a633d2f666f6e742f3561364c354c32542f666f6e7473697a652f3430302f66696c6c2f49304a42516b46434d413d3d2f646973736f6c76652f37302f677261766974792f43656e746572>
------------------------------
You can view, comment on, or merge this pull request online at:
#400
Commit Summary
- Add the encoding='utf-8' to ensure that it won't cause Chinese
disorderly code during the template files are read or wrote
File Changes
- *A* .idea/vcs.xml
<https://github.com/webpy/webpy/pull/400/files#diff-0> (6)
- *M* web/template.py
<https://github.com/webpy/webpy/pull/400/files#diff-1> (12)
Patch Links:
- https://github.com/webpy/webpy/pull/400.patch
- https://github.com/webpy/webpy/pull/400.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#400>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAdkZ0W4vb-86X1svf9T_q9042hm3p-ks5rcu05gaJpZM4MBpbY>
.
|
…e disorderly code during the template files are read or wrote" This reverts commit 8135512. revert
…erly code during the template files are read or wrote
@anandology Sure, now I have removed VCS.xml file. |
@anandology thoughts on .gitignore change? It is separate commit... otherwise LGTM |
Doesn't work with python 2.
To make it work with Python 2, we need to import the
@I2IT could you please make that change and remove the change the .gitignore? |
liuming-dev
added a commit
to liuming-dev/webpy
that referenced
this pull request
Sep 15, 2017
Merged in ffb0b6a. |
This was referenced Feb 28, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Today I found a problem when use web.py to develop a web app. The Exception is like this:
And this exception happens because the following code:
So, I change


return Template(open(path).read(), filename=path, **self._keywords)
toreturn Template(open(path,encoding='utf-8').read(), filename=path, **self._keywords)
, then the problem was sovled.And the Chinese disorderly code problem was also solved:
Before>>