typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

`os.EX_NOTFOUND` was... not found

Open qexat opened this issue 1 year ago • 3 comments

In the module os, EX_NOTFOUND is exposed on platforms that are neither win32 nor darwin. (source)

Using Python 3.11.6 on EndeavourOS 64-bit (Linux 6.6.10-arch1-1), raises at runtime:

AttributeError: module 'os' has no attribute 'EX_NOTFOUND'

I can also reproduce it with:

  • Python 3.9.18
  • Python 3.8.18
  • Python 3.13.0 (built from source from the main branch)

qexat avatar Jan 07 '24 15:01 qexat

According to https://stackoverflow.com/questions/51322536/python-on-unix-value-of-os-ex-notfound it exists on e.g. Solaris. We should add an and sys.platform != "linux" to the condition. PR welcome!

srittau avatar Jan 08 '24 02:01 srittau

@qexat Thanks for the issue! :-) I am kind of curious — what were you doing that led you to noticing this?

(In general, determining platform availability of constants has been a little tricky for Linux, since Linux / Python builds on Linux is not a monolith. So I'm quite curious about use cases that depend on this. As per usual, typeshed prefers false negatives over false positives, so we likely overstate constant availability on Linux anywhere we have a regex in stubtest allowlists)

hauntsaninja avatar Jan 08 '24 05:01 hauntsaninja

@qexat Thanks for the issue! :-) I am kind of curious — what were you doing that led you to noticing this?

For my snippets repository, I was writing a little dependency checker (very basic and in a few lines, really) that exits early with a code and I wanted to try using os constants — the module supposedly makes programs more portable :)

qexat avatar Jan 08 '24 07:01 qexat