Skip to content

Commit 1820edd

Browse files
committed
Runs on non-win32 systems now, without producing any output.
1 parent dba7511 commit 1820edd

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# pydbugstring
22

3-
Provides a function to call Windows OutputDebugString with any Python Object.
4-
Provides a handler for the Python Logging Module which sends logging to OutputDebugString.
3+
Provides a function OutputDebugString to call:
4+
- on win32 platforms, calls the ctypes.windll.kernel32.OutputDebugStringW with any Python Object, after converting that object to a string.
5+
- on other platforms, converts the argument to a string and discards it, returns 0
6+
7+
Provides a handler for the Python Logging Module which sends logging to OutputDebugString. On platforms other than win32, the logging output is disccarded.
58

69

710
The output can be viewed using the [DebugView](https://learn.microsoft.com/en-us/sysinternals/downloads/debugview) program from the SysInternals package from Microsoft.

src/pydebugstring/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"function to write python obects to OutputDebugString on windows"
2-
__version__ = '1.0.0.1'
2+
__version__ = '1.0.0.2'
33
from .output import outputDebugString
44
from .outputdebugstringhandler import OutputDebugStringHandler

src/pydebugstring/output.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import ctypes
2-
W32OutputDebugString = ctypes.windll.kernel32.OutputDebugStringW
2+
from sys import platform
3+
if platform == "win32":
4+
W32OutputDebugString = ctypes.windll.kernel32.OutputDebugStringW
5+
else:
6+
def W32OutputDebugString(arg):
7+
"""Dummy function as an alternative to W32OutputDebugString in case code using this module
8+
is run on platfomrs other than win32. W32OutputDebugString does nothing, returns 0.
9+
"""
10+
return 0
311

412
def outputDebugString(to_show):
513
"""

0 commit comments

Comments
 (0)