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

Support Python3 #110

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Support Python3 #110

wants to merge 15 commits into from

Conversation

takano32
Copy link
Collaborator

@takano32 takano32 commented Feb 9, 2024

closes: #107

最低限の動作がするような気がするところまで修正

$ python tests.py
............................F.....EFF.F.F
======================================================================
ERROR: test_cp932 (__main__.TestSubcultureTitleExtract)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/takano32/GitHub/sub/tests.py", line 437, in test_cp932
    self.assertEqual(self.s.response(), u'Title: Shift-JISテキストを正しく扱う')
  File "/Users/takano32/GitHub/sub/sun.py", line 748, in response
    res += self.get_element_title(url=url) + "\n"
  File "/Users/takano32/GitHub/sub/sun.py", line 719, in get_element_title
    h.feed(str(self.content.decode()).replace("\n", ""))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 254: invalid start byte

======================================================================
FAIL: test_response (__main__.TestSubcultureSilent)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/takano32/GitHub/sub/tests.py", line 213, in test_response
    self.assertRegex(str(self.r.response()), r)
AssertionError: Regex didn't match: '^(:?私も|また)?会いたいな$' not found in 'None'

======================================================================
FAIL: test_euc (__main__.TestSubcultureTitleExtract)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/takano32/GitHub/sub/tests.py", line 441, in test_euc
    self.assertEqual(self.s.response(), u'Title: FreeBSD ハンドブック')
AssertionError: 'Title: FreeBSD ハンドブック | FreeBSD Documentation Portal' != 'Title: FreeBSD ハンドブック'
- Title: FreeBSD ハンドブック | FreeBSD Documentation Portal
+ Title: FreeBSD ハンドブック


======================================================================
FAIL: test_googlephotos (__main__.TestSubcultureTitleExtract)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/takano32/GitHub/sub/tests.py", line 457, in test_googlephotos
    self.assertRegex(self.s.response(), r'https://lh[0-9]\.googleusercontent\.com/[a-zA-Z0-9\-_]+=s1600#.jpg')
AssertionError: Regex didn't match: 'https://lh[0-9]\\.googleusercontent\\.com/[a-zA-Z0-9\\-_]+=s1600#.jpg' not found in ''

======================================================================
FAIL: test_instagram (__main__.TestSubcultureTitleExtract)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/takano32/GitHub/sub/tests.py", line 453, in test_instagram
    self.assertRegex(self.s.response(), r'https://[a-z0-9\-]*?\.cdninstagram.com/[a-zA-Z0-9\/]*?/t51.2885-15/e35/13397618_1803858326514633_1716463464_n.jpg.*')
AssertionError: Regex didn't match: 'https://[a-z0-9\\-]*?\\.cdninstagram.com/[a-zA-Z0-9\\/]*?/t51.2885-15/e35/13397618_1803858326514633_1716463464_n.jpg.*' not found in ''

======================================================================
FAIL: test_utf8_withlazycrlf (__main__.TestSubcultureTitleExtract)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/takano32/GitHub/sub/tests.py", line 449, in test_utf8_withlazycrlf
    self.assertEqual(self.s.response(), u'Title: 「マッドマックス」上映中の米映画館で発砲、51歳の容疑者射殺 | ロイター')
AssertionError: 'Title: 「マッドマックス」上映の劇場で発砲、容疑者射殺後に空気銃と判明 | ロイター' != 'Title: 「マッドマックス」上映中の米映画館で発砲、51歳の容疑者射殺 | ロイター'
- Title: 「マッドマックス」上映の劇場で発砲、容疑者射殺後に空気銃と判明 | ロイター
?                    ^^         --------
+ Title: 「マッドマックス」上映中の米映画館で発砲、51歳の容疑者射殺 | ロイター
?                   + ^^^^    ++++


----------------------------------------------------------------------
Ran 41 tests in 12.702s

FAILED (failures=5, errors=1)

@takano32 takano32 requested a review from tinbotu February 9, 2024 04:53
@takano32
Copy link
Collaborator Author

takano32 commented Feb 10, 2024

最低限の動作を確認できたので切り替えて試験運用しています。

doge@doge:~/workspace$ ls -ald sub*
lrwxrwxrwx 1 doge users   11  2月 10 20:06 sub -> sub.python3
drwxr-xr-x 6 doge users 4096  2月  9 13:49 sub.python2
drwxr-xr-x 7 doge users 4096  2月 10 20:26 sub.python3

Draft から Ready for preview にします。

@takano32 takano32 marked this pull request as ready for review February 10, 2024 11:32
Fix `str#.decode` error

```
Traceback (most recent call last):
  File "/var/www/cgi-bin/sub/sun.cgi", line 1540, in <module>
    no.say(slack=no.is_slack, lingr=False)
  File "/var/www/cgi-bin/sub/sun.cgi", line 1520, in say
    resp = "\n".join(tuple(self.response())).rstrip("\n")
  File "/var/www/cgi-bin/sub/sun.cgi", line 1495, in response
    r = I.response()
  File "/var/www/cgi-bin/sub/sun.cgi", line 1053, in response
    res += fp.read().decode('utf_8')
AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
```
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

Successfully merging this pull request may close these issues.

doge 3000
2 participants