tkinter.TclError: character U+1f449 is above the range (U+0000-U+FFFF) allowed by Tcl
The problem is described in a python bug report:
I took the solution posted there an adapted it to processing gmail messages where the Subject line somehow has incorrect characters inserted sometimes:
try: iid = self.lib_tree.insert("", tk.END, tags="unchecked", values=(message_id, subject, sender, epoch, date, labels, snippet))except tk.TclError: print('old subject:', subject) import re # From: https://bugs.python.org/issue21084 astral = re.compile(r'([^\x00-\uffff])') s = subject new_subject = "" for i, ss in enumerate(re.split(astral, s)): if not i%2: new_subject += ss else: new_subject += '?' print('new_subject:', new_subject) continue
Output from program loading about 5,000 gmail messages:
$ bserve.pyold subject: Mserve June 18/2021new_subject: Mser?e June 18/2021old subject: mserve December 7, 2020new_subject: mser?e December 7, 2020old subject: Re: WinEunuuchs2Unixnew_subject: Re: WinEunuuchs2Uni?old subject: 🚚 ORDER UPDATE: 2019 Cigarette Light...new_subject: ? ORDER UPDATE: 2019 Cigarette Light...old subject: 📌 You've got 18 new ideas waiting for you!new_subject: ? You'?e got 18 ne? ideas ?aiting for ?ou!old subject: 🔥 Get inspired with these 18 trending ideasnew_subject: ? Get inspired ?ith these 18 trending ideasold subject: 🔥 18 popular Pins for younew_subject: ? 18 popular Pins for ?ouold subject: 🔥 Get inspired with these 18 trending ideasnew_subject: ? Get inspired ?ith these 18 trending ideasold subject: 🔥 Get inspired with these 18 trending ideasnew_subject: ? Get inspired ?ith these 18 trending ideasold subject: 📌 You've got 18 new ideas waiting for you!new_subject: ? You'?e got 18 ne? ideas ?aiting for ?ou!old subject: 📌 We picked some Puzzle art Pins for younew_subject: ? We picked some Pu??le art Pins for ?ouold subject: 🔵 INFANTRY Mens LCD Digital Quartz Wrist Watch Tactical Sport Stainless Steel Navy is HOT on eBay, but quantity is limitednew_subject: ? INFANTRY Mens LCD Digital Quart? Wrist Watch Tactical Sport Stainless Steel Na?? is HOT on eBa?, but quantit? is limitedold subject: 🔵 POLJOT AVIATOR ATTACK PLANE MEN`S RUSSIAN MILITARY WATCH is HOT on eBay, but quantity is limitednew_subject: ? POLJOT AVIATOR ATTACK PLANE MEN`S RUSSIAN MILITARY WATCH is HOT on eBa?, but quantit? is limited
Some are obvious reasons like "🔥". Some are less obvious like "Mserve" has invalid "v" and becomes "Mser?e".
I suppose there was a glitch when I wrote the mserve project email in Android from me when traveling to me for when I get home at end of trip.