Modify

Opened 2 years ago

Closed 2 years ago

#13739 closed defect (fixed)

Python3: NameError: name 'unichr' is not defined / SyntaxError: invalid syntax

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

Description

Plugin fails in Python 3:

	Traceback (most recent call last):
	  File "trac\loader.py", line 80, in _load_eggs
		entry.load(require=True)
	  File "pkg_resources\__init__.py", line 2443, in load
		return self.resolve()
	  File "pkg_resources\__init__.py", line 2449, in resolve
		module = __import__(self.module_name, fromlist=['__name__'], level=0)
	  File "mailarchive\web_ui.py", line 24, in <module>
		from mailarchive.model import ArchivedMail
	  File "mailarchive\model.py", line 44, in <module>
		map(unichr, xrange(0x10000)))) +
	NameError: name 'unichr' is not defined
	Traceback (most recent call last):
	  File "trac\loader.py", line 80, in _load_eggs
		entry.load(require=True)
	  File "pkg_resources\__init__.py", line 2443, in load
		return self.resolve()
	  File "pkg_resources\__init__.py", line 2449, in resolve
		module = __import__(self.module_name, fromlist=['__name__'], level=0)
	  File "mailarchive\admin.py", line 52
		print "Skipping mail with UID %s" % (uid,)
			  ^
	SyntaxError: invalid syntax (admin.py, line 52)

Attachments (0)

Change History (3)

comment:1 Changed 2 years ago by Peter Suter

  • mailarchive/admin.py

    diff -r aff2cda05771 -r 3b30a6cdb827 mailarchive/admin.py
    a b  
    11# -*- coding: utf-8 -*-
    22
     3from __future__ import print_function
     4
    35import imaplib
    46import datetime
    57import os
     
    4951
    5052            # No duplicates
    5153            if ArchivedMail.select_by_id(self.env, uid) is not None:
    52                 print "Skipping mail with UID %s" % (uid,)
     54                print("Skipping mail with UID %s" % (uid,))
    5355                continue
    5456
    5557            typ, data = imap_conn.uid('fetch', uid, '(RFC822)')
  • mailarchive/model.py

    diff -r aff2cda05771 -r 3b30a6cdb827 mailarchive/model.py
    a b  
    1515from trac.util.datefmt import from_utimestamp, to_utimestamp, utc
    1616from trac.util.text import stripws
    1717
     18try:
     19    unichr
     20except NameError:
     21    unichr = chr # In Python 3 chr can be used instead of unichr in Python 2
     22
     23try:
     24    xrange
     25except NameError:
     26    xrange = range # In Python 3 range can be used instead of xrange in Python 2
    1827
    1928SCHEMA = [
    2029    Table('mailarchive', key='id')[
  • mailarchive/web_ui.py

    diff -r aff2cda05771 -r 3b30a6cdb827 mailarchive/web_ui.py
    a b  
    201201                for part in header[len(h):].split(' ')
    202202                if part
    203203                for found_mail in ArchivedMail.search(self.env, [part.strip()])
    204             }.iteritems())
     204            }.items())
    205205        ]
    206206
    207207        resource = Resource('mailarchive', id)

comment:2 Changed 2 years ago by lucid

In 17666:

MailArchivePlugin: Python3 compatibility.
(see #13739)

comment:3 Changed 2 years ago by lucid

Resolution: fixed
Status: newclosed

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.