Modify

Opened 4 years ago

Closed 4 years ago

#13736 closed defect (fixed)

Python3: ModuleNotFoundError: No module named 'StringIO'

Reported by: Peter Suter Owned by: lucid
Priority: normal Component: WeekPlanPlugin
Severity: normal Keywords: python3
Cc: Trac Release:

Description

Plugin fails to load with Python3:

	ModuleNotFoundError: No module named 'StringIO'

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by Peter Suter

  • weekplan/core.py

    diff -r 260f0363c21f -r f7154f499658 weekplan/core.py
    a b  
    44from json.encoder import JSONEncoder
    55import pkg_resources
    66import re
    7 from StringIO import StringIO
     7try:
     8    from StringIO import StringIO # Python 2
     9except ImportError:
     10    from io import StringIO # Python 3
     11
    812
    913from trac import __version__
    1014from trac.db.api import DatabaseManager
  • weekplan/macro.py

    diff -r 260f0363c21f -r f7154f499658 weekplan/macro.py
    a b  
    11# -*- coding: utf-8 -*-
    22
     3from __future__ import division
     4
    35import datetime
    46import math
    5 
     7from functools import reduce
    68
    79from trac.core import *
    810from trac.util.datefmt import parse_date, utc
     
    4749            raise TracError('Missing plan id')
    4850
    4951        colors = kw.get('color', '#38A|#4B6|#DA8|#9CD|#CAD|#CC7').split('|')
    50         colors = dict(zip(plan_ids, colors*((len(plan_ids)-1)/len(colors)+1)))
     52        colors = dict(zip(plan_ids, colors*((len(plan_ids)-1)//len(colors)+1)))
    5153
    5254        labels = [label for label in kw.get('label', '').split('|') if label]
    5355        labels = dict(zip(plan_ids, labels + plan_ids[len(labels):]))

comment:2 Changed 4 years ago by lucid

Resolution: fixed
Status: newclosed

In 17664:

WeekPlanPlugin: Python3 compatibility.
(fix #13736)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain lucid.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.