Manpage: python script byte to string to fix blender.1.py #115127

Merged
Brecht Van Lommel merged 1 commits from HurricanePootis/blender:main into main 2023-11-22 20:01:07 +01:00
Contributor

Problem

As of right now, the blender.1.py script used to create the man page does not work. Whenever run with the following command (as per instructed in the header of the script), the error listed below the command is returned.

hurricane@TheCloutPC /run/media/hurricane/newmaindata/mine/blender/build/bin $ ./blender -b --python /run/media/hurricane/newmaindata/mine/blender/doc/manpage/blender.1.py -- --output blender.1
Blender 4.0.1 (hash d0dd92834a08 built 2023-11-19 08:46:17)
Read prefs: "/home/hurricane/.config/blender/4.0/config/userpref.blend"
Error: Python: Traceback (most recent call last):
  File "/run/media/hurricane/newmaindata/mine/blender/doc/manpage/blender.1.py", line 167, in main
    man_page_from_blender_help(fh, verbose)
  File "/run/media/hurricane/newmaindata/mine/blender/doc/manpage/blender.1.py", line 54, in man_page_from_blender_help
    blender_info = blender_extract_info()
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/hurricane/newmaindata/mine/blender/doc/manpage/blender.1.py", line 44, in blender_extract_info
    blender_date = time.strftime("%B %d, %Y", time.strptime(blender_build_date_text, "%Y-%m-%d"))
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/_strptime.py", line 562, in _strptime_time
    tt = _strptime(data_string, format)[0]
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/_strptime.py", line 317, in _strptime
    raise TypeError(msg.format(index, type(arg)))
TypeError: strptime() argument 0 must be str, not <class 'bytes'>

Blender quit

The fix

I added a .decode() to the end of blender_build_date_text to create blender_build_date_text.decode(). This converts the object bytes into a string, which time.strptime() can accept.

The whole reason I am doing this fix because, to my knowledge, the Arch Linux blender package maintainer hasn't yet released blender 4 on Arch because the man page was not being generated. Therefore, I decided to dig into this problem using my own experience. Eventually, after many lengthy compiles, I tracked down the issue to the python script.

My System & Notice

Arch Linux
Python 3.11.5
Glibc 2.38
Radeon RX 6800
Ryzen 5 5600X

I am not a developer, and this was my first time working with python. I apologize if I do anything wrong in creating this pull request, and I look forward to learning how to better myself in this professional environment.

# Problem As of right now, the `blender.1.py` script used to create the man page does not work. Whenever run with the following command (as per instructed in the header of the script), the error listed below the command is returned. ```python hurricane@TheCloutPC /run/media/hurricane/newmaindata/mine/blender/build/bin $ ./blender -b --python /run/media/hurricane/newmaindata/mine/blender/doc/manpage/blender.1.py -- --output blender.1 Blender 4.0.1 (hash d0dd92834a08 built 2023-11-19 08:46:17) Read prefs: "/home/hurricane/.config/blender/4.0/config/userpref.blend" Error: Python: Traceback (most recent call last): File "/run/media/hurricane/newmaindata/mine/blender/doc/manpage/blender.1.py", line 167, in main man_page_from_blender_help(fh, verbose) File "/run/media/hurricane/newmaindata/mine/blender/doc/manpage/blender.1.py", line 54, in man_page_from_blender_help blender_info = blender_extract_info() ^^^^^^^^^^^^^^^^^^^^^^ File "/run/media/hurricane/newmaindata/mine/blender/doc/manpage/blender.1.py", line 44, in blender_extract_info blender_date = time.strftime("%B %d, %Y", time.strptime(blender_build_date_text, "%Y-%m-%d")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/_strptime.py", line 562, in _strptime_time tt = _strptime(data_string, format)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/_strptime.py", line 317, in _strptime raise TypeError(msg.format(index, type(arg))) TypeError: strptime() argument 0 must be str, not <class 'bytes'> Blender quit ``` # The fix I added a `.decode()` to the end of `blender_build_date_text` to create `blender_build_date_text.decode()`. This converts the object bytes into a string, which time.strptime() can accept. The whole reason I am doing this fix because, to my knowledge, the Arch Linux blender package maintainer hasn't yet released blender 4 on Arch because the man page was not being generated. Therefore, I decided to dig into this problem using my own experience. Eventually, after many lengthy compiles, I tracked down the issue to the python script. # My System & Notice Arch Linux Python 3.11.5 Glibc 2.38 Radeon RX 6800 Ryzen 5 5600X I am not a developer, and this was my first time working with python. I apologize if I do anything wrong in creating this pull request, and I look forward to learning how to better myself in this professional environment.
HurricanePootis added 1 commit 2023-11-19 10:57:30 +01:00
HurricanePootis changed title from Manpage python script byte to string to Manpage: python script byte to string to fix blender.1.py 2023-11-19 11:15:41 +01:00
Brecht Van Lommel approved these changes 2023-11-22 20:00:04 +01:00
Brecht Van Lommel merged commit 70e2c0bcd4 into main 2023-11-22 20:01:07 +01:00

This has been backported to the 4.0 branch as well.

This has been backported to the 4.0 branch as well.
First-time contributor

Blender Arch maintainer here. This patch doesn't fix the problem for me. The author of this patch has produced a different solution for Arch Linux. However, I'd prefer if the actual problem could be fixed upstream.

Blender Arch maintainer here. This patch doesn't fix the problem for me. The author of this patch has produced a different solution for Arch Linux. However, I'd prefer if the actual problem could be fixed upstream.

Additional fix in #115320.

Additional fix in #115320.
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 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#115127
No description provided.