Skip to content

bpo-30183: Fixes HP-UX cc compilation error in pytime.c #1351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 21, 2017

Conversation

haney
Copy link
Contributor

@haney haney commented Apr 28, 2017

HP-UX does not support the CLOCK_MONOTONIC identifier, and will fail to
compile:

"Python/pytime.c", line 723: error #2020: identifier
"CLOCK_MONOTONIC" is undefined
      const clockid_t clk_id = CLOCK_MONOTONIC;

Add a new section for __hpux that calls gethrtime() instead of
clock_gettime().

HP-UX does not support the CLOCK_MONOTONIC identifier, and will fail to
compile:

    "Python/pytime.c", line 723: error python#2020: identifier
    "CLOCK_MONOTONIC" is undefined
          const clockid_t clk_id = CLOCK_MONOTONIC;

Add a new section for __hpux that calls 'gethrtime()' instead of
'clock_gettime()'.
@mention-bot
Copy link

@haney, thanks for your PR! By analyzing the history of the files in this pull request, we identified @benjaminp, @serhiy-storchaka and @abalkin to be potential reviewers.

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

Thanks again to your contribution and we look forward to looking at it!

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, except of a minor comment.

I cannot test, so I expect that you tested your own patch :-) Are you able to build Python with this change? Does test_time pass?

Python/pytime.c Outdated
if (time == -1) {
if (raise) {
PyErr_SetFromErrno(PyExc_OSError);
return -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You remove remove this duplicated return.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh. Thanks.

@haney
Copy link
Contributor Author

haney commented Jun 21, 2017

Yes, I successfully built the Python library and ran the test suite on HPUX after applying this patch.

It looks like test_time is failing. I'll dig into it and see if the failure is related to this change or other issues on HPUX (I'm seeing 40 tests fail). I'll update this pull request when I have additional information. Thanks for prompting that double-check on the state of the test.

@haney
Copy link
Contributor Author

haney commented Jun 21, 2017

The failing tests in test_time appear to be unrelated to this change, and I expect were pre-existing failures on this platform. The test output I'm seeing follows:

======================================================================
FAIL: test_4dyear (test.test_time.TestStrftime4dyear)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 557, in test_4dyear
    self.test_year('%04d', func=year4d)
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 587, in test_year
    self.assertEqual(func(1),    fmt % 1)
AssertionError: '' != '0001'
+ 0001

======================================================================
FAIL: test_large_year (test.test_time.TestStrftime4dyear)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 572, in test_large_year
    return super().test_large_year()
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 595, in test_large_year
    self.assertEqual(self.yearstr(12345), '12345')
AssertionError: '' != '12345'
+ 12345

======================================================================
FAIL: test_negative (test.test_time.TestStrftime4dyear)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 576, in test_negative
    return super().test_negative()
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 601, in test_negative
    self.assertEqual(self.yearstr(-1), self._format % -1)
AssertionError: '' != '-1'
+ -1

======================================================================
FAIL: test_year (test.test_time.TestStrftime4dyear)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 587, in test_year
    self.assertEqual(func(1),    fmt % 1)
AssertionError: '' != '1'
+ 1

======================================================================
FAIL: test_default_values_for_zero (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 210, in test_default_values_for_zero
    self.assertEqual(expected, result)
AssertionError: '2000 01 01 00 00 00 1 001' != ''
- 2000 01 01 00 00 00 1 001
+


======================================================================
FAIL: test_strptime (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 222, in test_strptime
    time.strptime(strf_output, format)
ValueError: time data '' does not match format '%d'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/amd/devco/haney/git/cpython/Lib/test/test_time.py", line 225, in test_strptime
    (format, strf_output))
AssertionError: conversion specifier '%d' failed with '' input.

----------------------------------------------------------------------

Since the tests that are failing all appear to be related to formatting time objects, I don't think they are related to this change. test_monotonic, which I would expect to be directly related to this change, is passing.

@vstinner vstinner merged commit c90e960 into python:master Jun 21, 2017
@vstinner
Copy link
Member

test_time failures seem to be unrelated to the monotonic clock. Let's do that in a new PR. Thanks @haney for fixing this HP-UX issue!

@haney haney deleted the bpo-30183 branch December 7, 2022 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants