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: 2to3 crashes with some doctests
Type: crash Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.1, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, eric.araujo, jerith, maubp, tiagoantao
Priority: normal Keywords: patch

Created on 2010-07-10 19:27 by tiagoantao, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
DocSQL.py tiagoantao, 2010-07-10 19:50
2to3_log_fix.patch jerith, 2010-09-04 16:41 Fix self.log crash in 2to3
Messages (10)
msg109911 - (view) Author: Tiago Antao (tiagoantao) * Date: 2010-07-10 19:27
2to3 -d sometimes crashes.

The problem seems to be in refactor_doctest. The problematic line is:
if self.log.isEnabledFor(logging.DEBUG):
self.log does not exist. The error, as expected:
  File "/usr/lib/python3.1/lib2to3/refactor.py", line 516, in refactor_doctest
    if self.log.isEnabledFor(logging.DEBUG):
AttributeError: 'StdoutRefactoringTool' object has no attribute 'log'
msg109916 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-07-10 19:45
Fixed in r82779. I'm curious as to what it's failing on.
msg109917 - (view) Author: Tiago Antao (tiagoantao) * Date: 2010-07-10 19:50
Benjamin,

Thanks for the fast answer.
I attach the problematic file.
This file is from Biopython. We are trying to have a Python 3 version of it.

We applied 2to3 (no -d) first (via distutils on setup.py build) and I was applying 2to3 -d manually after it.
msg109925 - (view) Author: Tiago Antao (tiagoantao) * Date: 2010-07-10 20:03
BTW, this happens in 2.6 also
msg109988 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-07-11 10:32
Could it be because of the escaped triple quotes?
msg110023 - (view) Author: Tiago Antao (tiagoantao) * Date: 2010-07-11 16:13
A few more problematic examples (hope it helps)
        >>> my_mseq = MutableSeq("MKQHKAMIVALIVICITAVVAAL", \
                                 IUPAC.protein)

Note the line continuation
>>> rec.letter_annotations["secondary_structure"] = \
(The same pattern)

Another (different)
        """Returns a simple text representation of the codon table

        e.g.
        >>> import Bio.Data.CodonTable
        >>> print Bio.Data.CodonTable.standard_dna_table
        >>> print Bio.Data.CodonTable.generic_by_id[1]"""

And (the original)
>>> class CreatePeople(DocSQL.Create):
...     \"""
...     CREATE TEMPORARY TABLE people
...     (id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
...     last_name TINYTEXT,
...     first_name TINYTEXT)
...     \"""
...

Hope it helps
msg110025 - (view) Author: Tiago Antao (tiagoantao) * Date: 2010-07-11 16:27
Another example
    >>> records = (record for record in \
                SeqIO.parse("Roche/E3MFGYR02_random_10_reads.sff","sff") \
                if record.seq[record.annotations["cli [...]

Note that ... does not apply here (it will fail on python2 doctests)
msg110262 - (view) Author: Tiago Antao (tiagoantao) * Date: 2010-07-14 09:54
I've re-opened this bug because of the late examples that I've included that still crash. I can open a new bug if you prefer with the late examples (just tell me and I will open a new bug).

This is somewhat important for us: In order to be able to release a Python3 version of biopython we need to have 2to3 doctest processing working.
msg111811 - (view) Author: Peter (maubp) Date: 2010-07-28 13:56
Reverted accidental title change - had keyboard focus on the page not
the address bar I think. Sorry!
msg115588 - (view) Author: Jeremy Thurgood (jerith) Date: 2010-09-04 16:41
This seems to be fixed in 3.2 and the 2.7 maintenance branch, but here's a (one-liner) patch for people who want to fix their local installations.
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53463
2010-09-05 18:03:52eric.araujosetstatus: open -> closed
stage: resolved
2010-09-04 16:41:47jerithsetfiles: + 2to3_log_fix.patch

nosy: + jerith
messages: + msg115588

keywords: + patch
2010-07-28 13:56:19maubpsetmessages: + msg111811
title: 2to3 doctests -> 2to3 crashes with some doctests
2010-07-28 13:55:06maubpsettitle: 2to3 crashes with some doctests -> 2to3 doctests
2010-07-28 13:55:00maubpsetnosy: + maubp
2010-07-14 09:54:10tiagoantaosetstatus: closed -> open

messages: + msg110262
2010-07-11 16:27:37tiagoantaosetmessages: + msg110025
2010-07-11 16:13:06tiagoantaosetmessages: + msg110023
2010-07-11 10:32:30eric.araujosetnosy: + eric.araujo
messages: + msg109988
2010-07-10 20:03:20tiagoantaosetmessages: + msg109925
versions: + Python 2.6
2010-07-10 19:50:57tiagoantaosetfiles: + DocSQL.py

messages: + msg109917
2010-07-10 19:45:40benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg109916

resolution: fixed
2010-07-10 19:29:50tiagoantaosettype: crash
2010-07-10 19:27:48tiagoantaocreate