This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [easy] undefined name in Lib/test/mock_socket.py
Type: Stage: resolved
Components: Tests Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: corona10, furkanonder, miss-islington, vstinner
Priority: normal Keywords: newcomer friendly, patch

Created on 2020-04-30 23:50 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19832 merged furkanonder, 2020-05-01 09:20
PR 20094 merged vstinner, 2020-05-14 22:36
Messages (11)
msg367812 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-30 23:50
pyflakes found the following issues in sendall():

Lib/test/mock_socket.py:95:21 undefined name 'data'
Lib/test/mock_socket.py:96:28 undefined name 'data'
Lib/test/mock_socket.py:97:20 undefined name 'data'

Code:

    def sendall(self, buffer, flags=None):
        self.last = data
        self.output.append(data)
        return len(data)

    def send(self, data, flags=None):
        self.last = data
        self.output.append(data)
        return len(data)

I guess that sendall() buffer parameter should be renamed to data.
msg367813 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-30 23:53
Another one:

Lib/test/test_frame.py:53:17 undefined name 'inner'

I guess that self.inner() should be used instead of inner(). In practice, it's dead code, but fixing it would make pyflakes happier :-)
msg367814 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-04-30 23:59
Another one:

Lib/test/test_json/test_recursion.py:55:24 undefined name 'pyjson'

Code:

    def test_defaultrecursion(self):
        class RecursiveJSONEncoder(self.json.JSONEncoder):
            recurse = False
            def default(self, o):
                if o is JSONTestObject:
                    if self.recurse:
                        return [JSONTestObject]
                    else:
                        return 'JSONTestObject'
                return pyjson.JSONEncoder.default(o)

Here I'm not sure. *Maybe* pyjson.JSONEncoder should be replaced with self.json.JSONEncoder?
msg367816 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-01 00:04
Another one:

Lib/unittest/test/test_program.py:191:40 undefined name 'hasInstallHandler'

Code:

    def testBufferCatchFailfast(self):
        program = self.program
        for arg, attr in (('buffer', 'buffer'), ('failfast', 'failfast'),
                      ('catch', 'catchbreak')):
            if attr == 'catch' and not hasInstallHandler:
                continue
            ...

attr is never equal to 'catch' and so it's just dead code which can be removed.
msg367829 - (view) Author: Furkan Onder (furkanonder) * Date: 2020-05-01 09:27
Hello,
I sent a PR that corrects variable and function names.
I'm not sure how to fix it for Lib/test/test_json/test_recursion.py:55:24 so I didn't make any changes.
msg367841 - (view) Author: miss-islington (miss-islington) Date: 2020-05-01 12:49
New changeset 719e14d2837520c18398a3e22a36f20c1fe76edf by Furkan Önder in branch 'master':
bpo-40462: fix variable and function names (GH-19832)
https://github.com/python/cpython/commit/719e14d2837520c18398a3e22a36f20c1fe76edf
msg367842 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2020-05-01 13:10
@vstinner
IMHO we should create backport patch for 3.8 and 3.7
3.8 and 3.7 has same codes for this.

https://github.com/python/cpython/blob/3.8/Lib/test/mock_socket.py#L95
msg368157 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-05 14:42
> IMHO we should create backport patch for 3.8 and 3.7

It's deadcode, I don't think that it's worth it. But it's up to you. If you consider that it's worth it, go ahead and backport the fix.
msg368874 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-14 23:02
New changeset 4b972faf605912092013a1fdbf486c498d002926 by Victor Stinner in branch 'master':
bpo-40462: Fix typo in test_json (GH-20094)
https://github.com/python/cpython/commit/4b972faf605912092013a1fdbf486c498d002926
msg368875 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-14 23:02
Thanks for the fix Furkan Önder!
msg368879 - (view) Author: Furkan Onder (furkanonder) * Date: 2020-05-14 23:29
You are welcome :=)
History
Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84642
2020-05-14 23:29:08furkanondersetmessages: + msg368879
2020-05-14 23:02:41vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg368875

stage: patch review -> resolved
2020-05-14 23:02:17vstinnersetmessages: + msg368874
2020-05-14 22:36:16vstinnersetpull_requests: + pull_request19400
2020-05-14 22:27:53vstinnersetpull_requests: - pull_request19288
2020-05-06 23:55:47furkanondersetpull_requests: + pull_request19288
2020-05-05 14:42:29vstinnersetmessages: + msg368157
2020-05-01 13:10:04corona10setnosy: + corona10
messages: + msg367842
2020-05-01 12:49:39miss-islingtonsetnosy: + miss-islington
messages: + msg367841
2020-05-01 09:27:06furkanondersetmessages: + msg367829
2020-05-01 09:20:39furkanondersetkeywords: + patch
nosy: + furkanonder

pull_requests: + pull_request19151
stage: patch review
2020-05-01 00:04:31vstinnersetmessages: + msg367816
2020-04-30 23:59:30vstinnersetmessages: + msg367814
2020-04-30 23:53:15vstinnersetmessages: + msg367813
2020-04-30 23:50:30vstinnercreate