View Issue Details

IDProjectCategoryView StatusLast Update
0000995FreeCADFeaturepublic2018-10-23 10:14
ReporteryorikAssigned Toyorik 
PriorityurgentSeveritymajorReproducibilityN/A
Status assignedResolutionopen 
Product Version 
Target Version0.18Fixed in Version 
Summary0000995: Python3 compatibility (Ongoing)
DescriptionStarting a thread about python3 compatibility.
Additional InformationActive discussion thread: https://forum.freecadweb.org/viewtopic.php?f=10&t=12534
TagsNo tags attached.

Relationships

parent of 0001744 closedwmayer FreeCAD Use unicode in Unit system 
parent of 0003630 assignedsliptonic Path Can't create a new tool 
related to 0001795 closedyorik Arch adapt IFC exporters to accept unicode filenames 
Not all the children of this issue are yet resolved or closed.

Activities

yorik

2013-04-17 15:22

administrator   ~0003071

Started to work on this in https://github.com/yorikvanhavre/FreeCAD/tree/python3

shoogen

2013-04-20 06:48

developer   ~0003086

Last edited: 2013-04-20 06:50

I think python 3 compatibility depends on issue #1027.
Because we have to carefufully jugde when to use byte strings and when to use (default/unicode) objects.

yorik

2013-04-20 17:48

administrator   ~0003089

Yes without a doubt. I was trying to take the lazy way and leave at most as possible the strings as they are, and solve the utf problems later, as they arise....

But yes your approach would obviously be better

shoogen

2014-09-20 07:49

developer   ~0005134

http://forum.freecadweb.org/viewtopic.php?f=10&t=7713
https://github.com/yorikvanhavre/FreeCAD/tree/pyccc625

shoogen

2014-10-02 07:31

developer   ~0005177

Last edited: 2014-10-02 07:31

View 2 revisions

Maybe we should start using
from __future__ import print_function
in python modules

yorik

2014-10-05 22:53

administrator   ~0005194

As a proff of concept, I adapted the Draft module to be compatible with python3. It is relatively easy to make the python code compatible with both py2 and py3.

99% of the issues are:
- print something -> print(something)
- for k,v in dict.iteritems() -> for k,v in dict.items()
- if dict.has_key(k) -> if k in dict

Using 2to3 shows what needs to be changed:
- Try running "2to3" like this: 2to3 myfile.py
- This writes the changes (only do if you don't have any doubt about the changes, some might not be what you want): 2to3 -w myfile.py
- Sometimes 2to3 still shows print statements even after they are changed, in this case: 2to3 -x print myfile.py

shoogen

2014-10-06 18:01

developer   ~0005195

But the without the from __future__ imports the scripts will behave differently in python2 and python3, won't they?

yorik

2014-10-06 18:46

administrator   ~0005198

No, the above methods all work in python2 too, that's the whole point:

- print() works in both versions
- dict.iteritems() returns an iterable, dict.items() returns a list of tuples in python2, and an iterable in python3. Both are iterable anyway.
- if k in dict works in python2 too

There are stil la couple of things I'm not sure if they work in both versions, namely all about unicode. I lest them as they are, but added a # Python3 comment, so the day we switch, they will be easy to find (there are not many)

local imports also behave differently, but that are all easy things to fix later.

shoogen

2014-10-06 21:40

developer   ~0005200

I'm not convinced

$ python3
Python 3.2.3 (default, Feb 20 2013, 14:44:27)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print (1,2,3)
1 2 3
>>>
$ python2
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print (1,2,3)
(1, 2, 3)
>>>

yorik

2014-10-06 21:50

administrator   ~0005201

Last edited: 2014-10-06 21:51

View 2 revisions

hmm you picked exactly the corner case...
Anyway, that shouldn't be a very big problem

shoogen

2014-10-07 11:21

developer   ~0005202

why do we use print in the first place? (Instead of FreeCAD.Console...)

yorik

2014-10-07 12:16

administrator   ~0005203

Mainly for degugging I think. But you are right, probably many of the print statements should be converted to Console messages (and dutifully translated...)

shoogen

2015-01-30 17:34

developer   ~0005750

we should check our usage of as_std_string (without the encoding parameter)
git grep ".as_std_string()" src/App/ src/Gui/ src/Mod/
lists 31 occurrences

yorik

2016-01-03 19:12

administrator   ~0006663

current progresses in https://github.com/yorikvanhavre/FreeCAD/tree/py3-3 rebased on current master

- Base, App and Gui are ported
- Builds successfully with pyton2 and python3
- Crashes when launching with both versions :(

Kunda1

2017-01-28 20:44

manager   ~0008064

Last edited: 2018-08-31 06:58

View 4 revisions

Python 3 port continues in forum: https://forum.freecadweb.org/viewtopic.php?f=10&t=12534
@looooo has been spearheading python 3 port: here is a roadmap list: https://github.com/looooo/FreeCAD/issues/8

Kunda1

2018-03-19 13:46

manager   ~0011048

Per wmayer:
[quote=wmayer]From my point of view we should finish the Py3 port ASAP when starting with v0.18 development. I would then make Py3 the default version but keep Py2 specific code for a while[/quote] ([url=https://forum.freecadweb.org/viewtopic.php?f=10&t=12534&p=222019#p222019]link[/url])

Issue History

Date Modified Username Field Change
2013-02-14 20:41 yorik New Issue
2013-02-14 20:41 yorik Status new => assigned
2013-02-14 20:41 yorik Assigned To => yorik
2013-04-17 15:22 yorik Note Added: 0003071
2013-04-20 06:48 shoogen Note Added: 0003086
2013-04-20 06:49 shoogen Note Edited: 0003086
2013-04-20 06:50 shoogen Note Edited: 0003086
2013-04-20 17:48 yorik Note Added: 0003089
2013-04-23 22:05 yorik Relationship added child of 0001027
2013-11-04 23:05 yorik Target Version 0.14 =>
2014-07-06 15:27 yorik Target Version => 0.15
2014-09-13 21:19 shoogen Relationship added parent of 0001744
2014-09-20 07:49 shoogen Note Added: 0005134
2014-09-27 18:46 yorik Changeset attached => FreeCAD Master master f87bd2ac
2014-09-27 18:47 yorik Changeset attached => FreeCAD Master master 69c4b37f
2014-09-27 18:47 yorik Changeset attached => FreeCAD Master master ad3908cc
2014-10-02 07:31 shoogen Note Added: 0005177
2014-10-02 07:31 shoogen Note Edited: 0005177 View Revisions
2014-10-05 22:40 yorik Changeset attached => FreeCAD Master master 8d2e08ff
2014-10-05 22:53 yorik Note Added: 0005194
2014-10-05 23:00 yorik Changeset attached => FreeCAD Master master daedcf4f
2014-10-06 18:01 shoogen Note Added: 0005195
2014-10-06 18:46 yorik Note Added: 0005198
2014-10-06 21:40 shoogen Note Added: 0005200
2014-10-06 21:50 yorik Note Added: 0005201
2014-10-06 21:51 yorik Note Edited: 0005201 View Revisions
2014-10-07 11:21 shoogen Note Added: 0005202
2014-10-07 12:16 yorik Note Added: 0005203
2014-10-11 12:43 shoogen Relationship deleted child of 0001027
2014-10-22 08:17 shoogen Relationship added related to 0001795
2015-01-20 23:28 yorik Target Version 0.15 =>
2015-01-30 17:34 shoogen Note Added: 0005750
2015-02-08 14:59 wmayer Changeset attached => FreeCAD Master master faac8c36
2016-01-03 19:12 yorik Note Added: 0006663
2017-01-28 20:44 Kunda1 Note Added: 0008064
2017-01-29 21:59 Kunda1 Note Edited: 0008064 View Revisions
2017-01-29 21:59 Kunda1 Note Edited: 0008064 View Revisions
2017-03-13 13:56 Kunda1 Changeset attached => FreeCAD master 0196d50c
2017-03-13 13:57 Kunda1 Changeset attached => FreeCAD master 81884f78
2017-03-13 13:58 Kunda1 Changeset attached => FreeCAD master 7a0a9974
2017-03-13 13:58 Kunda1 Changeset attached => FreeCAD master f94e1ff2
2017-03-13 13:58 Kunda1 Changeset attached => FreeCAD master 99131438
2017-03-13 13:58 Kunda1 Changeset attached => FreeCAD master 946c1268
2017-03-13 13:59 Kunda1 Changeset attached => FreeCAD master 4664e5bb
2017-03-13 13:59 Kunda1 Changeset attached => FreeCAD master dd02fc12
2017-03-13 13:59 Kunda1 Changeset attached => FreeCAD master 8b45976c
2017-03-13 14:00 Kunda1 Changeset attached => FreeCAD master 69828c26
2017-03-13 14:00 Kunda1 Changeset attached => FreeCAD master a388a9d7
2017-03-13 14:01 Kunda1 Changeset attached => FreeCAD master 1a4385e0
2017-03-13 14:01 Kunda1 Changeset attached => FreeCAD master 47059805
2017-03-13 14:01 Kunda1 Changeset attached => FreeCAD master 0e9189e7
2017-03-13 14:03 Kunda1 Changeset attached => FreeCAD master d5348c60
2017-03-13 14:04 Kunda1 Changeset attached => FreeCAD master b61a95c7
2017-03-13 14:05 Kunda1 Changeset attached => FreeCAD master be2b5777
2017-03-13 14:05 Kunda1 Changeset attached => FreeCAD master 9a5d920f
2017-03-13 14:05 Kunda1 Changeset attached => FreeCAD master 70451135
2017-03-13 14:05 Kunda1 Changeset attached => FreeCAD master 8bc6936b
2017-03-13 14:07 Kunda1 Changeset attached => FreeCAD master 4d21adf4
2017-03-13 14:07 Kunda1 Changeset attached => FreeCAD master 99fa203f
2017-03-13 14:08 Kunda1 Changeset attached => FreeCAD master 05544f39
2017-03-13 14:08 Kunda1 Changeset attached => FreeCAD master d925db17
2017-03-13 14:09 Kunda1 Changeset attached => FreeCAD master 3803896f
2017-03-13 14:09 Kunda1 Changeset attached => FreeCAD master e90ddefb
2017-03-13 14:11 Kunda1 Changeset attached => FreeCAD master ed23c0d3
2017-03-13 14:11 Kunda1 Changeset attached => FreeCAD master 76b33977
2017-03-13 14:11 Kunda1 Changeset attached => FreeCAD master 55545fbc
2017-03-13 14:11 Kunda1 Changeset attached => FreeCAD master 125fd78f
2017-03-13 14:11 Kunda1 Changeset attached => FreeCAD master 944d62ef
2017-03-13 14:11 Kunda1 Changeset attached => FreeCAD master 04e0620d
2017-03-13 14:11 Kunda1 Changeset attached => FreeCAD master 70aebe98
2017-03-13 14:12 Kunda1 Changeset attached => FreeCAD master 1558e920
2017-03-13 14:12 Kunda1 Changeset attached => FreeCAD master 21ffbeaf
2017-03-13 14:12 Kunda1 Changeset attached => FreeCAD master bcde3cd5
2017-03-13 14:12 Kunda1 Changeset attached => FreeCAD master 381419c2
2017-03-13 14:12 Kunda1 Changeset attached => FreeCAD master 8696ecdf
2017-03-13 14:12 Kunda1 Changeset attached => FreeCAD master 38921cf3
2017-03-13 14:12 Kunda1 Changeset attached => FreeCAD master 3d3a8d01
2017-03-13 14:13 Kunda1 Changeset attached => FreeCAD master a101d426
2017-03-13 14:13 Kunda1 Changeset attached => FreeCAD master 32bacd0b
2017-03-13 14:13 Kunda1 Changeset attached => FreeCAD master 2673f9ed
2017-03-13 14:13 Kunda1 Changeset attached => FreeCAD master 4f43cfac
2017-03-13 14:13 Kunda1 Changeset attached => FreeCAD master 742d92c6
2017-03-13 14:13 Kunda1 Changeset attached => FreeCAD master 3efc4fee
2017-03-13 14:13 Kunda1 Changeset attached => FreeCAD master 9b6ef856
2017-03-13 14:13 Kunda1 Changeset attached => FreeCAD master 15916016
2017-03-13 14:15 Kunda1 Changeset attached => FreeCAD master da2b9f38
2017-03-13 14:16 Kunda1 Changeset attached => FreeCAD master 8ad2c699
2017-03-13 14:16 Kunda1 Changeset attached => FreeCAD master 31e44895
2017-03-13 14:16 Kunda1 Changeset attached => FreeCAD master 1a21a4bc
2017-03-13 14:16 Kunda1 Changeset attached => FreeCAD master 2bc11621
2017-03-13 14:16 Kunda1 Changeset attached => FreeCAD master f3fb6762
2017-03-13 14:16 Kunda1 Changeset attached => FreeCAD master 4915a099
2017-03-13 14:17 Kunda1 Changeset attached => FreeCAD master 0afb7b6a
2017-03-13 14:17 Kunda1 Changeset attached => FreeCAD master 9f2a389d
2017-03-13 14:17 Kunda1 Changeset attached => FreeCAD master a460c540
2017-03-13 14:17 Kunda1 Changeset attached => FreeCAD master dcdce7ba
2017-03-13 14:17 Kunda1 Changeset attached => FreeCAD master 8165b2ab
2017-03-13 14:17 Kunda1 Changeset attached => FreeCAD master fc2010ba
2017-03-13 14:17 Kunda1 Changeset attached => FreeCAD master b265030d
2017-03-13 14:18 Kunda1 Changeset attached => FreeCAD master e47edae9
2017-03-13 14:18 Kunda1 Changeset attached => FreeCAD master 06a5bfb0
2017-03-13 14:18 Kunda1 Changeset attached => FreeCAD master 9d85f3bb
2017-03-13 14:18 Kunda1 Changeset attached => FreeCAD master 52fc8191
2017-03-13 14:18 Kunda1 Changeset attached => FreeCAD master 76a4e746
2017-03-13 14:18 Kunda1 Changeset attached => FreeCAD master 5c0bcf61
2017-03-13 14:19 Kunda1 Changeset attached => FreeCAD master 915a1b18
2017-03-13 14:19 Kunda1 Changeset attached => FreeCAD master 3617fc36
2017-03-13 15:22 Kunda1 Changeset attached => FreeCAD master 2f93571c
2017-03-13 15:24 Kunda1 Changeset attached => FreeCAD master c0ec75eb
2017-03-13 15:25 Kunda1 Changeset attached => FreeCAD master e9b57222
2017-03-13 15:27 Kunda1 Changeset attached => FreeCAD master 42331bde
2017-03-13 15:27 Kunda1 Changeset attached => FreeCAD master f9cb89a9
2017-03-13 15:27 Kunda1 Changeset attached => FreeCAD master 91e2e004
2017-03-13 15:29 Kunda1 Changeset attached => FreeCAD master f6b6e62a
2017-03-13 15:37 Kunda1 Changeset attached => FreeCAD master 8b5fb47e
2017-03-13 15:37 Kunda1 Changeset attached => FreeCAD master 3a273788
2017-03-13 15:38 Kunda1 Changeset attached => FreeCAD master adb9353d
2017-03-13 15:38 Kunda1 Changeset attached => FreeCAD master a39ef71d
2017-03-13 15:38 Kunda1 Changeset attached => FreeCAD master 71f6a289
2017-03-13 15:39 Kunda1 Changeset attached => FreeCAD master da1081bc
2017-03-13 15:39 Kunda1 Changeset attached => FreeCAD master 159dbe2c
2017-03-13 15:39 Kunda1 Changeset attached => FreeCAD master 55826040
2017-03-13 15:39 Kunda1 Changeset attached => FreeCAD master 81464b5e
2017-03-13 15:40 Kunda1 Changeset attached => FreeCAD master c9f168d3
2017-03-13 15:41 Kunda1 Changeset attached => FreeCAD master aa7aa647
2017-03-13 15:41 Kunda1 Changeset attached => FreeCAD master bf10bf33
2017-03-13 15:41 Kunda1 Changeset attached => FreeCAD master 094a4352
2017-03-13 15:41 Kunda1 Changeset attached => FreeCAD master 85d8d704
2017-03-13 15:41 Kunda1 Changeset attached => FreeCAD master a5b6e5d4
2017-03-13 15:41 Kunda1 Changeset attached => FreeCAD master a07b9cd0
2017-03-13 15:41 Kunda1 Changeset attached => FreeCAD master b5bf7d6b
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master b10f8386
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master 91d6e24f
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master ebc6d372
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master f85d168e
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master 28144778
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master a6434637
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master cb922404
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master 05279d28
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master 10814929
2017-03-13 15:42 Kunda1 Changeset attached => FreeCAD master 65fe62d9
2017-03-13 15:43 Kunda1 Changeset attached => FreeCAD master bfdaa46f
2017-03-13 15:43 Kunda1 Changeset attached => FreeCAD master 36383135
2017-03-13 15:43 Kunda1 Changeset attached => FreeCAD master d78d7477
2017-03-13 15:43 Kunda1 Changeset attached => FreeCAD master a467612b
2017-03-13 15:43 Kunda1 Changeset attached => FreeCAD master 5aea3220
2017-03-13 15:44 Kunda1 Changeset attached => FreeCAD master 391cdf81
2017-03-13 15:44 Kunda1 Changeset attached => FreeCAD master f0951065
2017-04-26 00:20 Kunda1 Summary Python3 compatibility => Python3 compatibility (Ongoing)
2017-04-26 00:21 Kunda1 Sticky Issue No => Yes
2017-04-28 01:47 Kunda1 Changeset attached => FreeCAD master 84f86442
2017-05-06 20:21 Kunda1 Changeset attached => FreeCAD master 226dd17e
2017-05-06 20:22 Kunda1 Changeset attached => FreeCAD master aa3f9288
2017-05-06 20:22 Kunda1 Changeset attached => FreeCAD master a3539c51
2017-05-07 13:54 Kunda1 Changeset attached => FreeCAD master 4f044dcb
2017-05-10 19:13 wmayer Changeset attached => FreeCAD master 0d033757
2017-05-11 17:55 Kunda1 Changeset attached => FreeCAD master b07075db
2017-05-11 17:56 Kunda1 Changeset attached => FreeCAD master ca3e58e2
2017-05-15 20:51 Kunda1 Changeset attached => FreeCAD master dc413acc
2017-05-22 12:37 Kunda1 Changeset attached => FreeCAD master fed9d791
2017-05-22 12:37 Kunda1 Changeset attached => FreeCAD master ef22d520
2017-05-22 12:41 Kunda1 Changeset attached => FreeCAD master 2becb8a0
2017-05-22 12:41 Kunda1 Changeset attached => FreeCAD master 5fbca1a4
2017-05-22 12:42 Kunda1 Changeset attached => FreeCAD master 0e9e49cb
2017-05-22 12:42 Kunda1 Changeset attached => FreeCAD master 94c68d72
2017-05-28 00:06 Kunda1 Changeset attached => FreeCAD master 852a9841
2017-06-21 20:31 Kunda1 Changeset attached => FreeCAD master 947c10a4
2017-06-21 20:32 Kunda1 Changeset attached => FreeCAD master 11dcd18e
2017-07-04 13:12 Kunda1 Changeset attached => FreeCAD master b77d8cac
2017-07-18 16:05 Kunda1 Changeset attached => FreeCAD master 2e118be3
2017-07-18 16:18 Kunda1 Changeset attached => FreeCAD master a6894034
2018-03-19 13:46 Kunda1 Note Added: 0011048
2018-03-19 13:46 Kunda1 Target Version => 0.18
2018-03-19 13:48 Kunda1 Priority normal => urgent
2018-03-19 13:48 Kunda1 Severity minor => major
2018-08-31 06:58 Kunda1 Additional Information Updated View Revisions
2018-08-31 06:58 Kunda1 Note Edited: 0008064 View Revisions
2018-10-23 10:14 Kunda1 Relationship added parent of 0003630