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

ValueError. need more than 1 value to unpack #164

Closed
aleray opened this issue Dec 8, 2012 · 3 comments
Closed

ValueError. need more than 1 value to unpack #164

aleray opened this issue Dec 8, 2012 · 3 comments
Labels
bug Bug report. extension Related to one or more of the included extensions.

Comments

@aleray
Copy link

aleray commented Dec 8, 2012

Hi,

with the document below, I get the a "Need more than 1 value to unpack" ValueError:

# Hello{ {: id='foo' }

World

Here is the traceback:

☁  markdown_py -x extra Catalog-ExtendDimensions
Traceback (most recent call last):
  File "/usr/bin/markdown_py", line 34, in <module>
    run()
  File "/usr/lib/python2.7/site-packages/markdown/__main__.py", line 81, in run
    markdown.markdownFromFile(**options)
  File "/usr/lib/python2.7/site-packages/markdown/__init__.py", line 449, in markdownFromFile
    kwargs.get('encoding', None))
  File "/usr/lib/python2.7/site-packages/markdown/__init__.py", line 366, in convertFile
    html = self.convert(text)
  File "/usr/lib/python2.7/site-packages/markdown/__init__.py", line 307, in convert
    output = self.serializer(root)
  File "/usr/lib/python2.7/site-packages/markdown/serializers.py", line 275, in to_xhtml_string
    return _write_html(ElementTree(element).getroot(), format="xhtml")
  File "/usr/lib/python2.7/site-packages/markdown/serializers.py", line 197, in _write_html
    qnames, namespaces = _namespaces(root, default_namespace)
  File "/usr/lib/python2.7/site-packages/markdown/serializers.py", line 263, in _namespaces
    add_qname(key)
  File "/usr/lib/python2.7/site-packages/markdown/serializers.py", line 223, in add_qname
    uri, tag = qname[1:].split("}", 1)
ValueError: need more than 1 value to unpack

Thanks,

Alex

@waylan
Copy link
Member

waylan commented Dec 9, 2012

Interesting. This is the first I've ever seen an error from the serializer - which is a trimmed down version of the serializer that ships with the newest version of ElementTree. I wonder if this is really a bug in the serializer, an edge case where we're building an invalid elementtree, or a case of garbage in - garbage out. Either way, we need to address this. We shouldn't be crashing regardless of the input provided. Thanks for the report.

@waylan
Copy link
Member

waylan commented Dec 12, 2012

Did a little debugging on this. The attributes set on the h1 are the problem:

>>> h1.items()
[(u'{:', u'{:'), (u'id', u'foo')]

The colon is optional, so the first { starts the attr list, and the second {: is seen as a valueless key. However, a key of {: would not produce valid html - so the serializer is correct to choke on that. Guess the attr list parser needs to be improved.

@waylan waylan closed this as completed in a8e06b7 Dec 13, 2012
@mitya57
Copy link
Collaborator

mitya57 commented Dec 16, 2012

The new test passes with Python 2, but fails with Python 3:

ERROR: TestSyntax: "extensions/attr_list"
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/home/mandriver/Python-Markdown/build/tests/__init__.py", line 95, in __call__
    output = markdown.markdown(input, **get_args(file, config))
  File "/home/mandriver/Python-Markdown/build/lib/markdown/__init__.py", line 415, in markdown
    return md.convert(text)
  File "/home/mandriver/Python-Markdown/build/lib/markdown/__init__.py", line 304, in convert
    output = self.serializer(root)
  File "/home/mandriver/Python-Markdown/build/lib/markdown/serializers.py", line 275, in to_xhtml_string
    return _write_html(ElementTree(element).getroot(), format="xhtml")
  File "/home/mandriver/Python-Markdown/build/lib/markdown/serializers.py", line 197, in _write_html
    qnames, namespaces = _namespaces(root, default_namespace)
  File "/home/mandriver/Python-Markdown/build/lib/markdown/serializers.py", line 263, in _namespaces
    add_qname(key)
  File "/home/mandriver/Python-Markdown/build/lib/markdown/serializers.py", line 223, in add_qname
    uri, tag = qname[1:].split("}", 1)
ValueError: need more than 1 value to unpack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report. extension Related to one or more of the included extensions.
Projects
None yet
Development

No branches or pull requests

3 participants