Skip to content

test_heapq: AttributeError: 'int' object has no attribute 'pop' #53798

Closed

Description

@florentx
mannequin
BPO 9589
Nosy @pitrou, @vstinner, @florentx
Files
  • addbuilddir.patch
  • c-addbuildir.patch
  • 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 = 'https://github.com/pitrou'
    closed_at = <Date 2010-08-13.22:40:21.919>
    created_at = <Date 2010-08-13.17:31:13.897>
    labels = ['tests', 'type-bug', 'library']
    title = "test_heapq: AttributeError: 'int' object has no attribute 'pop'"
    updated_at = <Date 2010-08-14.09:47:21.625>
    user = 'https://github.com/florentx'

    bugs.python.org fields:

    activity = <Date 2010-08-14.09:47:21.625>
    actor = 'vstinner'
    assignee = 'pitrou'
    closed = True
    closed_date = <Date 2010-08-13.22:40:21.919>
    closer = 'pitrou'
    components = ['Library (Lib)', 'Tests']
    creation = <Date 2010-08-13.17:31:13.897>
    creator = 'flox'
    dependencies = []
    files = ['18504', '18509']
    hgrepos = []
    issue_num = 9589
    keywords = ['patch', 'buildbot']
    message_count = 7.0
    messages = ['113798', '113800', '113801', '113806', '113819', '113844', '113882']
    nosy_count = 3.0
    nosy_names = ['pitrou', 'vstinner', 'flox']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue9589'
    versions = ['Python 3.2']

    Activity

    1. florentx commented on Aug 13, 2010

      florentxmannequin
      MannequinAuthor

      Various buildbots show a failure on test_heapq.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      testsTests in the Lib/test dir
      type-bugAn unexpected behavior, bug, or error
      on Aug 13, 2010
    3. pitrou commented on Aug 13, 2010

      @pitrou
      Member

      This is a variant of the kind of annoyance pointed out in bpo-9548. Here, it seems addbuilddir() in Lib/site.py shouldn't import sysconfig, because it imports the re module.

    4. florentx commented on Aug 13, 2010

      florentxmannequin
      MannequinAuthor

      For some reason, sys.modules['heapq'] contains the Python implementation instead of the C implementation.

      Tested with r83981 on python 3:

      Python 3.2a1+ (py3k:83981M, Aug 13 2010, 19:02:31)
      [GCC 4.3.4] on linux2
      Type "help", "copyright", "credits" or "license" for more information.

      >>> import heapq
      >>> heapq.heappop(10)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/home/florent/dev/python/py3trunk/Lib/heapq.py", line 140, in heappop
          lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
      AttributeError: 'int' object has no attribute 'pop'
      
      >>> import _heapq
      >>> _heapq.heappop(10)
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: heap argument must be a list

      These tests (TestErrorHandling) are supposed to run with the C module only.

    5. pitrou commented on Aug 13, 2010

      @pitrou
      Member

      Here is a patch which works if the patch in bpo-9548 is also applied.
      It won't work alone because opening a file in text mode currently imports locale which imports re, etc. ... all before adding the build dir to sys.path.

      Of course, since the logic in addbuilddir() is now much simpler, it could also be rewritten in C somewhere (where?), and the launched much earlier during the startup phase.

    6. pitrou commented on Aug 13, 2010

      @pitrou
      Member

      Here is a C version of addbuilddir. It solves the present issue.

    7. pitrou commented on Aug 13, 2010

      @pitrou
      Member

      I've committed an updated version of the C patch in r83988, after Victor's comments on IRC.

    8. self-assigned this
      on Aug 13, 2010
    9. vstinner commented on Aug 14, 2010

      @vstinner
      Member

      r83988 is also the correct fix for bpo-586680: I updated this issue.

    10. 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

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions