Skip to content

Conversation

brandonchinn178
Copy link
Contributor

Fixes #499

The getiterator function doesn't accept arguments in Python 3.6 (raises a TypeError), so this manually filters elements based on the tag name

@waylan
Copy link
Member

waylan commented Sep 29, 2016

Thanks for doing the work on this. I don't doubt your right, but did you find any comments about this change in Python's documentation/release notes/commit logs? I'm curious about the reasoning behind that change.

@brandonchinn178
Copy link
Contributor Author

There are no explicit changes in the changelog, so I suspect there must've been some change in the way Python 3.6 interfaces with the underlying C library?

@mitya57
Copy link
Collaborator

mitya57 commented Sep 29, 2016

The documentation for 3.6 still mentions tag as a valid argument.

According to the stacktraces this looks like a bug in Python 3.6 to me:

>>> from xml.etree.ElementTree import Element
>>> el = Element('foo')
>>> el.getiterator('bar')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: ../Python/getargs.c:1508: bad argument to internal function
>>> el.getiterator(tag='bar')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: iter() takes at most 1 argument (140172072006928 given)

Please report it to Python issue tracker (or I can do it for you, if you prefer).

@brandonchinn178
Copy link
Contributor Author

Wait so .iter('div') works... since getiterator is being deprecated anyway, I think this is a worthwhile change. It seems like maybe there's a bug in getiterator when it passes the call to iter?

@waylan
Copy link
Member

waylan commented Sep 29, 2016

Ah, getiterator has been deprecated since Python 2.7, and iter was added in 2.7. As 2.7 is the lowest supported version, we should be using iter.

@waylan waylan merged commit 1550bdb into Python-Markdown:master Sep 29, 2016
@mitya57
Copy link
Collaborator

mitya57 commented Sep 29, 2016

Getting rid of deprecated calls is indeed the good thing.
But I filed http://bugs.python.org/issue28314 for the regression anyway.

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.

3 participants