Patch to Python uuid module to avoid CRT warning on Windows #38364

Closed
opened 2014-01-25 19:07:17 +01:00 by Tom Edwards · 11 comments

There is a bug in Python's uuid module that has been affecting official Blender releases on Windows for several years. It's triggered by Blender's inclusion of the CRT redistributables, and causes a runtime exception to be thrown when the module is first imported. It's harmless, but the OS "runtime error" window that appears is disconcerting for users and a thorn in the side of anyone whose addon uses uuid.

In uuid.py I've applied the fix suggested in Python's bug tracker, and it works just fine. It would be good to get it into the next Blender release.

The file is located at lib/*/release/python33.tar.gz/uuid.py. I don't know how Git would handle changes to that file...perhaps a "patches" subdir and change to the INSTALL project would be appropriate?

There is [a bug in Python's `uuid` module ](http://bugs.python.org/issue17213) that has been affecting official Blender releases on Windows for several years. It's triggered by Blender's inclusion of the CRT redistributables, and causes a runtime exception to be thrown when the module is first imported. It's harmless, but the OS "runtime error" window that appears is disconcerting for users and a thorn in the side of anyone whose addon uses `uuid`. In [uuid.py](https://archive.blender.org/developer/F75395/uuid.py) I've applied the fix suggested in Python's bug tracker, and it works just fine. It would be good to get it into the next Blender release. The file is located at `lib/*/release/python33.tar.gz/uuid.py`. I don't know how Git would handle changes to that file...perhaps a "patches" subdir and change to the INSTALL project would be appropriate?
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @artfunkel

Added subscriber: @artfunkel
Thomas Dinges was assigned by Bastien Montagne 2014-01-26 15:28:51 +01:00

Added subscriber: @mont29

Added subscriber: @mont29

Thomas, as Windows release manager, I think this one is for you :)

Thomas, as Windows release manager, I think this one is for you :)

Any chance to fix this upstream rather than hacking it on our side?

I also rather let vc2008 libs die and don't change them again. We will switch to vc2012 or 2013 after the 2.70 release.

Any chance to fix this upstream rather than hacking it on our side? I also rather let vc2008 libs die and don't change them again. We will switch to vc2012 or 2013 after the 2.70 release.
Author

Since I added Python 3.3 to the list of affected platforms the bug has been getting a bit of attention, but seeing as it was reported two years ago let's not hold our breath...

Since I added Python 3.3 to the list of affected platforms the bug has been getting a bit of attention, but seeing as it was reported two years ago let's not hold our breath...

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Some nasty workarounds...

  import ctypes
  import sys
  sys.modules["ctypes"] = type(sys)("ctypes")  # dummy module, uuid can continue without it
  import uuid
  sys.modules["ctypes"] = ctypes
  del ctypes, sys

Infact simply temp overwriting CDLL works

  import ctypes
  CDLL = ctypes.CDLL
  ctypes.CDLL = None  # calls this this will fail, but python has a fallback
  import uuid
  ctypes.CDLL = CDLL
  del ctypes, CDLL
Some nasty workarounds... ``` import ctypes import sys sys.modules["ctypes"] = type(sys)("ctypes") # dummy module, uuid can continue without it import uuid sys.modules["ctypes"] = ctypes del ctypes, sys ``` Infact simply temp overwriting CDLL works ``` import ctypes CDLL = ctypes.CDLL ctypes.CDLL = None # calls this this will fail, but python has a fallback import uuid ctypes.CDLL = CDLL del ctypes, CDLL

Added subscriber: @Wiz

Added subscriber: @Wiz

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

With Python3.4x and MSVC2013, this is now resolved. closing.

With Python3.4x and MSVC2013, this is now resolved. closing.
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#38364
No description provided.