- Notifications
You must be signed in to change notification settings - Fork0
Avoid sed inconpatibility#1
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Avoid sed inconpatibility#1
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| defdelete_pot_creation_date(filename): | ||
| withcodecs.open(filename,'r',encoding='utf-8')asf: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Python 2/3 共通のコード書くときは、 codecs.open よりも io.open の方が好み。
cocoatomoFeb 28, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
ちょっと分かりづらいんですが, howto/logging-cookbook.rst に ascii の範囲を越える文字が使われていて, 組み込み関数の open を使うと Windows でエラーが出ていたんで encoding 指定できる codecs.open を使った.
具体的な箇所はここの二重引用符
https://github.com/python-doc-ja/cpython-doc-intl/blame/intl-3.6/Doc/howto/logging-cookbook.rst#L1988
よく見ると QUOTATION MARK (0x22) ではなく LEFT DOUBLE QUOTATION MARK (0x201C) と RIGHT DOUBLE QUOTATION MARK (0x201D) が使われている.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
エラーメッセージ
>>> open('locale\pot\howto\logging-cookbook.pot').readlines()Traceback (most recent call last): File "<stdin>", line 1, in <module>UnicodeDecodeError: 'cp932' codec can't decode byte 0x9c in position 2194: illegal multibyte sequenceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
組み込みの open じゃなくて io.open ね。 Python 2.7 でも encoding 指定できるはず。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
あ、こっちか。間違って os.open 見てました ;p
https://docs.python.jp/3/library/io.html#high-level-module-interface
https://docs.python.jp/2.7/library/io.html#text-i-o
これか。オプション引数多いし、こっちが良さそう。
Doc/Makefile Outdated
| gettext: | ||
| sphinx-build -E -b gettext -D gettext_compact=0 -w warnings.txt -d build/.doctrees. locale/pot | ||
| find locale/pot -name'*.pot'| xargs sed -i -e'/^"POT-Creation-Date: 20/d' | ||
| python tools/delete_pot_creation_date.py locale/pot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
他のところに合わせて$(PYTHON) ってしておいてください。
sed command has inconpatibility on
-ioption behavior between GNU sed and BSD sed.In addition to this inconpatibility, Windows has no sed command natively.
In order to deal with these difference between platforms, Python script would be helpful.