Skip to content

[easy] undefined name in Lib/test/mock_socket.py #84642

Closed

Description

@vstinner
BPO 40462
Nosy @vstinner, @corona10, @miss-islington, @furkanonder
PRs
  • bpo-40462: fix variable and function names #19832
  • bpo-40462: Fix typo in test_json #20094
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-05-14.23:02:41.255>
    created_at = <Date 2020-04-30.23:50:30.182>
    labels = ['easy', 'tests', '3.9']
    title = '[easy] undefined name in Lib/test/mock_socket.py'
    updated_at = <Date 2020-05-14.23:29:08.116>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-05-14.23:29:08.116>
    actor = 'furkanonder'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-05-14.23:02:41.255>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2020-04-30.23:50:30.182>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40462
    keywords = ['patch', 'newcomer friendly']
    message_count = 11.0
    messages = ['367812', '367813', '367814', '367816', '367829', '367841', '367842', '368157', '368874', '368875', '368879']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'corona10', 'miss-islington', 'furkanonder']
    pr_nums = ['19832', '20094']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue40462'
    versions = ['Python 3.9']

    Activity

    1. vstinner commented on Apr 30, 2020

      @vstinner
      MemberAuthor

      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.

    2. vstinner commented on Apr 30, 2020

      @vstinner
      MemberAuthor

      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 :-)

    3. vstinner commented on Apr 30, 2020

      @vstinner
      MemberAuthor

      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?

    4. vstinner commented on May 1, 2020

      @vstinner
      MemberAuthor

      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.

    5. furkanonder commented on May 1, 2020

      furkanondermannequin
      Mannequin

      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.

    6. miss-islington commented on May 1, 2020

      @miss-islington
      Contributor

      New changeset 719e14d by Furkan Önder in branch 'master':
      bpo-40462: fix variable and function names (GH-19832)
      719e14d

    7. corona10 commented on May 1, 2020

      @corona10
      Member

      @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

    8. vstinner commented on May 5, 2020

      @vstinner
      MemberAuthor

      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.

    9. vstinner commented on May 14, 2020

      @vstinner
      MemberAuthor

      New changeset 4b972fa by Victor Stinner in branch 'master':
      bpo-40462: Fix typo in test_json (GH-20094)
      4b972fa

    10. vstinner commented on May 14, 2020

      @vstinner
      MemberAuthor

      Thanks for the fix Furkan Önder!

    11. furkanonder commented on May 14, 2020

      furkanondermannequin
      Mannequin

      You are welcome :=)

    12. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.9 (EOL)end of lifeeasytestsTests in the Lib/test dir

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions